{"record":{"id":"4618a7c6218b5118","repo":"docusealco/docuseal","slug":"failed-to-load-text-page-page-index-pointer-is","errorCode":null,"errorMessage":"Failed to load text page #{page_index}, pointer is NULL.","messagePattern":"Failed to load text page #(.+?), pointer is NULL\\.","errorType":"exception","errorClass":"Pdfium::PdfiumError","httpStatus":null,"severity":"error","filePath":"lib/pdfium.rb","lineNumber":1063,"sourceCode":"\n      bitmap_data = buffer_ptr.read_bytes(stride * render_height)\n\n      [bitmap_data, render_width, render_height]\n    ensure\n      Pdfium.FPDFBitmap_Destroy(bitmap_ptr) if bitmap_ptr && !bitmap_ptr.null?\n    end\n\n    def text\n      return @text if @text\n\n      ensure_not_closed!\n\n      text_page = Pdfium.FPDFText_LoadPage(page_ptr)\n\n      if text_page.null?\n        Pdfium.check_last_error(\"Failed to load text page #{page_index}\")\n\n        raise PdfiumError, \"Failed to load text page #{page_index}, pointer is NULL.\"\n      end\n\n      char_count = Pdfium.FPDFText_CountChars(text_page)\n\n      return @text = '' if char_count.zero?\n\n      buffer_char_capacity = char_count + 1\n\n      buffer = FFI::MemoryPointer.new(:uint16, buffer_char_capacity)\n\n      chars_written = Pdfium.FPDFText_GetText(text_page, 0, buffer_char_capacity, buffer)\n\n      if chars_written <= 0\n        Pdfium.check_last_error(\"Failed to extract text from page #{page_index}\")\n\n        return @text = ''\n      end\n","sourceCodeStart":1045,"sourceCodeEnd":1081,"githubUrl":"https://github.com/docusealco/docuseal/blob/004a22c1c88109c7ba0b567df011a8cb13894001/lib/pdfium.rb#L1045-L1081","documentation":"Raised by Page#text when FPDFText_LoadPage returns NULL for the loaded page. check_last_error runs first and raises the error-code variant when PDFium recorded one, so this plain message means the text layer could not be built without a recorded code, typically a content stream pdfium cannot parse. A scanned PDF without OCR is not a failure (char_count of 0 returns an empty string), so this error signals actual structural damage.","triggerScenarios":"Calling page.text on a page whose content stream is corrupt; documents that only partially loaded; pages damaged by earlier failed edit operations on the same document object.","commonSituations":"Search/indexing pipelines over user uploads; text extraction from PDFs produced by broken generators; files that survived partial transfers.","solutions":["Confirm other pages extract fine to isolate a single bad page, and treat that page as having no text","Repair the file externally (qpdf --decrypt or ghostscript re-distill) and retry","Rescue per page and continue the job rather than failing the whole document","Update libpdfium; text-loading fixes ship in most releases"],"exampleFix":"# before\ntext = doc.pages.map(&:text).join\n\n# after\ntext = doc.pages.filter_map do |page|\n  begin\n    page.text\n  rescue Pdfium::PdfiumError\n    '' # skip unparseable page\n  end\nend.join","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"text = begin\n  page.text\nrescue Pdfium::PdfiumError\n  '' # unparseable page: no text rather than failed job\nend","preventionTips":["Make text extraction per-page resilient; one damaged page should not kill the document job","Run qpdf/ghostscript repair on uploads that fail text loading","Keep libpdfium current"],"tags":["pdfium","text-extraction","corrupt-pdf","ruby"],"backgroundTag":"pdf-text-extraction-failed","analyzedSha":"004a22c1c88109c7ba0b567df011a8cb13894001","analyzedAt":"2026-08-21T13:38:23.343Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}