PdfDictionary pageDict = myReader.getPageN(1); PdfArray annots = pageDict.getAsArray(PdfName.ANNOTS); ArrayList<String> dests = new ArrayList<String>(); if (annots != null) { for (int i = 0; i < annots.size(); ++i) { PdfDictionary annotDict = annots.getAsDict(i); PdfName subType = annotDict.getAsName(PdfName.SUBTYPE); if (subType != null && PdfName.LINK.equals(subType)) { PdfDictionary action = annotDict.getAsDict(PdfName.A); if (action != null && PdfName.URI.equals(action.getAsName(PdfName.S)) { dests.add(action.getAsString(PdfName.URI).toString()); } // else { its an internal link, meh } } } }
/** * Retrieve the given page's resource dictionary * @param pageDict the given page * @return The page's resources, or 'null' if the page has none. * @since 5.1 */ public PdfDictionary getPageResources(final PdfDictionary pageDict) { return pageDict.getAsDict(PdfName.RESOURCES); }
/** * Retrieve the given page's resource dictionary * @param pageDict the given page * @return The page's resources, or 'null' if the page has none. * @since 5.1 */ public PdfDictionary getPageResources(final PdfDictionary pageDict) { return pageDict.getAsDict(PdfName.RESOURCES); }
/** * Checks if the PDF is a tagged PDF. */ public boolean isTagged() { PdfDictionary markInfo = catalog.getAsDict(PdfName.MARKINFO); if (markInfo == null) return false; if ( PdfBoolean.PDFTRUE.equals(markInfo.getAsBoolean(PdfName.MARKED))) { return catalog.getAsDict(PdfName.STRUCTTREEROOT) != null; } else { return false; } }
PageStamp(PdfStamperImp stamper, PdfReader reader, PdfDictionary pageN) { this.pageN = pageN; pageResources = new PageResources(); PdfDictionary resources = pageN.getAsDict(PdfName.RESOURCES); pageResources.setOriginalResources(resources, stamper.namePtr); } }
public void extractText(String src, String dest) throws IOException { PrintWriter out = new PrintWriter(new FileOutputStream(dest)); PdfReader reader = new PdfReader(src); RenderListener listener = new MyTextRenderListener(out); PdfContentStreamProcessor processor = new PdfContentStreamProcessor(listener); PdfDictionary pageDic = reader.getPageN(1); PdfDictionary resourcesDic = pageDic.getAsDict(PdfName.RESOURCES); processor.processContent(ContentByteUtils.getContentBytesForPage(reader, 1), resourcesDic); out.flush(); out.close(); }
boolean isSymbolic() { PdfDictionary fontDescriptor = font.getAsDict(PdfName.FONTDESCRIPTOR); if (fontDescriptor == null) return false; PdfNumber flags = fontDescriptor.getAsNumber(PdfName.FLAGS); if (flags == null) return false; return (flags.intValue() & 0x04) != 0; } }
PageStamp(PdfStamperImp stamper, PdfReader reader, PdfDictionary pageN) { this.pageN = pageN; pageResources = new PageResources(); PdfDictionary resources = pageN.getAsDict(PdfName.RESOURCES); pageResources.setOriginalResources(resources, stamper.namePtr); } }
boolean isSymbolic() { PdfDictionary fontDescriptor = font.getAsDict(PdfName.FONTDESCRIPTOR); if (fontDescriptor == null) return false; PdfNumber flags = fontDescriptor.getAsNumber(PdfName.FLAGS); if (flags == null) return false; return (flags.intValue() & 0x04) != 0; } }
/** * Checks if this PDF has usage rights enabled. * * @return <code>true</code> if usage rights are present; <code>false</code> otherwise */ public boolean hasUsageRights() { PdfDictionary perms = catalog.getAsDict(PdfName.PERMS); if (perms == null) return false; return perms.contains(PdfName.UR) || perms.contains(PdfName.UR3); }
/** * Checks if this PDF has usage rights enabled. * * @return <code>true</code> if usage rights are present; <code>false</code> otherwise */ public boolean hasUsageRights() { PdfDictionary perms = catalog.getAsDict(PdfName.PERMS); if (perms == null) return false; return perms.contains(PdfName.UR) || perms.contains(PdfName.UR3); }
public void manipulatePdf(String src, String dest) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); PdfDictionary root = reader.getCatalog(); PdfDictionary names = root.getAsDict(PdfName.NAMES); names.remove(PdfName.EMBEDDEDFILES); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); stamper.close(); }
public void manipulatePdf(String src, String dest) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); PdfDictionary root = reader.getCatalog(); PdfDictionary names = root.getAsDict(PdfName.NAMES); PdfDictionary embeddedFiles = names.getAsDict(PdfName.EMBEDDEDFILES); PdfArray namesArray = embeddedFiles.getAsArray(PdfName.NAMES); namesArray.remove(0); namesArray.remove(0); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); stamper.close(); }
public PdfContentByte getUnderContent(){ if (under == null) { if (pageResources == null) { pageResources = new PageResources(); PdfDictionary resources = pageN.getAsDict(PdfName.RESOURCES); pageResources.setOriginalResources(resources, cstp.namePtr); } under = new PdfCopy.StampContent(cstp, pageResources); } return under; }
public PdfContentByte getOverContent(){ if (over == null) { if (pageResources == null) { pageResources = new PageResources(); PdfDictionary resources = pageN.getAsDict(PdfName.RESOURCES); pageResources.setOriginalResources(resources, cstp.namePtr); } over = new PdfCopy.StampContent(cstp, pageResources); } return over; }
public PdfContentByte getUnderContent(){ if (under == null) { if (pageResources == null) { pageResources = new PageResources(); PdfDictionary resources = pageN.getAsDict(PdfName.RESOURCES); pageResources.setOriginalResources(resources, cstp.namePtr); } under = new PdfCopy.StampContent(cstp, pageResources); } return under; }
public PdfContentByte getOverContent(){ if (over == null) { if (pageResources == null) { pageResources = new PageResources(); PdfDictionary resources = pageN.getAsDict(PdfName.RESOURCES); pageResources.setOriginalResources(resources, cstp.namePtr); } over = new PdfCopy.StampContent(cstp, pageResources); } return over; }
/** * Removes any usage rights that this PDF may have. Only Adobe can grant usage rights * and any PDF modification with iText will invalidate them. Invalidated usage rights may * confuse Acrobat and it's advisable to remove them altogether. */ public void removeUsageRights() { PdfDictionary perms = catalog.getAsDict(PdfName.PERMS); if (perms == null) return; perms.remove(PdfName.UR); perms.remove(PdfName.UR3); if (perms.size() == 0) catalog.remove(PdfName.PERMS); }
/** * Removes the XFA stream from the document. */ public void removeXfa() { PdfDictionary root = reader.getCatalog(); PdfDictionary acroform = root.getAsDict(PdfName.ACROFORM); acroform.remove(PdfName.XFA); try { xfa = new XfaForm(reader); } catch(Exception e) { throw new ExceptionConverter(e); } }