python-3.xpdfnet

The dictionary does not contain required key: Pages


I am trying to convert pdf to pdf/a using PDFNetPython3. However I am getting following errors. Main error message: The dictionary does not contain required key: Pages

According to PDFNetPython3 docs.

from PDFNetPython3 import PDFNet, PDFACompliance
# ... some necessary code like temp_file_path_in (this is not null and has values of file_object)

pdf_a = PDFACompliance(True, tmp_file_path_in, None, PDFACompliance.e_Level2B, 0, 0, 10)

Also tried using this(got same error):

pdf_a = PDFACompliance(True, filename, None, PDFACompliance.e_Level2B, 0, 10)

I wanted to know does this Pages related to pdf page numbers or total page count. I am merging a blank pdf page with other pdf pages and converting to pdfa !

Refrence: https://www.pdftron.com/documentation/python/guides/features/pdfa/convert/

Thanks in advance!!!


Solution

  • The exception indicates that the document you are processing does not contain any pages. Since you are merging a blank PDF, it is likely you missed the PDFDoc.PagePushBack(page) call.

    If this does not help, please share your code for creating and merging the PDF.