Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Apr 17, 2024 10:19 am

Hi, I'm getting the below error message when I'm trying to convert certain PDF files to docx.

Error message:
Code: Select all
Traceback (most recent call last):
  File "/src/pdf2text.py", line 8, in <module>
    processor.process_document()
  File "/src/utils/document_processor.py", line 68, in process_document
    self._convert_pdf_to_docx()
  File "/src/utils/document_processor.py", line 84, in _convert_pdf_to_docx
    pdf_converter.convert_to_docx(self.temp_docx_filepath)
  File "/src/utils/pdf_to_docx_converter.py", line 23, in convert_to_docx
    self.doc.SaveToFile(output_file, FileFormat.DOCX)
  File "/usr/local/lib/python3.10/dist-packages/plum/function.py", line 642, in __call__
    return self.f(self.instance, *args, **kw_args)
  File "/usr/local/lib/python3.10/dist-packages/plum/function.py", line 592, in __call__
    return _convert(method(*args, **kw_args), return_type)
  File "/usr/local/lib/python3.10/dist-packages/spire/pdf/PdfDocument.py", line 287, in SaveToFile
    CallCFunction(GetDllLibPdf().PdfDocument_SaveToFileFF,self.Ptr, filename,enumfileFormat)
  File "/usr/local/lib/python3.10/dist-packages/spire/pdf/common/__init__.py", line 109, in CallCFunction
    raise SpireException(info)
spire.pdf.common.SpireException: Arg_NullReferenceException:   at sprf1k.spra(sprf1d, String, sprf3n[], spraq6, Double, Double, Double, Boolean, sprauj, Boolean, Boolean) + 0xf7
   at sprf07.spra(sprf3v, String, Boolean) + 0x429
   at sprf07.spra(spreb0, String) + 0x4a9
   at sprf07.sprd(spreb0) + 0xc35
   at sprf07.spra(Boolean) + 0xf9
   at sprf4a.spra(spreb8, sprdfc, sprf07) + 0xd8f
   at sprf07.spre(spreb0) + 0x146
   at sprf07.spra(Boolean) + 0xf9
   at sprecn.spra(Int32) + 0x1a2
   at Spire.Pdf.Conversion.PdfToDocConverter.spra(PdfDocumentBase, Stream, Int32, Int32) + 0xff
   at Spire.Pdf.PdfDocumentBase.spra(String, Boolean) + 0x13e
   at Spire.Pdf.AOT.NLPdfDocument.PdfDocument_SaveToFileFF(IntPtr, IntPtr, Int32, IntPtr) + 0x7b


Code:
Code: Select all
from utils.pdf_to_docx_converter import PDFToDOCXConverter

def _convert_pdf_to_docx():
    pdf_converter = PDFToDOCXConverter(pdf_path)
    pdf_converter.convert_to_docx(temp_docx_filepath)


In my pdf_to_docx_converter.py file:

Code: Select all
from spire.pdf.common import *
from spire.pdf import PdfDocument, FileFormat

class PDFToDOCXConverter:
    def __init__(self, pdf_file):
        self.pdf_file = pdf_file
        self.doc = PdfDocument()

    def convert_to_docx(self, output_file):
        self.doc.LoadFromFile(self.pdf_file)
        self.doc.SaveToFile(output_file, FileFormat.DOCX)
        self.doc.Close()



I'm using Spire.Pdf 10.2.0 for Python (installed via pypi), and using WSL. The PDF file I used is too big so it can't be uploaded, but it's a PDF of a paper I downloaded online (paper name: BBDM: Image-to-Image Translation with Brownian Bridge Diffusion Models)

Appreciate the help, thank you.

haleyteh
 
Posts: 2
Joined: Thu Apr 04, 2024 8:42 am

Thu Apr 18, 2024 2:53 am

Hi,

Thanks for your inquiry.
I indeed need the pdf file to test your scenario, but I didn’t find the pdf file you mentioned in internet. For the big file, you could upload it via Dropbox or OneDrive server, then share us with the download link. Thanks in advance.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Thu Apr 18, 2024 4:18 am

Hi,

I've tried on both these PDF files and had the same problem above (please preppend "www dropbox com" in front as I'm not allowed to post URLs):

/scl/fi/kyqgoiggpbd4p8vpqxbyh/test.pdf?rlkey=ja6ytpwglbzekn0ubkfiu0sko&st=qegspa7k&dl=0
/scl/fi/z9pvpnak0lo2k0zkfs96b/test2.pdf?rlkey=a0zbiam081aawiefpk16egs04&st=nb94yo2q&dl=0

I'm also not sure if this because I did not apply for a temporary license previously? I just did so yesterday, but have not received the license yet.

Thanks!

haleyteh
 
Posts: 2
Joined: Thu Apr 04, 2024 8:42 am

Thu Apr 18, 2024 9:58 am

Hi,

Thanks for your feedback.
I have got the two Pdf files you provided, and I'll give you feedback after testing as soon as.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.PDF