Method RemoveUnusedFontGlyphs
- Namespace
- BitMiracle.Docotic.Pdf
- Assembly
- BitMiracle.Docotic.Pdf.dll
RemoveUnusedFontGlyphs()
Tries to remove unused glyphs from all fonts in the document.
public PdfCollection<PdfFont> RemoveUnusedFontGlyphs()
Returns
- PdfCollection<PdfFont>
The collection of fonts, where unused glyphs were successfully removed.
Remarks
This method might fail to remove unused glyphs in the following cases:
-
Font is not embedded. For such fonts the Embedded
property is
false
. - Font is used in a PdfTextBox or PdfComboBox and therefore all font glyphs should be preserved. A PDF reader or editor might be unable to change text in a control if some glyphs are missed in the font.
- Font is of an unsupported type. For now, only TrueType/OpenType (not CFF) fonts are supported.
This method is useful for decreasing size of produced PDF documents. It performs one of the supported lossy transformations. The method creates a font subsets with used glyphs only and embeds subsets in the current document.
A glyph is treated as used if the current document contains character drawn with the glyph.
This method does not remove unused glyphs from Type1 fonts.
Exceptions
- UnsupportedFontException
One of the fonts has unexpected structure. Please send us a PDF file for review. As a workaround, you can process individual fonts using RemoveUnusedGlyphs() method.
RemoveUnusedFontGlyphs(IEnumerable<PdfFont>)
Tries to remove unused glyphs from the specified fonts in the document.
public PdfCollection<PdfFont> RemoveUnusedFontGlyphs(IEnumerable<PdfFont> fonts)
Parameters
fonts
IEnumerable<PdfFont>The collection of fonts to process. All fonts must belong to this document.
Returns
- PdfCollection<PdfFont>
The collection of fonts, where unused glyphs were successfully removed.
Remarks
This method might fail to remove unused glyphs in the following cases:
-
Font is not embedded. For such fonts the Embedded
property is
false
. - Font is used in a PdfTextBox or PdfComboBox and therefore all font glyphs should be preserved. A PDF reader or editor might be unable to change text in a control if some glyphs are missed in the font.
- Font is of an unsupported type. For now, only TrueType/OpenType (not CFF) fonts are supported.
This method is useful for decreasing size of produced PDF documents. It performs one of the supported lossy transformations. The method creates a font subsets with used glyphs only and embeds subsets in the current document.
A glyph is treated as used if the current document contains character drawn with the glyph.
This method does not remove unused glyphs from Type1 fonts.
Some PDF documents use a same font descriptor and font bytes in multiple fonts. In such cases, the call of this method for one of the fonts will also remove unused glyphs for all other fonts.
Exceptions
- UnsupportedFontException
One of the fonts has unexpected structure. Please send us a PDF file for review. As a workaround, you can process individual fonts using RemoveUnusedGlyphs() method.