internal static DocumentFont GetFont(PDFObjects pdf, PdfObject pdfObject) { var dic = pdf.GetObject <DictionaryObject>(pdfObject); var name = pdf.GetObject <NameObject>(dic.Dictionary["BaseFont"]).Value; lock (lck) { if (m_lstFont.ContainsKey(name)) { return(m_lstFont[name]); } if (IsBaseFont(pdf, dic)) { var font = new DocumentBaseFont(name); m_lstFont.Add(name, font); return(font); } else if (IsSubsetFont(dic)) { var font = pdf.GetDocument <DocumentTtfSubsetFont>(pdfObject); m_lstFont.Add(name, font); return(font); } else if (IsTrueTypeFont(pdf, dic)) { var font = pdf.GetDocument <DocumentTtfFont>(pdfObject); m_lstFont.Add(name, font); return(font); } } throw new PdfException(PdfExceptionCodes.INVALID_FONT, $"Not supported font type"); }
public static DocumentImage GetImage(PDFObjects pdf, PdfObject pdfObject) { var dic = pdf.GetObject <DictionaryObject>(pdfObject); if (dic.Dictionary.ContainsKey("Filter") && pdf.GetObject <NameObject>(dic.Dictionary["Filter"]).Value == "DCTDecode") { return(GetImageInternal(dic.Stream)); } int width = pdf.GetObject <IntegerObject>(dic.Dictionary["Width"]).IntValue; int height = pdf.GetObject <IntegerObject>(dic.Dictionary["Height"]).IntValue; int bitsPerComponents = pdf.GetObject <IntegerObject>(dic.Dictionary["BitsPerComponent"]).IntValue; string colorSpace = pdf.GetObject <NameObject>(dic.Dictionary["ColorSpace"]).Value; return(GetRawImage(dic.Stream, width, height, bitsPerComponents, Enum.Parse <DeviceColorSpace>(colorSpace))); }
private static bool IsBaseFont(PDFObjects pdf, DictionaryObject dic) => dic.Dictionary.ContainsKey("BaseFont") && dic.Dictionary.ContainsKey("Subtype") && pdf.GetObject <NameObject>(dic.Dictionary["Subtype"]).Value == "Type1";