In the application I’m writing there are sometimes PDF that has the XMP already set and when converting to PDF/A-1a the validation will not go though because the data in the XMP metadata is not correct
<Compliance Name="Log"
Operation="Validation"
Target="PDF/A-1A">
<Version>1.0</Version>
<Copyright>Copyright (c) 2001-2023 Aspose Pty Ltd. All Rights Reserved.</Copyright>
<Date>2023-06-20 15:46:44</Date>
<File Version="1,7"
Name=""
Pages="3">
<Security/>
<Catalog/>
<Header/>
<Fonts/>
<trailer/>
<Metadata>
<Problem Severity="Error"
Clause="6.7.11"
Convertable="True">Required property 'pdfaid:part' for schema 'pdfaid' missing</Problem>
<Problem Severity="Error"
Clause="6.7.11"
Convertable="True">Required property 'pdfaid:conformance' for schema 'pdfaid' missing</Problem>
</Metadata>
<objects/>
<xObjects/>
<actions/>
</File>
</Compliance>
byte[] pdfaData;
try (ByteArrayInputStream bais = new ByteArrayInputStream(data);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ByteArrayOutputStream log = new ByteArrayOutputStream()) {
Document pdfDocument = new Document(bais);
pdfDocument.removeMetadata();
pdfDocument.convert(log, PdfFormat.PDF_A_1A, ConvertErrorAction.Delete);
pdfDocument.save(baos);
pdfaData = baos.toByteArray();
} catch (Exception e) {
System.out.println("Unable to convert " + e);
return;
}
Should Aspose convert the XMP part as well or should I remove the XMP data before converting?
Have tried to remove XMP with the removeMetaData() metod on the Document class but that didn’t work and I haven’t found any example where complete removal is done.