@Override public boolean equals(Object other) { return other instanceof PDPage && ((PDPage) other).getCOSObject() == this.getCOSObject(); }
private SearchContext(PDPage page) { this.searched = page.getCOSObject(); }
/** * Removes the given page from the page tree. * * @param page The page to remove. */ public void remove(PDPage page) { remove(page.getCOSObject()); }
/** * This method checks additional actions contained in the given Page object. * * @param context the preflight context. * @param page the page to check. * @throws ValidationException */ protected void validateActions(PreflightContext context, PDPage page) throws ValidationException { ContextHelper.validateElement(context, page.getCOSObject(), ACTIONS_PROCESS); }
if (pageForWidget != null) if (pagesAnnotationsMap.get(pageForWidget.getCOSObject()) == null) pagesAnnotationsMap.put(pageForWidget.getCOSObject(), widgetsForPage); Map<COSDictionary,PDAnnotationWidget> widgetsForPage = pagesAnnotationsMap.get(pageForWidget.getCOSObject()); widgetsForPage.put(widget.getCOSObject(), widget);
COSDictionary nextPageDict = nextPage.getCOSObject(); COSDictionary parentDict = (COSDictionary) nextPageDict.getDictionaryObject(COSName.PARENT); COSArray kids = (COSArray) parentDict.getDictionaryObject(COSName.KIDS); if (pageDict.equals(nextPage.getCOSObject())) kids.add(i, newPage.getCOSObject()); newPage.getCOSObject().setItem(COSName.PARENT, parentDict); found = true; break;
COSDictionary prevPageDict = prevPage.getCOSObject(); COSDictionary parentDict = (COSDictionary) prevPageDict.getDictionaryObject(COSName.PARENT); COSArray kids = (COSArray) parentDict.getDictionaryObject(COSName.KIDS); if (pageDict.equals(prevPage.getCOSObject())) kids.add(i + 1, newPage.getCOSObject()); newPage.getCOSObject().setItem(COSName.PARENT, parentDict); found = true; break;
public PageEntry getPage(int index) { PDPage page = doc.getPages().get(index); String pageLabel = PDFDebugger.getPageLabel(doc, index); return new PageEntry(page.getCOSObject(), index + 1, pageLabel); }
/** * Check that all XObject references in the PDResource of the page and in the Thumb entry are confirming to the * PDF/A specification. * * @param context the preflight context. * @param page the page to check. * @throws ValidationException */ protected void validateGraphicObjects(PreflightContext context, PDPage page) throws ValidationException { COSBase thumbBase = page.getCOSObject().getItem(PAGE_DICTIONARY_VALUE_THUMB); if (thumbBase != null) { try { if (thumbBase instanceof COSObject) { thumbBase = ((COSObject) thumbBase).getObject(); } PDXObject thumbImg = PDImageXObject.createThumbnail((COSStream)thumbBase); ContextHelper.validateElement(context, thumbImg, GRAPHIC_PROCESS); } catch (IOException e) { LOGGER.debug("Unable to read Thumb image", e); context.addValidationError(new ValidationError(ERROR_GRAPHIC_INVALID, "Unable to read Thumb image : " + e.getMessage())); } } }
private Map<Integer,LayoutPage> getLayoutPages(PDDocument doc) throws IOException { int numberOfPages = doc.getNumberOfPages(); Map<Integer,LayoutPage> layoutPages = new HashMap<>(numberOfPages); for (int i=0;i<numberOfPages;i++) { PDPage page = doc.getPage(i); COSBase contents = page.getCOSObject().getDictionaryObject(COSName.CONTENTS); PDResources resources = page.getResources(); if (resources == null) { resources = new PDResources(); } layoutPages.put(i, new LayoutPage(page.getMediaBox(), createCombinedContentStream(contents), resources.getCOSObject())); } return layoutPages; }
/** * Check that the group dictionary doesn't have a Transparency attribute * * @param context the preflight context. * @param page the page to check. * @throws ValidationException */ protected void validateGroupTransparency(PreflightContext context, PDPage page) throws ValidationException { COSBase baseGroup = page.getCOSObject().getItem(XOBJECT_DICTIONARY_KEY_GROUP); COSDictionary groupDictionary = COSUtils.getAsDictionary(baseGroup, context.getDocument().getDocument()); if (groupDictionary != null) { String sVal = groupDictionary.getNameAsString(COSName.S); if (XOBJECT_DICTIONARY_VALUE_S_TRANSPARENCY.equals(sVal)) { context.addValidationError(new ValidationError(ERROR_GRAPHIC_TRANSPARENCY_GROUP, "Group has a transparency S entry or the S entry is null")); } } }
@Override public void injectProcSetArray(PDFormXObject innerForm, PDPage page, PDResources innerFormResources, PDResources imageFormResources, PDResources holderFormResources, COSArray procSet) { innerForm.getResources().getCOSObject().setItem(COSName.PROC_SET, procSet); page.getCOSObject().setItem(COSName.PROC_SET, procSet); innerFormResources.getCOSObject().setItem(COSName.PROC_SET, procSet); imageFormResources.getCOSObject().setItem(COSName.PROC_SET, procSet); holderFormResources.getCOSObject().setItem(COSName.PROC_SET, procSet); LOG.info("Inserted ProcSet to PDF"); }
COSDictionary pageDictionary = page.getCOSObject(); COSBase contents = pageDictionary.getDictionaryObject(COSName.CONTENTS); if (contents instanceof COSStream)
private LayoutPage getLayoutPage(PDDocument doc) throws IOException { PDPage page = doc.getPage(0); COSBase contents = page.getCOSObject().getDictionaryObject(COSName.CONTENTS); PDResources resources = page.getResources(); if (resources == null) { resources = new PDResources(); } return new LayoutPage(page.getMediaBox(), createCombinedContentStream(contents), resources.getCOSObject()); }
/** * Adds the given page to this page tree. * * @param page The page to add. */ public void add(PDPage page) { // set parent COSDictionary node = page.getCOSObject(); node.setItem(COSName.PARENT, root); // todo: re-balance tree? (or at least group new pages into tree nodes of e.g. 20) // add to parent's kids COSArray kids = (COSArray)root.getDictionaryObject(COSName.KIDS); kids.add(node); // update ancestor counts do { node = (COSDictionary) node.getDictionaryObject(COSName.PARENT, COSName.P); if (node != null) { node.setInt(COSName.COUNT, node.getInt(COSName.COUNT) + 1); } } while (node != null); }
PDPage importedPage = new PDPage(new COSDictionary(page.getCOSObject()), resourceCache); PDStream dest = new PDStream(this, page.getContents(), COSName.FLATE_DECODE); importedPage.setContents(dest); importedPage.setMediaBox(page.getMediaBox()); importedPage.setRotation(page.getRotation()); if (page.getResources() != null && !page.getCOSObject().containsKey(COSName.RESOURCES))
COSDictionary pageDictionary = page.getCOSObject(); COSBase originalContent = pageDictionary.getDictionaryObject(COSName.CONTENTS); COSArray newContentArray = new COSArray();
((COSArray) page.getCOSObject().getItem(COSName.CONTENTS)).remove(0);
COSArray contents = (COSArray) page.getCOSObject().getItem(COSName.CONTENTS); contents.remove(0);
(COSDictionary) cloner.cloneForNewDocument(page.getCOSObject())); newPage.setCropBox(page.getCropBox()); newPage.setMediaBox(page.getMediaBox());