/** * 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); }
void addDefaultColor(PdfName name, PdfObject obj) { if (obj == null || obj.isNull()) colorDictionary.remove(name); else colorDictionary.put(name, obj); }
void addDefaultColor(PdfName name, PdfObject obj) { if (obj == null || obj.isNull()) colorDictionary.remove(name); else colorDictionary.put(name, obj); }
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(); }
private static void moveRectangle(PdfDictionary dic2, PdfReader r, int pageImported, PdfName key, String name) { Rectangle m = r.getBoxSize(pageImported, name); if (m == null) dic2.remove(key); else dic2.put(key, new PdfRectangle(m)); }
void addAdditionalAction(final PdfName actionType, final PdfAction action) { if (additionalActions == null) { additionalActions = new PdfDictionary(); } if (action == null) additionalActions.remove(actionType); else additionalActions.put(actionType, action); if (additionalActions.size() == 0) additionalActions = null; }
private static void moveRectangle(PdfDictionary dic2, PdfReader r, int pageImported, PdfName key, String name) { Rectangle m = r.getBoxSize(pageImported, name); if (m == null) dic2.remove(key); else dic2.put(key, new PdfRectangle(m)); }
void addAdditionalAction(final PdfName actionType, final PdfAction action) { if (additionalActions == null) { additionalActions = new PdfDictionary(); } if (action == null) additionalActions.remove(actionType); else additionalActions.put(actionType, action); if (additionalActions.size() == 0) additionalActions = null; }
public void setMKBackgroundColor(BaseColor color) { if (color == null) getMK().remove(PdfName.BG); else getMK().put(PdfName.BG, getMKColor(color)); }
public void setMKBorderColor(BaseColor color) { if (color == null) getMK().remove(PdfName.BC); else getMK().put(PdfName.BC, getMKColor(color)); }
public void setMKBorderColor(BaseColor color) { if (color == null) getMK().remove(PdfName.BC); else getMK().put(PdfName.BC, getMKColor(color)); }
public void setMKBackgroundColor(BaseColor color) { if (color == null) getMK().remove(PdfName.BG); else getMK().put(PdfName.BG, getMKColor(color)); }
/** * 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); } }
/** * 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); }
private PdfObject cleverPdfDictionaryClone(PdfDictionary dict) { PdfDictionary newDict; if (dict.isStream()) { newDict = new PdfStream(emptyByteArray); newDict.remove(PdfName.LENGTH); } else newDict = new PdfDictionary(); for (PdfName key : dict.getKeys()) if (keysForCheck.contains(key)) newDict.put(key, dict.get(key)); return newDict; }
void deleteOutlines() { PdfDictionary catalog = reader.getCatalog(); PdfObject obj = catalog.get(PdfName.OUTLINES); if (obj == null) return; if (obj instanceof PRIndirectReference) { PRIndirectReference outlines = (PRIndirectReference) obj; outlineTravel(outlines); PdfReader.killIndirect(outlines); } catalog.remove(PdfName.OUTLINES); markUsed(catalog); }
void deleteOutlines() { PdfDictionary catalog = reader.getCatalog(); PdfObject obj = catalog.get(PdfName.OUTLINES); if (obj == null) return; if (obj instanceof PRIndirectReference) { PRIndirectReference outlines = (PRIndirectReference) obj; outlineTravel(outlines); PdfReader.killIndirect(outlines); } catalog.remove(PdfName.OUTLINES); markUsed(catalog); }