using latest Aspose for .Net (24.2) c# .Net 8.0:
in my code I read a PDF doc, remove some embedded fonts, change the default font and save the PDF.
the code is:
Document doc = new Document(path, loadOptions);
foreach (Page page in doc.Pages)
{
if (page.Resources.Fonts != null)
{
foreach (Font pageFont in page.Resources.Fonts)
{
if (pageFont.IsEmbedded)
{
pageFont.IsEmbedded = false;
}
}
}
foreach (XForm form in page.Resources.Forms)
{
if (form?.Resources?.Fonts != null)
{
foreach (Font formFont in form.Resources.Fonts)
{
if (formFont.IsEmbedded)
{
formFont.IsEmbedded = false;
}
}
}
}
}
SaveOptions so = new PdfSaveOptions()
{
DefaultFontName = “Arial”,
};
doc.Save(destinationPath, so);
however, when I try to open the PDf I receive an error from Acrobat Reader saying:
Cannot find or create the font ‘TimesNewRoman’
and some characters are garbled in the doc.
when I analyzed the resulting doc in:
the original PDF has the following fonts:
image.png (8.4 KB)
the resulting PDf has:
image.png (8.6 KB)
so, instead of using Ariel to replace the embedded ArielNarrow, the doc is still using TimesNewRoman.
here is the document I was processing:
FICC Strategy US Auction Preview 2024.06.24.zip (89.7 KB)
[internal ref NCP-4313]