public boolean isFlushed() { return pdfObject.isFlushed(); }
/** * Copies object content from object 'from'. * * @param from object to copy content from. * @param document document to copy object to. */ protected void copyContent(PdfObject from, PdfDocument document) { if (isFlushed()) throw new PdfException(PdfException.CannotCopyFlushedObject, this); }
private void addKidObjectToStructElemList(PdfObject k, List<IStructureNode> list) { if (k.isFlushed()) { list.add(null); return; } list.add(convertPdfObjectToIPdfStructElem(k)); }
private void ifKidIsStructElementAddToList(PdfObject kid, List<IStructureNode> kids) { if (kid.isFlushed()) { kids.add(null); } else if (kid.isDictionary() && PdfStructElem.isStructElem((PdfDictionary) kid)) { kids.add(new PdfStructElem((PdfDictionary) kid)); } } }
private void getAllFieldNames(PdfArray fields, Set<String> existingFields) { for (PdfObject field : fields) { if (field.isFlushed()) { continue; } PdfDictionary dic = (PdfDictionary) field; PdfString name = dic.getAsString(PdfName.T); if (name != null) { existingFields.add(name.toUnicodeString()); } PdfArray kids = dic.getAsArray(PdfName.Kids); if (kids != null) { getAllFieldNames(kids, existingFields); } } } }
private void getAllFieldNames(PdfArray fields, Set<String> existingFields) { for (PdfObject field : fields) { if (field.isFlushed()) { continue; } PdfDictionary dic = (PdfDictionary) field; PdfString name = dic.getAsString(PdfName.T); if (name != null) { existingFields.add(name.toUnicodeString()); } PdfArray kids = dic.getAsArray(PdfName.Kids); if (kids != null) { getAllFieldNames(kids, existingFields); } } } }
private void flushWithResources(PdfDictionary objsCollection) { if (objsCollection == null) { return; } for (PdfObject obj : objsCollection.values()) { if (obj.isFlushed()) continue; flushResourcesContentStreams(((PdfDictionary) obj).getAsDictionary(PdfName.Resources)); flushMustBeIndirectObject(obj); } }
if (ap != null && !ap.isFlushed()) { PdfObject normal = ap.get(PdfName.N); if (normal != null && !normal.isFlushed()) { if (normal.isDictionary()) { for (PdfName key : ((PdfDictionary) normal).keySet()) {
if (ap != null && !ap.isFlushed()) { PdfObject normal = ap.get(PdfName.N); if (normal != null && !normal.isFlushed()) { if (normal.isDictionary()) { for (PdfName key : ((PdfDictionary) normal).keySet()) {
private Map<String, PdfFormField> iterateFields(PdfArray array, Map<String, PdfFormField> fields) { int index = 1; for (PdfObject field : array) { if (field.isFlushed()) { Logger logger = LoggerFactory.getLogger(PdfAcroForm.class); logger.warn(LogMessageConstant.FORM_FIELD_WAS_FLUSHED);
private Map<String, PdfFormField> iterateFields(PdfArray array, Map<String, PdfFormField> fields) { int index = 1; for (PdfObject field : array) { if (field.isFlushed()) { Logger logger = LoggerFactory.getLogger(PdfAcroForm.class); logger.warn(LogMessageConstant.FORM_FIELD_WAS_FLUSHED);
if (isFlushed() || getIndirectReference() == null || getIndirectReference().isFree()) {
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()); } } } }