Hello,
We are using Aspose PDF in order to generate a PDF/A3 that need to meet Factur-X standards.
There is a validator at this address which allows to check the conformity of the file.
Using the validator mentionned above, we currently have 2 errors:
1 - Wrong value for /EF/F/Subtype
Value for /EF/F/Subtype should be ‘/text#2Fxml’. Current value is ‘/application#2Fpdf’.
2 - Missing entry /EF/F/Type
How can we provide those two values with Aspose ?
Here is a schema from the standard
image.png (89.5 KB)
Here a PDF describing the standard
1. FACTUR-X 1.0.06 2022 03 01 EN VF.pdf (1.6 MB)
And here is a snippet of the code that we use to generate our PDF
public Stream AttachXmlFacturX(Stream pdfStream, Stream xmlStream)
{
var pdfDocument = new Document(pdfStream);
FileSpecification fileSpecification = new FileSpecification(xmlStream, "factur-x.xml", "factur-x xml file");
pdfDocument.EmbeddedFiles.Add("factur-x.xml", fileSpecification);
fileSpecification.Name = "factur-x.xml";
fileSpecification.MIMEType = "text/xml";
fileSpecification.Params = new FileParams(fileSpecification);
fileSpecification.Params.ModDate = DateTime.Now;
fileSpecification.Params.CreationDate = DateTime.Now;
pdfDocument.SetTitle("mon titre");
var extensionSchemaDescription = new XmpPdfAExtensionSchemaDescription("fx", "urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#", "Factur-X PDFA Extension Schema");
var extensionSchema = new XmpPdfAExtensionSchema(extensionSchemaDescription);
var object1 = new XmpPdfAExtensionProperty("DocumentFileName", "factur-x.xml", "Text", XmpPdfAExtensionCategoryType.External, "The name of the embedded XML document");
var object2 = new XmpPdfAExtensionProperty("DocumentType", "INVOICE", "Text", XmpPdfAExtensionCategoryType.External, "The type of the hybrid document blablabalbaa");
var object3 = new XmpPdfAExtensionProperty("Version", "1.0", "Text", XmpPdfAExtensionCategoryType.External, "The actual version of the standard blablabalbaa");
var object4 = new XmpPdfAExtensionProperty("ConformanceLevel", "MINIMUM", "Text", XmpPdfAExtensionCategoryType.External, "The conformance level blablabalbaa");
extensionSchema.Objects.Add(object1);
extensionSchema.Objects.Add(object2);
extensionSchema.Objects.Add(object3);
extensionSchema.Objects.Add(object4);
pdfDocument.Metadata.ExtensionFields.Add("fx", extensionSchema);
pdfDocument.Metadata.RegisterNamespaceUri("fx", "urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#");
pdfDocument.Metadata["fx:DocumentType"] = "INVOICE";
pdfDocument.Metadata["fx:DocumentFileName"] = "factur-x.xml";
pdfDocument.Metadata["fx:Version"] = "1.0";
pdfDocument.Metadata["fx:ConformanceLevel"] = "MINIMUM";
bool convertSuccess = pdfDocument.Convert(new MemoryStream(), PdfFormat.PDF_A_3B, ConvertErrorAction.None);
if (convertSuccess)
{
fileSpecification.SetValue("AFRelationship", "Data");
fileSpecification.IncludeContents = true;
Stream outputStream = new MemoryStream();
pdfDocument.Save(outputStream);
return outputStream;
}
else
{
throw new Exception("Erreur de conversion PDF A3");
}
}
We know that there is the value PdfFormat.ZUGFeRD in the PdfFormat enum for the Convert method but it looks like it does a lot of things that we don’t want (I would say that it is made for older version of the ZUGFeRD standard, prior to 2.1)
I’ve found a very similar question in an other post but unfortunately there is no answer since almost a year.
Thank you