FileFormats - Pdf.Net.Core how to check and EmbedFonts?

Hello, 

the title is quite self-explanatory. 

Anyway, we are migrating from net framework 4.8 to net8.0.

We used to have something like :

                    var fonts = documentLoad.UsedFonts;
                    if (documentLoad.IsAllFontsEmbedded == false)
                    {
                        foreach (PdfUsedFont font in fonts)
                        {
                            if (font.Type != PdfFontType.TrueTypeEmbedded)
                            {
                                documentLoad.EmbedFonts();
                            }
                        }
                    }


Is there anything we can do to achieve the same on Net.Core?

Thanks in advance


5 Replies

JT Jeyalakshmi Thangamarippandian Syncfusion Team March 19, 2024 02:42 PM UTC

Hi, 

In our PDF library, the UsedFonts API is only supported in the base platform and it is not supported in the .Net Core platform. So we could not use this approach to embed the non-embedded fonts. However we can use our PDF to PDF/A conversion support, in this support, the non-embedded fonts are embedded. You can refer the following UG documentation for further details.

Working with PDF conformance in .NET PDF Library | Syncfusion

Regards,

Jeyalakshmi T




SU Stefano Ursoleo - Unicode Srl replied to Jeyalakshmi Thangamarippandian March 19, 2024 03:27 PM UTC

Thanks for your suggestion JT, it sounds like a good solution. I'll let you know shortly 

Kind Regards,

Stefano



JT Jeyalakshmi Thangamarippandian Syncfusion Team March 20, 2024 07:32 AM UTC

Thank you for the update. Please get back to us if you need any other assistance.



SU Stefano Ursoleo - Unicode Srl replied to Jeyalakshmi Thangamarippandian March 21, 2024 01:20 PM UTC

Hello JT, 

with some further testing, we still have issues with converting PDF, even into PDF\A format. 

We can only use PDF A3A because of healthcare standards. 

Our code in net core:


public void PdfToPdfA()
{
    byte[] pdf = System.IO.File.ReadAllBytes("PDF.pdf");
 
    using (MemoryStream ms_pdf = new MemoryStream(pdf))
    {
        MemoryStream ms_pdfa3a = new MemoryStream();
        using (Syncfusion.Pdf.Parsing.PdfLoadedDocument documentLoad = new Syncfusion.Pdf.Parsing.PdfLoadedDocument(pdf))
        {


            using (Syncfusion.Pdf.PdfDocument documentSave = new Syncfusion.Pdf.PdfDocument(Syncfusion.Pdf.PdfConformanceLevel.Pdf_A3A))
            {
                int startIndex = 0;
                int endIndex = documentLoad.Pages.Count - 1;
 
                documentSave.ImportPageRange(documentLoad, startIndex, endIndex);
 
                documentSave.Save(ms_pdfa3a);
                ms_pdfa3a.Position = 0;
                documentSave.Close(true);
            }
 
            documentLoad.Close();
        }
 
        byte[] pdfa3a = ms_pdfa3a.ToArray();
        System.IO.File.WriteAllBytes("PDFA3A.pdf", pdfa3a);
    }
}


I'm attaching PDF original file and the converted one as well. 

Once again, thanks in advance

Regards,

Stefano




Attachment: PDFFiles_2d23c2b4.zip


JT Jeyalakshmi Thangamarippandian Syncfusion Team March 22, 2024 01:43 PM UTC

As of now, we don't have the support to convert the PDF document to PDF/A3A conformance. Upon further analyze with your code, we found that you are using import page option to create new document. In this approach the font will not be embedded, because of it only import the exiting content without any update. So we request you to convert your PDF document to PDF/A1B conformance to get all fonts are embedded. You can refer to the UG documentation for more details.

Working with PDF conformance in .NET PDF Library | Syncfusion



Loader.
Up arrow icon