I checked this ticket and I can see that the PDFNET-42700 status is closed !
Is it corrected ? Or what does mean the Closed,status ? I had no news on this ticket.
Thanks for writing us.
We are pleased to inform you that earlier logged issue has been resolved. However, followings are the findings and feedback from our product team regarding the issue, which you were facing.
Input document “01.pdf” has a fonts (i.e “Berlin Sans FB”, “LucidaHandwriting-Italic”) which can be absent on destination computer, and this font absence produces an error
"Font is not embedded". This error has a reason cause PDF/A standard requires that all fonts must be embedded into document. Usually it’s not a problem to embed font, but if font is absent then we have a question - what data to embed instead of absent font?
A special option to use font substitution was added into Aspose.Pdf to resolve cases with absent fonts.
This option was included into new class
Aspose.Pdf.PdfAOptionClasses.FontEmbeddingOptions - property
UseDefaultSubstitution. When this flag is set and some font is absent then Aspose.Pdf will substitute this font using internal default substitution algorithm.
Code snippet to convert input document:
Document doc = new Document(dataDir + "01.pdf"); PdfFormatConversionOptions ops = new PdfFormatConversionOptions(PdfFormat.PDF_A_1B, ConvertErrorAction.Delete); ops.FontEmbeddingOptions.UseDefaultSubstitution = true; doc.Convert(ops); doc.Save(dataDir + "01_PDFA.pdf");
Usage of flag
UseDefaultSubstitution substitute all the absent fonts automatically. It can be helpful when you do not know what font must be used to substitute absent font. But also it has a risk to damage document representation, cause there can be cases when new font is not fully compatible with source font. So you can use this flag
UseDefaultSubstitution on your own risk.
If you know what font can be used to substitute absent one, you can use another font substitution mechanism - in this case its possible to declare new font directly. Its accomplished with using of property
Substitutions of class
Aspose.Pdf.Text.FontRepository. Use this property to add substitution for desired font.
Next code snippet converts input document and declares to substitute font “LucidaHandwriting-Italic” with a font “Arial”, if source font “LucidaHandwriting-Italic” will be absent:
Document doc = new Document(dataDir + "01.pdf"); PdfFormatConversionOptions ops = new PdfFormatConversionOptions(PdfFormat.PDF_A_1B, ConvertErrorAction.Delete); FontRepository.Substitutions.Add(new SimpleFontSubstitution("LucidaHandwriting-Italic", "Arial")); doc.Convert(ops); doc.Save(dataDir + "01_PDFA.pdf");
In case of any further assistance, please feel free to contact us.
I’ve a question regarding your answer.
in fact, regading the code snippet, you mention PDFA_1B in order to substitute the missing font.
But in my case, the conversion to PDFA_1B works properly. The issue is on the same input document transformed to PDFA_2B format.
Is there any difference between PDFA_1B and PDFA_2B regarding the fact that a font is missing in the input ?
Thanks for writing back.
We have also tested the shared approaches while converting PDF document into PDFA_2B format and resultant document has compliance with PDF/A standard and look OK. Please check attached PDFA_1B document and a compliance test report of Adobe Preflight.
In case if you are still facing issue while converting PDF into PDFA_2B, please let us know, so that we can test and log the issue accordingly.