Hello,
I work as a developer at a company where we are using the Aspose.PDF library. I’m reaching out because we’ve encountered a problem:
Our application operates in the cloud, and we’re restricted to using only one system font, which is Lucida Casual. Since we’re unable to install additional fonts, we’ve decided to use Aspose.Pdf.Text.FontRepository in conjunction with Aspose.Pdf.Text.MemoryFontSource:
byte[] fontData = <Font byte array> // suppose this is Helvetica.ttf
var fontSource = new Aspose.Pdf.Text.MemoryFontSource(fontData);
Aspose.Pdf.Text.FontRepository.Sources.Add(fontSource);
Aspose.Pdf.Text.FontRepository.ReloadFonts();
The first issue is when using the FindFont method.
The code:
Aspose.Pdf.Text.FontRepository.FindFont("Lucida Casual")
correctly returns a Font object for “Lucida Casual.” However, when we try:
Aspose.Pdf.Text.FontRepository.FindFont("Helvetica")
we get the exception “Font Helvetica was not found.”
The second issue presents itself during the conversion of a PDF, that uses Helvetica but doesn’t embed the font, into a PNG file. The resulting image lacks text. For the conversion, we employ the Aspose.Pdf.Devices.PngDevice with these settings:
Aspose.Pdf.Devices.ImageDevice imageDevice = new Aspose.Pdf.Devices.PngDevice(<page size>, <resolution>)
{
TransparentBackground = false,
};
imageDevice.RenderingOptions.UseNewImagingEngine = true;
imageDevice.RenderingOptions.InterpolationHighQuality = true;
imageDevice.RenderingOptions.UseFontHinting = true;
imageDevice.Process(<page>, <output stream>);
My assessment is that fonts loaded into the Aspose.Pdf.Text.FontRepository as Aspose.Pdf.Text.MemoryFontSource aren’t being recognized for font substitution. I may be incorrect and would welcome your perspective. Thank you for considering my request.
Best regards,
Rok