Free Support Forum - aspose.com

Converting to PDF-A 1a failing

Hi, I’m currently evaluating your product Aspose.PDF in combination with Aspose.Words for merging Word- & PDF-files to a single PDF-A file. Unfortunately there’s some difficulties with the conversion (according to the log file).<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I started off with a new Document and “merged” pdf-files by adding them to its page collection which caused convert problems. If I ignore the problem (success-boolean) and save the file to disk it opens correctly as a PDF-A document. To minimize the problems I stopped adding any pages to see what happened, the following code still causes validation problems:

var mergedPdf = new Aspose.Pdf.Document();

var success = mergedPdf.Validate(logFilePath, PdfFormat.PDF_A_1A); success = mergedPdf.Convert(logFilePath, PdfFormat.PDF_A_1A, ConvertErrorAction.Delete);

The logFilePath-result:

<Catalog>

<objects>

<Problem Severity="Error" Clause="6.1.7" ObjectID="9" Convertable="True">The stream dictionary contains 'N' key</Problem>

</objects>

<xObjects />

<actions />

<Header />

<Annotations />

<Metadata>

<Problem Severity="Error" Clause="6.7.2" Convertable="True">Metadata key does not exists</Problem>

</Metadata>

<Fonts />

<trailer>

<Problem Severity="Error" Clause="6.1.3" Convertable="True">The trailer dictionary does not contain 'ID'</Problem>

</trailer>

</Catalog>

Through the help of http://www.callassoftware.com/callas/doku.php/en:products:pdfapilot:pdfatestsuiteallresults we tracked down the solution to the two last errors, it is a mismatch for CreationDate.

To solve those we applied the following code:

var pdfGenerator = new Aspose.Pdf.Generator.Pdf();

pdfGenerator.Conformance = PdfConformance.PdfA1A;

pdfGenerator.XmpMetadata = new Aspose.Pdf.Generator.XmpMetadata();

pdfGenerator.XmpMetadata.AddCreationDate(DateTime.Now.ToString());

pdfGenerator.Save(mergedPdfStream);

var mergedPdf = new Aspose.Pdf.Document(mergedPdfStream);

mergedPdf.Pages.Delete();

var success = mergedPdf.Validate(logFilePath, PdfFormat.PDF_A_1A); success = mergedPdf.Convert(logFilePath, PdfFormat.PDF_A_1A, ConvertErrorAction.Delete);

We still receive a problem with “The stream dictionary contains 'N' key” though which I haven’t been able to track down what it actually means:

<Compliance Name="Log" Operation="Validation" Target="PDF/A-1a">

<Version>1.0</Version>

<copyright>Copyright 2011 Aspose ltd</copyright>

<Date>2011-10-03 16:19:58</Date>

<file Version="1,4" Name="test.pdf" Pages="0">

<Issues>

<Catalog>

<objects>

<Problem Severity="Error" Clause="6.1.7" ObjectID="21" Convertable="True">The stream dictionary contains 'N' key</Problem>

</objects>

<xObjects />

<actions />

<Header />

<Annotations />

<Metadata />

<Fonts />

<trailer />

</Catalog>

</Issues>

</file>

</Compliance>

Should we just ignore this error or have we done anything wrong in our coding? Also when specifying PdfFormat.PDF_A_1B (less strict) the error log still says Target="PDF/A-1a" .

Sincerely

Magnus


This message was posted using Page2Forum from Convert PDF File to PDF-A 1a and PDF-A 1b Compliant PDF - Aspose.Pdf for .NET

Hi Magnus,

Thanks for using our products. We are working over this query and will get back to you soon. We are sorry for the delay and inconvenience.

I managed to avoid the other error with the following code:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

var pdfGenerator = new Aspose.Pdf.Generator.Pdf();

//pdfGenerator.Conformance = PdfConformance.PdfA1A;

var dateTimeNow = new DateTimeOffset(DateTime.Now);

var dateTimeString = dateTimeNow.ToString("s") + "+" + dateTimeNow.Offset.ToString().Substring(0, 5);

pdfGenerator.XmpMetadata = new Aspose.Pdf.Generator.XmpMetadata();

pdfGenerator.XmpMetadata.AddUserProperty(@"xmlns:xmp=""http://ns.adobe.com/xap/1.0/""", "xmp:CreationDate", dateTimeString);

pdfGenerator.XmpMetadata.AddUserProperty(@"xmlns:pdfaid=""http://www.aiim.org/pdfa/ns/id/""", "pdfaid:part", "1");

pdfGenerator.XmpMetadata.AddUserProperty(@"xmlns:pdfaid=""http://www.aiim.org/pdfa/ns/id/""", "pdfaid:conformance", "A");

//pdfGenerator.XmpMetadata.AddUserProperty(@"xmlns:xapMM=""http://ns.adobe.com/xap/1.0/mm/ """, "xapMM:DocumentID", String.Concat("xmp.did:", Guid.NewGuid().ToString("D")));

//pdfGenerator.XmpMetadata.AddUserProperty(@"xmlns:xapMM=""http://ns.adobe.com/xap/1.0/mm/ """, "xapMM:InstanceID", String.Concat("xmp.did:", Guid.NewGuid().ToString("D")));

pdfGenerator.Save(mergedPdfStream);

var mergedPdf = new Aspose.Pdf.Document(mergedPdfStream);

mergedPdf.Info.CreationDate = dateTimeNow.DateTime;

But instead I get this error:
<trailer>

<Problem Severity="Error" Clause="6.1.3" Convertable="True">The trailer dictionary does not contain 'ID'</Problem>

</trailer>


I’ve looked at both the generated files with a hex editor and see that it does not contain any ID in the trailer information, so it seems I only bypassed the other error to instead receive this error. Using http://www.validatepdfa.com/ I can also verify that both files causes the following errors:

<fileStructure>

<problem severity="error" clause="6.1.3" standard="pdfa">Missing ID in trailer dictionary</problem>

</fileStructure>

<metadata>

<problem severity="error" objectID="198" clause="p32" standard="xmp">Missing or invalid header of XMP packet wrapper</problem>

<problem severity="warning" objectID="198" clause="p33" standard="xmp">Recommended padding is not found in the XMP packet trailer</problem>

<problem severity="error" objectID="198" clause="6.7.9" standard="pdfa">XML structure of metadata corrupt</problem>

</metadata>

Reading from http://labs.appligent.com/presentations/recognizing_malformed_pdf_f.pdf in the section about Trailer I see how a pdf trailer should look, it seems as if Aspose.PDF does not generate valid PDFs?

This seems related to <A href="