/** * @param pageNum * @return a Dictionary object */ public PdfDictionary getPageNRelease(final int pageNum) { PdfDictionary dic = getPageN(pageNum); pageRefs.releasePage(pageNum); return dic; }
/** * @param pageNum * @return a Dictionary object */ public PdfDictionary getPageNRelease(final int pageNum) { PdfDictionary dic = getPageN(pageNum); pageRefs.releasePage(pageNum); return dic; }
/** * Retrieve the given page's resource dictionary * @param pageNum 1-based page number from which to retrieve the resource dictionary * @return The page's resources, or 'null' if the page has none. * @since 5.1 */ public PdfDictionary getPageResources(final int pageNum) { return getPageResources(getPageN(pageNum)); }
/** * Retrieve the given page's resource dictionary * @param pageNum 1-based page number from which to retrieve the resource dictionary * @return The page's resources, or 'null' if the page has none. * @since 5.1 */ public PdfDictionary getPageResources(final int pageNum) { return getPageResources(getPageN(pageNum)); }
PageStamp getPageStamp(int pageNum) { PdfDictionary pageN = reader.getPageN(pageNum); PageStamp ps = pagesToContent.get(pageN); if (ps == null) { ps = new PageStamp(this, reader, pageN); pagesToContent.put(pageN, ps); } return ps; }
/** * Gets a list of the document fonts in a particular page. Each element of the <CODE>ArrayList</CODE> * contains a <CODE>Object[]{String,PRIndirectReference}</CODE> with the font name * and the indirect reference to it. * @param reader the document where the fonts are to be listed from * @param page the page to list the fonts from * @return the list of fonts and references */ public static ArrayList<Object[]> getDocumentFonts(PdfReader reader, int page) { IntHashtable hits = new IntHashtable(); ArrayList<Object[]> fonts = new ArrayList<Object[]>(); recourseFonts(reader.getPageN(page), hits, fonts, 1, new HashSet<PdfDictionary>()); return fonts; }
/** * Gets a list of the document fonts in a particular page. Each element of the <CODE>ArrayList</CODE> * contains a <CODE>Object[]{String,PRIndirectReference}</CODE> with the font name * and the indirect reference to it. * @param reader the document where the fonts are to be listed from * @param page the page to list the fonts from * @return the list of fonts and references */ public static ArrayList<Object[]> getDocumentFonts(PdfReader reader, int page) { IntHashtable hits = new IntHashtable(); ArrayList<Object[]> fonts = new ArrayList<Object[]>(); recourseFonts(reader.getPageN(page), hits, fonts, 1, new HashSet<PdfDictionary>()); return fonts; }
PageStamp getPageStamp(int pageNum) { PdfDictionary pageN = reader.getPageN(pageNum); PageStamp ps = pagesToContent.get(pageN); if (ps == null) { ps = new PageStamp(this, reader, pageN); pagesToContent.put(pageN, ps); } ps.pageN.setIndRef(reader.getPageOrigRef(pageNum)); return ps; }
/** * Gets a list of all document fonts. Each element of the <CODE>ArrayList</CODE> * contains a <CODE>Object[]{String,PRIndirectReference}</CODE> with the font name * and the indirect reference to it. * @param reader the document where the fonts are to be listed from * @return the list of fonts and references */ public static ArrayList<Object[]> getDocumentFonts(PdfReader reader) { IntHashtable hits = new IntHashtable(); ArrayList<Object[]> fonts = new ArrayList<Object[]>(); int npages = reader.getNumberOfPages(); for (int k = 1; k <= npages; ++k) recourseFonts(reader.getPageN(k), hits, fonts, 1, new HashSet<PdfDictionary>()); return fonts; }
/** * Gets a list of all document fonts. Each element of the <CODE>ArrayList</CODE> * contains a <CODE>Object[]{String,PRIndirectReference}</CODE> with the font name * and the indirect reference to it. * @param reader the document where the fonts are to be listed from * @return the list of fonts and references */ public static ArrayList<Object[]> getDocumentFonts(PdfReader reader) { IntHashtable hits = new IntHashtable(); ArrayList<Object[]> fonts = new ArrayList<Object[]>(); int npages = reader.getNumberOfPages(); for (int k = 1; k <= npages; ++k) recourseFonts(reader.getPageN(k), hits, fonts, 1, new HashSet<PdfDictionary>()); return fonts; }
@Override void addAnnotation(PdfAnnotation annot, int page) { if (annot.isAnnotation()) annot.setPage(page); addAnnotation(annot, reader.getPageN(page)); }
PdfReader reader = new PdfReader(INTERMEDIATE); PdfStamper stamper = new PdfStamper(reader, FINAL_RESULT); PdfReaderContentParser parser = new PdfReaderContentParser(reader); TextMarginFinder finder = parser.processContent(1, new TextMarginFinder()); PdfDictionary page = reader.getPageN(1); page.put(PdfName.CROPBOX, new PdfArray(new float[]{pageSize.getLeft(), finder.getLly(), pageSize.getRight(), pageSize.getTop()})); stamper.markUsed(page); stamper.close(); reader.close();
@Override void addAnnotation(PdfAnnotation annot, int page) { if (annot.isAnnotation()) annot.setPage(page); addAnnotation(annot, reader.getPageN(page)); }
/** * Sets the display duration for the page (for presentations) * * @param seconds the number of seconds to display the page. A negative value removes the entry * @param page the page where the duration will be applied. The first page is 1 */ void setDuration(int seconds, int page) { PdfDictionary pg = reader.getPageN(page); if (seconds < 0) pg.remove(PdfName.DUR); else pg.put(PdfName.DUR, new PdfNumber(seconds)); markUsed(pg); }
/** * Sets the transition for the page * * @param transition the transition object. A <code>null</code> removes the transition * @param page the page where the transition will be applied. The first page is 1 */ void setTransition(PdfTransition transition, int page) { PdfDictionary pg = reader.getPageN(page); if (transition == null) pg.remove(PdfName.TRANS); else pg.put(PdfName.TRANS, transition.getTransitionDictionary()); markUsed(pg); }
/** * Sets the display duration for the page (for presentations) * * @param seconds the number of seconds to display the page. A negative value removes the entry * @param page the page where the duration will be applied. The first page is 1 */ void setDuration(int seconds, int page) { PdfDictionary pg = reader.getPageN(page); if (seconds < 0) pg.remove(PdfName.DUR); else pg.put(PdfName.DUR, new PdfNumber(seconds)); markUsed(pg); }
/** * Sets the transition for the page * * @param transition the transition object. A <code>null</code> removes the transition * @param page the page where the transition will be applied. The first page is 1 */ void setTransition(PdfTransition transition, int page) { PdfDictionary pg = reader.getPageN(page); if (transition == null) pg.remove(PdfName.TRANS); else pg.put(PdfName.TRANS, transition.getTransitionDictionary()); markUsed(pg); }
PdfReader reader = new PdfReader(src); // We assume that there's a single large picture on the first page PdfDictionary page = reader.getPageN(1); PdfDictionary resources = page.getAsDict(PdfName.RESOURCES); PdfDictionary xobjects = resources.getAsDict(PdfName.XOBJECT); PdfName imgName = xobjects.getKeys().iterator().next(); Image img = Image.getInstance((PRIndirectReference)xobjects.getAsIndirectObject(imgName)); img.setAbsolutePosition(0, 0); img.scaleAbsolute(reader.getPageSize(1)); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); stamper.getOverContent(1).addImage(img); stamper.close(); reader.close();
void setThumbnail(Image image, int page) throws PdfException, DocumentException { PdfIndirectReference thumb = getImageReference(addDirectImageSimple(image)); reader.resetReleasePage(); PdfDictionary dic = reader.getPageN(page); dic.put(PdfName.THUMB, thumb); reader.resetReleasePage(); }
void setThumbnail(Image image, int page) throws PdfException, DocumentException { PdfIndirectReference thumb = getImageReference(addDirectImageSimple(image)); reader.resetReleasePage(); PdfDictionary dic = reader.getPageN(page); dic.put(PdfName.THUMB, thumb); reader.resetReleasePage(); }