GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / UnembedFont Method
The font index. It must be a value from 1 to GetFontCount.
Example





In This Topic
UnembedFont Method (GdPicturePDF)
In This Topic
Tries to remove the embedded font program data of font, used in the currently loaded PDF document, according to the font index you have specified, if the font is embedded. You can use the GetFontCount method to determine the number of all used fonts in the PDF document. The font index is simply an integer value from 1 to GetFontCount.

Font embedding means that a full copy of the entire character set of a font is stored in the PDF. A font program can be embedded in a PDF file as data contained in a PDF stream object (also called a font file). Embedded fonts ensure that all of the font information needed to correctly visualize the document are always present. Removing this information might lead to decrease of the document quality and in rare cases to loss of information.

Certain types of fonts like font subsets or fonts with custom character mapping can not be unembedded using this method.

Syntax
'Declaration
 
Public Function UnembedFont( _
   ByVal FontIdx As Integer _
) As GdPictureStatus
public GdPictureStatus UnembedFont( 
   int FontIdx
)
public function UnembedFont( 
    FontIdx: Integer
): GdPictureStatus; 
public function UnembedFont( 
   FontIdx : int
) : GdPictureStatus;
public: GdPictureStatus UnembedFont( 
   int FontIdx
) 
public:
GdPictureStatus UnembedFont( 
   int FontIdx
) 

Parameters

FontIdx
The font index. It must be a value from 1 to GetFontCount.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK. If the method was unable to unembedd the font because of the font properties, then the return value is GdPictreStatus.Aborted.
Remarks
This method is only allowed for use with non-encrypted documents.
Example
How to unembed all fonts from the PDF document
Using pdf = New GdPicturePDF()
   pdf.LoadFromFile("input.pdf")
   Dim fontCount = pdf.GetFontCount()
   For i = 1 To fontCount
       Dim status = pdf.UnembedFont(i)
       If status = GdPictureStatus.Aborted Then
           'unable to remove embedded font data
       ElseIf status <> GdPictureStatus.OK Then
           'unexpected error
       End If
   Next
End Using
using(GdPicturePDF pdf = new GdPicturePDF())
{
    pdf.LoadFromFile("input.pdf");
    int fontCount = pdf.GetFontCount();
    for(int i = 1; i <= fontCount; i++)
    {
        GdPictureStatus status = pdf.UnembedFont(i);
        if (status == GdPictureStatus.Aborted)
        {
            //unable to remove embedded font data
        }
        else if(status != GdPictureStatus.OK)
        {
            //unexpected error
        }
    }
    pdf.SaveToFile("output.pdf");
}
See Also