/** * trailer dictionary */ private List<CosTrailer> getTrailer() { List<CosTrailer> list = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); list.add(new GFCosTrailer((COSDictionary) cosDocument.getTrailer().getObject().getDirectBase())); return Collections.unmodifiableList(list); }
private static COSObject getInformationDictionary(COSDocument document) { final COSObject info = document.getTrailer().getInfo(); if (info != null && info.getType() == COSObjType.COS_DICT) { return info; } return null; }
private COSDictionary getCatalog() { COSBase catalogLocal = cosDocument.getTrailer().getRoot().getDirectBase(); if (catalogLocal != null && catalogLocal.getType() == COSObjType.COS_DICT) { return (COSDictionary) catalogLocal; } return null; }
public void writeIncrementalUpdate(List<COSObject> changedObjects, List<COSObject> addedObjects) { List<COSKey> objectsToWrite = new ArrayList<>(); for (COSObject obj : changedObjects) { COSKey key = obj.getObjectKey(); if (key != null) { objectsToWrite.add(obj.getObjectKey()); } } changedObjects.clear(); objectsToWrite.addAll(prepareAddedObjects(addedObjects)); this.addToWrite(objectsToWrite); this.writeBody(); COSTrailer trailer = document.getTrailer(); // document.getLastTrailerOffset() + 1 point EXACTLY at first byte of xref this.setTrailer(trailer, document.getLastTrailerOffset() + 1); this.writeXRefInfo(); this.clear(); }
private InfoDictionaryImpl getInfo() { COSTrailer trailer = this.document.getDocument().getTrailer(); COSObject infoDict = trailer.getInfo(); return (infoDict != null && infoDict.getType() == COSObjType.COS_DICT) ? new InfoDictionaryImpl(infoDict, this.document.getDocument()) : null; }
public PDCatalog getCatalog() { if (!catalog.empty() || document == null) { return catalog; } COSObject root = document.getTrailer().getRoot(); if (root == COSObject.getEmpty()) { root = new COSObject(); document.getTrailer().setRoot(root); } if (!root.empty()) { catalog.setObject(root); return catalog; } root.setNameKey(ASAtom.TYPE, ASAtom.CATALOG); COSObject pages = new COSObject(); pages.setNameKey(ASAtom.TYPE, ASAtom.PAGES); pages.setArrayKey(ASAtom.KIDS); pages.setIntegerKey(ASAtom.COUNT, 0); pages = COSIndirect.construct(root, document); root.setKey(ASAtom.PAGES, pages); root = COSIndirect.construct(root, document); document.getTrailer().setRoot(root); catalog.setObject(root); return catalog; }
private void parseDocumentFeatures(PDDocument document) { COSDocument cosDocument = document.getDocument(); COSTrailer trailer = cosDocument.getTrailer(); if (trailer != null) { reporter.report(GFFeaturesObjectCreator.createInfoDictFeaturesObject(trailer.getInfo())); } StandardSecurityHandler standardSecurityHandler = cosDocument.getStandardSecurityHandler(); if (standardSecurityHandler != null) { reporter.report(GFFeaturesObjectCreator.createDocSecurityFeaturesObject(standardSecurityHandler.getPdEncryption())); } try { PDCatalog catalog = document.getCatalog(); if (catalog != null) { getCatalogFeatures(catalog); } } catch (IOException e) { LOGGER.log(Level.SEVERE, "Problem in parsing document catalog", e); } reporter.report(GFFeaturesObjectCreator.createLowLvlInfoFeaturesObject(cosDocument)); }
/** * Constructor using greenfield COSDocument * * @param cosDocument * greenfield COSDocument */ public GFCosDocument(COSDocument cosDocument) { super(cosDocument, COS_DOCUMENT_TYPE); this.catalog = this.getCatalog(); COSHeader cosHeader = cosDocument.getHeader(); this.indirectObjectCount = cosDocument.getObjects().size(); this.version = cosHeader.getVersion(); this.headerOffset = cosHeader.getHeaderOffset(); this.header = cosHeader.getHeader(); this.headerCommentByte1 = cosHeader.getHeaderCommentByte1(); this.headerCommentByte2 = cosHeader.getHeaderCommentByte2(); this.headerCommentByte3 = cosHeader.getHeaderCommentByte3(); this.headerCommentByte4 = cosHeader.getHeaderCommentByte4(); this.isOptionalContentPresent = parseOptionalContentPresent(); this.postEOFDataSize = cosDocument.getPostEOFDataSize(); this.isLinearised = cosDocument.getTrailer() != cosDocument.getLastTrailer() && cosDocument.isLinearized(); this.lastID = getTrailerID(cosDocument.getLastTrailer().getKey(ASAtom.ID)); this.firstPageID = getTrailerID(cosDocument.getFirstTrailer().getKey(ASAtom.ID)); PDFAFlavour.Specification specification = StaticContainers.getFlavour().getPart(); if (specification == PDFAFlavour.Specification.ISO_19005_3 || specification == PDFAFlavour.Specification.ISO_19005_4) { FileSpecificationKeysHelper.registerFileSpecificationKeys(cosDocument); } }