private List<PDMetadata> getMetadata() { if (this.catalog != null) { org.verapdf.pd.PDMetadata meta = this.catalog.getMetadata(); if (meta != null) { List<PDMetadata> metadata = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); metadata.add(new GFPDMetadata(meta, Boolean.TRUE)); return Collections.unmodifiableList(metadata); } } return Collections.emptyList(); }
public PDOutlineDictionary getOutlines() { return getCatalog().getOutlines(); }
public PDStructTreeRoot getStructTreeRoot() { return getCatalog().getStructTreeRoot(); }
private void getCatalogFeatures(PDCatalog catalog) throws IOException { reporter.report(GFFeaturesObjectCreator.createMetadataFeaturesObject(catalog.getMetadata())); PDOutlineDictionary outlines = catalog.getOutlines(); reporter.report(GFFeaturesObjectCreator.createOutlinesFeaturesObject(outlines)); PDNamesDictionary namesDictionary = catalog.getNamesDictionary(); reportOutlinesActions(outlines.getFirst()); reportAction(catalog.getOpenAction(), ActionFeaturesObjectAdapter.Location.DOCUMENT); PDCatalogAdditionalActions additionalActions = catalog.getAdditionalActions(); if (additionalActions != null) { reportAction(additionalActions.getDP(), ActionFeaturesObjectAdapter.Location.DOCUMENT); PDAcroForm acroForm = catalog.getAcroForm(); if (acroForm != null) { getAcroFormFeatures(acroForm); if (catalog.getOutputIntents() != null) { for (PDOutputIntent outInt : catalog.getOutputIntents()) { String iccProfileID = addICCProfileFromOutputIntent(outInt); if (!config.isFeatureEnabled(FeatureObjectType.ICCPROFILE)) { PDPageTree pageTree = catalog.getPageTree(); if (pageTree != null) { getPageTreeFeatures(pageTree, catalog.getPageLabels());
private List<CosLang> getLang() { if (this.catalog != null) { COSObject baseLang = catalog.getKey(ASAtom.LANG); if (baseLang != null && baseLang.getType() == COSObjType.COS_STRING) { List<CosLang> list = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); list.add(new GFCosLang((COSString) baseLang.getDirectBase())); return Collections.unmodifiableList(list); } } return Collections.emptyList(); }
private MetadataImpl parseMetadata() { PDCatalog catalog = this.document.getCatalog(); PDMetadata meta = catalog.getMetadata(); if (meta == null) { COSObject stream = COSStream.construct(); catalog.setKey(ASAtom.METADATA, stream); this.document.getDocument().addObject(stream); VeraPDFMeta xmp = VeraPDFMeta.create(); return new MetadataImpl(xmp, stream, this.document.getDocument(), true); } return parseMetadata(meta, this.document); }
/** * {@inheritDoc} Implemented by GreenField library. */ @Override public MetadataFixerResult saveDocumentIncremental(final MetadataFixerResultImpl.RepairStatus status, OutputStream output) { MetadataFixerResultImpl.Builder builder = new MetadataFixerResultImpl.Builder(); try { PDMetadata meta = this.document.getCatalog().getMetadata(); boolean isMetaPresent = meta != null && this.isNeedToBeUpdated(); boolean isMetaAdd = meta == null && this.metadata != null; if (isMetaPresent || isMetaAdd) { this.metadata.updateMetadataStream(); if (isMetaAdd) { this.document.getDocument().addChangedObject( this.document.getCatalog().getObject()); } this.document.saveTo(output); output.close(); builder.status(getStatus(status)); } else { builder.status(status); } } catch (Exception e) { LOGGER.log(Level.FINE, e.getMessage(), e); builder.status(FIX_ERROR).addFix("Problems with document save. " + e.getMessage()); } return builder.build(); }
public static void registerFileSpecificationKeys(COSDocument document) { PDDocument pdDocument = document.getPDDocument(); if (pdDocument == null) { return; } PDCatalog catalog = pdDocument.getCatalog(); if (catalog != null) { registerDictionaryAFKeys(catalog.getObject()); processStructElements(catalog.getStructTreeRoot()); } List<PDPage> pages = pdDocument.getPages(); for (PDPage page : pages) { processPage(page); } visitedKeys.clear(); }
public void addPage(final PDPage page, final int number) { if (document == null) { return; } final PDPageTree pages = this.getCatalog().getPageTree(); page.getObject().setKey(ASAtom.PARENT, pages.getObject()); if (pages.addPage(page, number)) { getCatalog().setKey(ASAtom.PAGES, pages.getRoot().getObject()); } //TODO : check this final COSObject obj = pages.getObject(); document.setObject(obj); }
PDCatalog catalog = pdDocument.getCatalog(); if (catalog != null) { ASAtom nameKey = catalog.getNameKey(ASAtom.VERSION); this.catalogVersion = nameKey == null ? null : nameKey.getValue(); this.isTagged = catalog.getStructTreeRoot() != null;
public List<PDPage> getPages() { final List<PDPage> pages = new ArrayList<>(); final int pageCount = this.getCatalog().getPageTree().getPageCount(); for (int i = 0; i < pageCount; i++) { pages.add(this.getPage(i)); } return pages; }
private List<PDAction> getOpenAction() { List<PDAction> actions = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); org.verapdf.pd.actions.PDAction action = this.catalog.getOpenAction(); if (action != null) { actions.add(GFPDAction.getAction(action)); } return Collections.unmodifiableList(actions); }
public List<PDOutputIntent> getOutputIntents() { return getCatalog().getOutputIntents(); }
public PDAcroForm getAcroForm() { return getCatalog().getAcroForm(); }
private List<PDAction> getActions() { if (this.catalog != null) { PDCatalogAdditionalActions additionalActions = this.catalog.getAdditionalActions(); if (additionalActions != null) { List<PDAction> actions = new ArrayList<>(MAX_NUMBER_OF_ACTIONS); org.verapdf.pd.actions.PDAction raw; raw = additionalActions.getDP(); this.addAction(actions, raw); raw = additionalActions.getDS(); this.addAction(actions, raw); raw = additionalActions.getWP(); this.addAction(actions, raw); raw = additionalActions.getWS(); this.addAction(actions, raw); raw = additionalActions.getWC(); this.addAction(actions, raw); return Collections.unmodifiableList(actions); } } return Collections.emptyList(); }
@Override public Boolean getcontainsAlternatePresentations() { if (this.catalog != null) { COSObject rawCatalog = this.catalog.getObject(); if (rawCatalog != null && rawCatalog.getType().isDictionaryBased()) { COSObject namesDictionary = rawCatalog.getKey(ASAtom.NAMES); if (namesDictionary != null && namesDictionary.getType().isDictionaryBased()) { COSObject alternatePresentations = namesDictionary.getKey(ASAtom.getASAtom("AlternatePresentations")); if (alternatePresentations != null && !alternatePresentations.empty() && alternatePresentations.getType() != COSObjType.COS_NULL) { return Boolean.TRUE; } } } } return Boolean.FALSE; }
private List<PDPerms> getPerms() { if(this.catalog != null) { COSObject perms = this.catalog.getKey(ASAtom.PERMS); if (perms != null && perms.getType().isDictionaryBased()) { List<PDPerms> list = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); list.add(new GFPDPerms(perms)); return Collections.unmodifiableList(list); } } return Collections.emptyList(); }
public PDPage getPage(final int number) { return this.getCatalog().getPageTree().getPage(number); }
public PDMetadata getMetadata() { return getCatalog().getMetadata(); }