/** * Marks object to be saved as indirect. * * @param document a document the indirect reference will belong to. * @return object itself. */ public PdfObject makeIndirect(PdfDocument document) { return makeIndirect(document, null); }
@Override public PdfObject makeIndirect(PdfDocument document, PdfIndirectReference reference) { if (!directOnly) { return super.makeIndirect(document, reference); } else { Logger logger = LoggerFactory.getLogger(PdfObject.class); logger.warn(LogMessageConstant.DIRECTONLY_OBJECT_CANNOT_BE_INDIRECT); } return this; }
/** * Marks object behind wrapper to be saved as indirect. * * @param document a document the indirect reference will belong to. * @return object itself. */ public PdfObjectWrapper<T> makeIndirect(PdfDocument document, PdfIndirectReference reference) { getPdfObject().makeIndirect(document, reference); return this; }
private void flushMustBeIndirectObject(PdfObject obj) { // TODO DEVSIX-744 obj.makeIndirect(getDocument()).flush(); }
/** * Creates an in-memory copy of a {@link PdfFormField}. This new field is * not added to the document. * * @param name the name of the {@link PdfFormField form field} to be copied * @return a clone of the original {@link PdfFormField} */ public PdfFormField copyField(String name) { PdfFormField oldField = getField(name); if (oldField != null) { PdfFormField field = new PdfFormField((PdfDictionary) oldField.getPdfObject().clone().makeIndirect(document)); return field; } return null; }
/** * Creates an in-memory copy of a {@link PdfFormField}. This new field is * not added to the document. * * @param name the name of the {@link PdfFormField form field} to be copied * @return a clone of the original {@link PdfFormField} */ public PdfFormField copyField(String name) { PdfFormField oldField = getField(name); if (oldField != null) { PdfFormField field = new PdfFormField((PdfDictionary) oldField.getPdfObject().clone().makeIndirect(document)); return field; } return null; }
void addNewIndirectObject(PdfObject object) { object.makeIndirect(document); ++n; int idx = size(); idxToRef.put(idx, object.getIndirectReference().getObjNumber()); refToIdx.put(object.getIndirectReference().getObjNumber(), idx); objects.add(object); LoggerHelper.info("New indirect object was successfully created. Its object number is: " + object.getIndirectReference().getObjNumber(), getClass()); } }
/** * 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; } }
copiedObjectKey = new PdfDocument.IndirectRefDescription(indirectReference); PdfIndirectReference indRef = newObject.makeIndirect(documentTo).getIndirectReference(); if (serializedContent != null) { smartModeSerializer.saveSerializedObject(serializedContent, indRef);
private void checkAndResolveCircularReferences(PdfObject pdfObject) { // Consider the situation when an XObject references the resources of the first page. // We add this XObject to the first page, there is no need to resolve any circular references // and then we flush this object and try to add it to the second page. // Now there are circular references and we cannot resolve them because the object is flushed // and we cannot get resources. // On the other hand, this situation may occur any time when object is already flushed and we // try to add it to resources and it seems difficult to overcome this without keeping /Resources key value. if (pdfObject instanceof PdfDictionary && !pdfObject.isFlushed()) { PdfDictionary pdfXObject = (PdfDictionary) pdfObject; PdfObject pdfXObjectResources = pdfXObject.get(PdfName.Resources); if (pdfXObjectResources != null && pdfXObjectResources.getIndirectReference() != null) { if (pdfXObjectResources.getIndirectReference().equals(getPdfObject().getIndirectReference())) { PdfObject cloneResources = getPdfObject().clone(); cloneResources.makeIndirect(getPdfObject().getIndirectReference().getDocument()); pdfXObject.put(PdfName.Resources, cloneResources.getIndirectReference()); } } } }
public PdfOutputStream write(PdfObject pdfObject) { if (pdfObject.checkState(PdfObject.MUST_BE_INDIRECT) && document != null) { pdfObject.makeIndirect(document); pdfObject = pdfObject.getIndirectReference();
crypto.makeIndirect(this); forbiddenToFlush.add(crypto.getIndirectReference());