Example usage for com.lowagie.text.pdf PdfArray getAsDict

List of usage examples for com.lowagie.text.pdf PdfArray getAsDict

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfArray getAsDict.

Prototype

public PdfDictionary getAsDict(int idx) 

Source Link

Document

Returns a PdfObject as a PdfDictionary, resolving indirect references.

Usage

From source file:it.flavianopetrocchi.jpdfbookmarks.itextbookmarksconverter.iTextBookmarksConverter.java

License:Open Source License

private void setActionsRecursive(Bookmark bookmark, PdfDictionary action) {

    setActionInBookmark(bookmark, action);

    PdfObject next = PdfReader.getPdfObjectRelease(action.get(PdfName.NEXT));
    if (next != null) {
        if (next.isArray()) {
            PdfArray actions = (PdfArray) next;
            for (int i = 0; i < actions.size(); i++) {
                Bookmark b = new Bookmark();
                action = actions.getAsDict(i);
                setActionsRecursive(b, action);
                bookmark.addChainedBookmark(b);
            }/*from   w  ww.ja  v  a 2s .  c  om*/
        } else if (next.isDictionary()) {
            Bookmark b = new Bookmark();
            action = (PdfDictionary) next;
            setActionsRecursive(b, action);
            bookmark.addChainedBookmark(b);
        }
    }
}

From source file:questions.stamppages.RemoveAttachmentAnnotations.java

public static void main(String[] args) throws IOException, DocumentException {
    createPdfWithAttachments();/*from  ww w.j  a  va2  s .  c  o  m*/
    PdfReader reader = new PdfReader(RESOURCE);
    PdfDictionary page;
    PdfDictionary annotation;
    for (int i = 1; i <= reader.getNumberOfPages(); i++) {
        page = reader.getPageN(i);
        PdfArray annots = page.getAsArray(PdfName.ANNOTS);
        if (annots != null) {
            for (int j = annots.size() - 1; j >= 0; j--) {
                annotation = annots.getAsDict(j);
                if (PdfName.FILEATTACHMENT.equals(annotation.get(PdfName.SUBTYPE))) {
                    annots.remove(j);
                }
            }
        }
    }
    reader.removeUnusedObjects();
    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(RESULT));
    stamper.close();
}