public override void Load(PDFObjects pdf, PdfObject pdfObject) { var dic = pdf.GetObject <DictionaryObject>(pdfObject); if (dic.Dictionary.ContainsKey("Parent")) { parent = pdf.GetDocument <DocumentPageTree>(dic.Dictionary["Parent"]); } var dicKids = pdf.GetObject <ArrayObject>(dic.Dictionary["Kids"]); foreach (var kid in dicKids.Childs <IndirectReferenceObject>()) { if (pdf.GetType(kid) == "Pages") { pageTreeSons.Add(pdf.GetDocument <DocumentPageTree>(kid)); } else { pageSons.Add(pdf.GetDocument <DocumentPage>(kid)); } } if (dic.Dictionary.ContainsKey("MediaBox")) { var mediaBox = pdf.GetObject <ArrayObject>(dic.Dictionary["MediaBox"]); MediaBox = new Rectangle( pdf.GetObject <RealObject>(mediaBox.childs[0]).Value, pdf.GetObject <RealObject>(mediaBox.childs[1]).Value, pdf.GetObject <RealObject>(mediaBox.childs[2]).Value, pdf.GetObject <RealObject>(mediaBox.childs[3]).Value); } }
public override void Load(PDFObjects pdf, PdfObject pdfObject) { System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); var dictionary = pdf.GetObject <DictionaryObject>(pdfObject); pageTree = pdf.GetDocument <DocumentPageTree>(dictionary.Dictionary["Pages"]); if (dictionary.Dictionary.ContainsKey("Outlines")) { outlines = pdf.GetDocument <DocumentOutlines>(dictionary.Dictionary["Outlines"]); } }
public override void Load(PDFObjects pdf, PdfObject pdfObject) { var dic = pdf.GetObject <DictionaryObject>(pdfObject); if (dic.Dictionary.ContainsKey("Parent")) { parent = pdf.GetDocument <DocumentPageTree>(dic.Dictionary["Parent"]); } if (dic.Dictionary.ContainsKey("MediaBox")) { var mediaBox = pdf.GetObject <ArrayObject>(dic.Dictionary["MediaBox"]); MediaBox = new Rectangle( pdf.GetObject <RealObject>(mediaBox.childs[0]).Value, pdf.GetObject <RealObject>(mediaBox.childs[1]).Value, pdf.GetObject <RealObject>(mediaBox.childs[2]).Value, pdf.GetObject <RealObject>(mediaBox.childs[3]).Value); } if (dic.Dictionary.ContainsKey("Resources")) { var resources = pdf.GetObject <DictionaryObject>(dic.Dictionary["Resources"]); foreach (var resource in resources.Dictionary) { switch (resource.Key) { case "Font": foreach (var font in pdf.GetObject <DictionaryObject>(resource.Value).Dictionary) { var documentFont = FontFactory.GetFont(pdf, font.Value); fonts.Add(documentFont, font.Key); reverseFonts.Add(font.Key, documentFont); } break; case "XObject": foreach (var image in pdf.GetObject <DictionaryObject>(resource.Value).Dictionary) { var documentImage = ImageFactory.GetImage(pdf, image.Value); images.Add(documentImage, image.Key); reverseImages.Add(image.Key, documentImage); } break; case "ProcSet": //14.2 Procedure Sets var arrayobject = pdf.GetObject <ArrayObject>(resource.Value); foreach (var item in arrayobject.Childs <NameObject>()) { procsets.Add(item.Value); } break; default: // TODO throw new PdfException(PdfExceptionCodes.INVALID_RESOURCE, $"Not supported resource found {resource.Key}"); } } } contents = pdf.GetDocument <DocumentText>(dic.Dictionary["Contents"]); }
public DocumentPage(DocumentPageTree parent) { this.parent = parent; this.contents = new DocumentText(); }
public DocumentCatalog() { System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); this.pageTree = new DocumentPageTree(); this.outlines = new DocumentOutlines(); }