We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Error log when converting pdf to pdfa

Hello,

I am trying to convert pdf to pdfa using the following coding.
The conversion seems fine without any exceptions.
But the two log files Conversion_log_.xml and Validation_log_.xml contain errors. The file name these log files is always test.pdf.
Since the contents in the log files do NOT reflect the real case, does Aspose.pdf hard-code the contents in the log files?

Attached are the input.pdf, output_pdfa_0.pdf, Conversion_log_0.xml and Validation_log_0.xml.

Thanks.


public static void main(String[] args) throws Exception {
static String dir_pdf2pdfa = "C:/temp/pdf/utilities/pdf2pdfa/";
ApplyLicense.setLicense();


/******* Convert PDF to PDFA *******/
pdfTopdfA1bConversion(PdfFormat.PDF_A_1A);
// pdfTopdfA1bConversion(PdfFormat.PDF_A_1B);
// pdfTopdfA1bConversion(PdfFormat.PDF_A_2A);
// pdfTopdfA1bConversion(PdfFormat.PDF_A_2B);
// pdfTopdfA1bConversion(PdfFormat.PDF_A_3A);
// pdfTopdfA1bConversion(PdfFormat.PDF_A_3B)
}

public static void pdfTopdfA1bConversion(int pdfFormat) {
// Open document
Document doc = new Document(dir_pdf2pdfa + "input.pdf");
// Convert to PDF/A compliant document
doc.validate(dir_pdf2pdfa + "Validation_log_" + pdfFormat + ".xml", pdfFormat);
doc.convert(dir_pdf2pdfa + "Conversion_log_" + pdfFormat + ".xml", pdfFormat, ConvertErrorAction.Delete);
// Save updated document
doc.save(dir_pdf2pdfa + "output_pdfa_" + pdfFormat + ".pdf");
}

Hi Jeff,


Thanks for using our API’s.

I have tested the scenario and have managed to reproduce same problem. For the sake of correction, I have logged it as PDFJAVA-36159 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

@jeffguo

Thanks for your patience.

Our product team has completed their investigation against the logged issue PDFJAVA-36159 and as per their findings, this is not a bug. The validation for converted PDFA document should be done after saving process is completed. Because internal streams and objects are completely converted and serialized into the file on the disk during save process. Please use following code snippet, in order to get correct results:

 // Open document
 Document doc = new Document("c:/pdftest/input (1).pdf");

 // Convert to PDF/A compliant document
 doc.convert("c:/pdftest/Conversion_log_" + PdfFormat.PDF_A_1A + ".xml", PdfFormat.PDF_A_1A, ConvertErrorAction.Delete);

 // Save updated document
 doc.save("c:/pdftest/Final_output_pdfa_" + PdfFormat.PDF_A_1A+ ".pdf");

 // Validate saved document
 doc = new Document("c:/pdftest/Final_output_pdfa_" + PdfFormat.PDF_A_1A+ ".pdf");
 doc.validate("c:/pdftest/Validation_log_" + PdfFormat.PDF_A_1A+ ".xml", PdfFormat.PDF_A_1A);
 doc.close();

Please try above code snippet, while using latest version Aspose.Pdf for Java 17.10 and in case you still face any issue, please feel free to let us know.