iTextSharp.text.pdf.PdfDictionary.GetAsName C# (CSharp) Method

GetAsName() public method

public GetAsName ( PdfName key ) : PdfName
key PdfName
return PdfName
        public PdfName GetAsName(PdfName key)
        {
            PdfName name = null;
            PdfObject orig = GetDirectObject(key);
            if (orig != null && orig.IsName())
                name = (PdfName) orig;
            return name;
        }

Usage Example

示例#1
1
 /**
 * Processes a dictionary.
 * In case of font dictionaries, the dictionary is processed.
 */
 public void UnembedTTF(PdfDictionary dict)
 {
     // we ignore all dictionaries that aren't font dictionaries
     if (!dict.IsFont())
         return;
     // we only remove TTF fonts
     if (dict.GetAsDict(PdfName.FONTFILE2) != null)
     {
         return;
     }
     // check if a subset was used (in which case we remove the prefix)
     PdfName baseFont = dict.GetAsName(PdfName.BASEFONT);
     if (baseFont.GetBytes()[7] == '+')
     {
         baseFont = new PdfName(baseFont.ToString().Substring(8));
         dict.Put(PdfName.BASEFONT, baseFont);
     }
     // we check if there's a font descriptor
     PdfDictionary fontDescriptor = dict.GetAsDict(PdfName.FONTDESCRIPTOR);
     if (fontDescriptor == null)
         return;
     // is there is, we replace the fontname and remove the font file
     fontDescriptor.Put(PdfName.FONTNAME, baseFont);
     fontDescriptor.Remove(PdfName.FONTFILE2);
 }
All Usage Examples Of iTextSharp.text.pdf.PdfDictionary::GetAsName