Fonts embedding while creating PDF

Skip to end of metadata
Go to start of metadata
If you need to use any font other than the 14 core fonts supported by Adobe Reader, than you must embed the font description while generating Pdf file. If font information is not embedded, Adobe Reader will take it from the Operating System if it’s installed over the system, or it will construct a substitute font according to the font descriptor in the Pdf.
Contents Summary

Fonts embedding Solution

We use the property IsFontEmbedded to embed the font information into Pdf file. Setting the value of this property to ‘True’ will embed the complete font file into the Pdf, knowing the fact that it will increase the Pdf file size. Following is the code snippet that can be used to embed the font information into Pdf.

<?xml version="1.0" encoding="utf-8" ?>
  <Pdf xmlns="Aspose.Pdf">
            <Segment FontName="Almonte Snow" IsFontEmbedded = "true"> This is a sample text using Custom font</Segment> 

There is another way to embed the font information into the Pdf file by using IsUnicode property. The font subset will be embedded. That means not the complete font file is embedded, but the subset that is used in the PDF is embedded. The file size of the PDF may be smaller than that of complete embedding of font file using IsFontEmbedded .
In the upper specified code simply change one line and use the rest of code as it is.

We can also set the property value pdf1.TextInfo.IsFontEmbedded = true; instead of calling SetUnicode() As a result it will embed the whole font description into resultant Pdf and it may increase the size of Pdf.

Each font has a set of supported characters. Sometimes, users may assign a font to a Segment paragraph which doesn't support every character appear in the Segment. Since the release of Aspose.Pdf 4.0.0 a new feature has been introduced to assign proper font to segments according to its contents. For this sake a property named [IsAutoFontAdjusted] has been added to Pdf class. If its value is set to true, a proper font to segments is assigned automatically.

Font Embedding when using Text String containing HTML Tags

We often need to display the HTML contents in Pdf in the same HTML format. Therefore we use Text.IsHtmlTagSupported property to accomplish this requirement. While using In-line formatting we may use custom fonts and in order to embed the custom font into resultant Pdf we need to use I sUnicode=true.

Fig: Output generated when HTML font is rendered into PDF and font is embedded.

‘Almonte Snow’ is the custom font installed over the system.
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.