Our print house tell us that Subset fonts in PDF’s are the cause of missing words on the printed page (even though the words are in the file). They advise us to use full embedded fonts instead. The issue is that we don’t create all of the PDF’s we send to be printed. Do you have a code sample (c# ideally) that shows how to replace a Subset font with a Full embedded font in a PDF file? I understand that this is the reverse of what most people are trying to do and it will make the file size bigger - but it’s worth it for a reliable printing experience.
Thanks for contacting support.
This seems a new feature requirement however - you can please try using following code snippet and share your feedback with us if it fulfills your requirements. In case it does not, please share your sample PDF document with us so that we can further proceed to address the scenario accordingly.
Document doc = new Document(dataDir + "A.pdf");
foreach (Page page in doc.Pages)
{
if (page.Resources.Fonts != null)
{
foreach (Aspose.Pdf.Text.Font pageFont in page.Resources.Fonts)
{
if (pageFont.FontName.Replace(" ", "").ToLower().StartsWith("arial"))
{
if (pageFont.IsSubset)
{
pageFont.IsEmbedded = true;
pageFont.FontOptions.NotifyAboutFontEmbeddingError = true;
}
}
}
}
}
doc.Save(dataDir + "A_embedded.pdf");
Note: The fonts you want to embed in the PDF, should be present/installed over the system where you are using the API.
Hi Asad, I did try this suggestion but it didn’t have the desired effect. To properly identify the before and after situation I used the pdffonts tool Download Xpdf and XpdfReader
First of all on the input file:
> c:\WIP\Fonts>\tools\bin64\pdffonts.exe -loc pdf/input.pdf
> Config Error: No display font for 'Symbol'
> Config Error: No display font for 'ZapfDingbats'
> name type emb sub uni prob object ID location
> ---------------------------------------------- ----------------- --- --- --- ---- --------- --------
> Arial,Bold CID TrueType yes no yes 5 0 embedded
> Arial,Bold TrueType no no no 12 0 external: C:\WINDOWS\Fonts\arialbd.ttf
> ABCDEE+Calibri TrueType yes yes no 14 0 embedded
> TJUIPW+Arial CID TrueType yes yes yes 48 0 embedded
I then used your code (minus the startswith(‘arial’) part to produce an output.pdf
Running the pdffonts tool across the output file:
> c:\WIP\Fonts>\tools\bin64\pdffonts.exe -loc pdf/output.pdf > Config Error: No display font for 'Symbol' > Config Error: No display font for 'ZapfDingbats' > name type emb sub uni prob object ID location > ---------------------------------------------- ----------------- --- --- --- ---- --------- -------- > Arial,Bold CID TrueType yes no yes 5 0 embedded > Arial,Bold TrueType no no no 12 0 external: C:\WINDOWS\Fonts\arialbd.ttf > Calibri TrueType no no no 14 0 external: C:\WINDOWS\Fonts\calibri.ttf > Arial CID TrueType no no yes 48 0 external: C:\WINDOWS\Fonts\arial.ttf > QMWDKJ+Arial CID TrueType yes yes yes 63 0 embedded > > c:\WIP\Fonts>
Obviously the desire is for the full font to be embedded (rather than a subset font embedded).
What we’ve achieved is Calibri is no longer subsetted but it’s no longer embedded either
The last Arial subset font seems unaffected.
Is there another way to achieve what we want? Is there a way to rationalize the fonts so that we only have one copy of Arial, Bold and one copy of Arial for example?
Thanks for providing these details.
Would you kindly share a sample PDF document with us. We will log an investigation ticket in our issue tracking system and share the ID with you.
An investigation ticket as PDFNET-47802 has been logged in our issue tracking system. We will further look into your requirements and let you know as soon as the ticket is resolved. Please spare us some time.
We are sorry for the inconvenience.
Hi - is there a way for me to see which system fonts Aspose ‘sees’? - I didn’t get an error saying it couldn’t find a font - but how can I know for sure?
Regretfully there is no such method in the .NET API to determine the target font directory. However, it does offer several methods to work with installed fonts.