/** * Gets a PdfReader associated with the document object belongs to. * * @return PdfReader. */ protected PdfReader getReader() { if (getDocument() != null) return getDocument().getReader(); return null; }
/** * Gets a PdfWriter associated with the document object belongs to. * * @return PdfWriter. */ protected PdfWriter getWriter() { if (getDocument() != null) return getDocument().getWriter(); return null; }
IndirectRefDescription(PdfIndirectReference reference) { this.docId = reference.getDocument().getDocumentId(); this.objNr = reference.getObjNumber(); this.genNr = reference.getGenNumber(); }
protected PdfDocument getDocument() { return getPdfObject().getIndirectReference().getDocument(); }
protected PdfDocument getDocument() { return getPdfObject().getIndirectReference().getDocument(); }
protected PdfDocument getDocument() { return getPdfObject().getIndirectReference().getDocument(); } }
protected PdfDocument getDocument() { return getPdfObject().getIndirectReference().getDocument(); }
public PdfDocument getDocument() { return getPdfObject().getIndirectReference().getDocument(); }
protected PdfDocument getDocument() { return getPdfObject().getIndirectReference().getDocument(); }
protected PdfDocument getDocument() { return getPdfObject().getIndirectReference().getDocument(); }
private static PdfDocument getDocEnsureIndirect(PdfStructElem structElem) { PdfIndirectReference indRef = structElem.getPdfObject().getIndirectReference(); if (indRef == null) { throw new PdfException(PdfException.StructureElementDictionaryShallBeAnIndirectObjectInOrderToHaveChildren); } return indRef.getDocument(); } }
/** * Updates this object with the values from a dictionary. * * @param extGState the dictionary containing source parameters */ public void updateFromExtGState(PdfDictionary extGState) { updateFromExtGState(new PdfExtGState(extGState), extGState.getIndirectReference() == null ? null : extGState.getIndirectReference().getDocument()); }
/** * 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 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 PdfStructTreeRoot(PdfDictionary pdfObject, PdfDocument document) { super(pdfObject); this.document = document; if (this.document == null) { ensureObjectIsAddedToDocument(pdfObject); this.document = pdfObject.getIndirectReference().getDocument(); } setForbidRelease(); parentTreeHandler = new ParentTreeHandler(this); getRoleMap(); // TODO may be remove? }
protected PdfDocument getDocument() { PdfDictionary structDict = getPdfObject(); PdfIndirectReference indRef = structDict.getIndirectReference(); if (indRef == null && structDict.getAsDictionary(PdfName.P) != null) { // If parent is direct - it's definitely an invalid structure tree. // MustBeIndirect state won't be met during reading, and all newly created struct elements shall have ind ref. indRef = structDict.getAsDictionary(PdfName.P).getIndirectReference(); } return indRef != null ? indRef.getDocument() : null; }
/** * Helper method for making an object indirect, if the object already is indirect. * Useful for FontDescriptor and FontFile to make possible immediate flushing. * If there is no PdfDocument, mark the object as {@code MUST_BE_INDIRECT}. * * @param obj an object to make indirect. * @return if current object isn't indirect, returns {@code false}, otherwise {@code tree} */ boolean makeObjectIndirect(PdfObject obj) { if (getPdfObject().getIndirectReference() != null) { obj.makeIndirect(getPdfObject().getIndirectReference().getDocument()); return true; } else { markObjectAsIndirect(obj); return false; } }
private void defineWidgetPageAndAddToIt(PdfPage currentPage, PdfDictionary mergedFieldAndWidget, boolean warnIfPageFlushed) { PdfAnnotation annot = PdfAnnotation.makeAnnotation(mergedFieldAndWidget); PdfDictionary pageDic = annot.getPageObject(); if (pageDic != null) { if (warnIfPageFlushed && pageDic.isFlushed()) { throw new PdfException(PdfException.PageAlreadyFlushedUseAddFieldAppearanceToPageMethodBeforePageFlushing); } PdfDocument doc = pageDic.getIndirectReference().getDocument(); PdfPage widgetPage = doc.getPage(pageDic); addWidgetAnnotationToPage(widgetPage, annot); } else { addWidgetAnnotationToPage(currentPage, annot); } }
private void defineWidgetPageAndAddToIt(PdfPage currentPage, PdfDictionary mergedFieldAndWidget, boolean warnIfPageFlushed) { PdfAnnotation annot = PdfAnnotation.makeAnnotation(mergedFieldAndWidget); PdfDictionary pageDic = annot.getPageObject(); if (pageDic != null) { if (warnIfPageFlushed && pageDic.isFlushed()) { throw new PdfException(PdfException.PageAlreadyFlushedUseAddFieldAppearanceToPageMethodBeforePageFlushing); } PdfDocument doc = pageDic.getIndirectReference().getDocument(); PdfPage widgetPage = doc.getPage(pageDic); addWidgetAnnotationToPage(widgetPage, annot); } else { addWidgetAnnotationToPage(currentPage, annot); } }
/** * This constructor is for reusing ByteArrayOutputStreams of indexStream and outputStream. * NOTE Only for internal use in PdfWriter! * @param prev previous PdfObjectStream. */ PdfObjectStream(PdfObjectStream prev) { this(prev.getIndirectReference().getDocument(), prev.getOutputStream().getOutputStream()); indexStream = new PdfOutputStream(prev.indexStream.getOutputStream()); ((ByteArrayOutputStream)outputStream.getOutputStream()).reset(); ((ByteArrayOutputStream)indexStream.getOutputStream()).reset(); prev.releaseContent(true); }