/** * Gets a list of marked content references on page. */ public Map<Integer, PdfMcr> getPageMarkedContentReferences(PdfPage page) { return pageToPageMcrs.get(page.getPdfObject().getIndirectReference()); }
/** * Gets a name specifying the tab order that shall be used for annotations on the page. * The possible values are {@link PdfName#R} (row order), {@link PdfName#C} (column order), and {@link PdfName#S} (structure order). * Beginning with PDF 2.0, the possible values also include {@link PdfName#A} (annotations array order) and {@link PdfName#W} (widget order). * See ISO 32000 12.5, "Annotations" for details. * * @return a {@link PdfName} specifying the annotations tab order or null if tab order is not defined. */ public PdfName getTabOrder() { return getPdfObject().getAsName(PdfName.Tabs); }
/** * Gets the XMP Metadata object. * * @return {@link PdfStream} object, that represent XMP Metadata. */ public PdfStream getXmpMetadata() { return getPdfObject().getAsStream(PdfName.Metadata); }
/** * Gets the key of the page’s entry in the structural parent tree. * * @return the key of the page’s entry in the structural parent tree. * If page has no entry in the structural parent tree, returned value is -1. */ public int getStructParentIndex() { return getPdfObject().getAsNumber(PdfName.StructParents) != null ? getPdfObject().getAsNumber(PdfName.StructParents).intValue() : -1; }
/** * Gets the {@link PdfDocument} that owns that page, or {@code null} if such document isn't exist. * * @return {@link PdfDocument} that owns that page, or {@code null} if such document isn't exist. */ public PdfDocument getDocument() { if (getPdfObject().getIndirectReference() != null) return getPdfObject().getIndirectReference().getDocument(); return null; }
private void loadPagesFromReader(PdfDocument doc, List<PdfDictionary> pages, List<PdfIndirectReference> pagesRef) { int numOfPages = doc.getNumberOfPages(); for (int i = 0; i < numOfPages; ++i) { pages.add(doc.getPage(i + 1).getPdfObject()); pagesRef.add(pages.get(i).getIndirectReference()); } }
/** * Sets a stream object that shall define the page’s thumbnail image. Thumbnail images represent the contents of * its pages in miniature form * * @return the thumbnail image, or <code>null</code> if it is not present */ public PdfImageXObject getThumbnailImage() { PdfStream thumbStream = getPdfObject().getAsStream(PdfName.Thumb); return thumbStream != null ? new PdfImageXObject(thumbStream) : null; }
/** * Gets the {@link Rectangle} object specified by page's BleedBox, that define the region to which the * contents of the page shall be clipped when output in a production environment. * * @return the {@link Rectangle} object specified by page's BleedBox, expressed in default user space units. * CropBox by default. */ public Rectangle getBleedBox() { Rectangle bleedBox = getPdfObject().getAsRectangle(PdfName.BleedBox); return bleedBox == null ? getCropBox() : bleedBox; }
/** * Gets the {@link Rectangle} object specified by page's TrimBox object, * that define the intended dimensions of the finished page after trimming. * * @return the {@link Rectangle} object specified by page's TrimBox, expressed in default user space units. * CropBox by default. */ public Rectangle getTrimBox() { Rectangle trimBox = getPdfObject().getAsRectangle(PdfName.TrimBox); return trimBox == null ? getCropBox() : trimBox; }
/** * Helper method that associate specified value with specified key in the underlined {@link PdfDictionary}. * May be used in chain. * * @param key the {@link PdfName} key with which the specified value is to be associated. * @param value the {@link PdfObject} value to be associated with the specified key. * @return this {@link PdfPage} object. */ public PdfPage put(PdfName key, PdfObject value) { getPdfObject().put(key, value); setModified(); return this; }
/** * Gets the {@link Rectangle} object specified by page's ArtBox, that define the extent of the page’s * meaningful content (including potential white space) as intended by the page’s creator. * * @return the {@link Rectangle} object specified by page's ArtBox, expressed in default user space units. * CropBox by default. */ public Rectangle getArtBox() { Rectangle artBox = getPdfObject().getAsRectangle(PdfName.ArtBox); return artBox == null ? getCropBox() : artBox; }
private PdfArray getAnnots(boolean create) { PdfArray annots = getPdfObject().getAsArray(PdfName.Annots); if (annots == null && create) { annots = new PdfArray(); put(PdfName.Annots, annots); } return annots; }
protected PdfPage(PdfDocument pdfDocument, PageSize pageSize) { this((PdfDictionary) new PdfDictionary().makeIndirect(pdfDocument)); PdfStream contentStream = (PdfStream) new PdfStream().makeIndirect(pdfDocument); getPdfObject().put(PdfName.Contents, contentStream); getPdfObject().put(PdfName.Type, PdfName.Page); getPdfObject().put(PdfName.MediaBox, new PdfArray(pageSize)); getPdfObject().put(PdfName.TrimBox, new PdfArray(pageSize)); if (pdfDocument.isTagged()) { setTabOrder(PdfName.S); } }
public boolean addPage(int index, PdfPage pdfPage) { if (index < from || index > from + getCount()) return false; kids.add(index - from, pdfPage.getPdfObject()); pdfPage.getPdfObject().put(PdfName.Parent, getPdfObject()); incrementCount(); setModified(); return true; }
/** * This method gets outlines of a current page * * @return return all outlines of a current page */ public List<PdfOutline> getOutlines(boolean updateOutlines) { getDocument().getOutlines(updateOutlines); return getDocument().getCatalog().getPagesWithOutlines().get(getPdfObject()); }
private int getExplicitDestinationPageNum(PdfArray explicitDest) { PdfIndirectReference pageReference = (PdfIndirectReference) explicitDest.get(0, false); PdfDocument doc = pageReference.getDocument(); for (int i = 1; i <= doc.getNumberOfPages(); ++i) { if (doc.getPage(i).getPdfObject().getIndirectReference().equals(pageReference)) return i; } throw new IllegalArgumentException("PdfLinkAnnotation comparison: Page not found."); }
public PdfStructElem(PdfDocument document, PdfName role, PdfAnnotation annot) { this(document, role); if (annot.getPage() == null) throw new PdfException(PdfException.AnnotationShallHaveReferenceToPage); getPdfObject().put(PdfName.Pg, annot.getPage().getPdfObject()); }
private int getOrCreatePageStructParentIndex(PdfPage page) { int structParentIndex = page.getStructParentIndex(); if (structParentIndex < 0) { structParentIndex = page.getDocument().getNextStructParentIndex(); page.getPdfObject().put(PdfName.StructParents, new PdfNumber(structParentIndex)); } return structParentIndex; } }
public PdfMcrDictionary(PdfPage page, PdfStructElem parent) { super(new PdfDictionary(), parent); PdfDictionary dict = (PdfDictionary) getPdfObject(); dict.put(PdfName.Type, PdfName.MCR); dict.put(PdfName.Pg, page.getPdfObject()); dict.put(PdfName.MCID, new PdfNumber(page.getNextMcid())); }
private void checkPage(PdfPage page) { PdfDictionary pageDict = page.getPdfObject(); if (isAlreadyChecked(pageDict)) return; checkPageObject(pageDict, page.getResources().getPdfObject()); PdfDictionary pageResources = page.getResources().getPdfObject(); checkResources(pageResources); checkAnnotations(pageDict); checkPageSize(pageDict); int contentStreamCount = page.getContentStreamCount(); for (int j = 0; j < contentStreamCount; ++j) { checkedObjects.add(page.getContentStream(j)); } }