Code with Finding: |
class PdfCopyFieldsImp { void propagate(PdfObject obj, PdfIndirectReference refo, boolean restricted) throws IOException { if (obj == null) return; // if (refo != null) // addToBody(obj, refo); if (obj instanceof PdfIndirectReference) return; switch (obj.type()) { case PdfObject.DICTIONARY: case PdfObject.STREAM: { PdfDictionary dic = (PdfDictionary)obj; for (PdfName key: dic.getKeys()) { if (restricted && (key.equals(PdfName.PARENT) || key.equals(PdfName.KIDS))) continue; PdfObject ob = dic.get(key); if (ob != null && ob.isIndirect()) { PRIndirectReference ind = (PRIndirectReference)ob; if (!setVisited(ind) && !isPage(ind)) { PdfIndirectReference ref = getNewReference(ind); propagate(PdfReader.getPdfObjectRelease(ind), ref, restricted); } } else propagate(ob, null, restricted); } break; } case PdfObject.ARRAY: { //PdfArray arr = new PdfArray(); for (Iterator<PdfObject> it = ((PdfArray)obj).listIterator(); it.hasNext();) { PdfObject ob = it.next(); if (ob != null && ob.isIndirect()) { PRIndirectReference ind = (PRIndirectReference)ob; if (!isVisited(ind) && !isPage(ind)) { PdfIndirectReference ref = getNewReference(ind); propagate(PdfReader.getPdfObjectRelease(ind), ref, restricted); } } else propagate(ob, null, restricted); } break; } case PdfObject.INDIRECT: { throw new RuntimeException(MessageLocalization.getComposedMessage("reference.pointing.to.reference")); } } }
}
|