Example usage for com.lowagie.text.pdf PdfName RECT

List of usage examples for com.lowagie.text.pdf PdfName RECT

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfName RECT.

Prototype

PdfName RECT

To view the source code for com.lowagie.text.pdf PdfName RECT.

Click Source Link

Document

A name

Usage

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

License:Open Source License

public ArrayList<AnnotationRect> getLinks(int currentPage, boolean convertNamedDestinations) {

    ArrayList<AnnotationRect> bookmarkLinks = new ArrayList<AnnotationRect>();
    ArrayList links = null;//from   w  w  w .j  ava2  s.com
    if (reader != null) {
        if (convertNamedDestinations) {
            reader.consolidateNamedDestinations();
        }
        links = reader.getAnnotations(currentPage);
        for (int i = 0; i < links.size(); i++) {
            AnnotationRect annoRect = new AnnotationRect();
            Bookmark bookmark = new Bookmark();
            PdfDictionary annot = (PdfDictionary) links.get(i);
            try {
                PdfObject dest = PdfReader.getPdfObjectRelease(annot.get(PdfName.DEST));
                if (dest != null) {
                    mapGotoBookmark(bookmark, dest);
                } else {
                    PdfDictionary action = (PdfDictionary) PdfReader.getPdfObjectRelease(annot.get(PdfName.A));
                    if (action != null) {
                        setActionsRecursive(bookmark, action);
                    } else {
                        bookmark.setType(BookmarkType.Unknown);
                    }
                }
            } catch (Exception e) {
                //empty on purpose
            }
            PdfObject obj = (PdfObject) annot.get(PdfName.RECT);
            if (obj instanceof PdfArray) {
                PdfArray rc = (PdfArray) obj;
                annoRect.llx = (int) rc.getAsNumber(0).floatValue();
                annoRect.lly = (int) rc.getAsNumber(1).floatValue();
                annoRect.urx = (int) rc.getAsNumber(2).floatValue();
                annoRect.ury = (int) rc.getAsNumber(3).floatValue();
            }
            annoRect.bookmark = bookmark;
            bookmarkLinks.add(annoRect);
        }
    }

    return bookmarkLinks;
}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PolygonAnnotation.java

License:Open Source License

public PolygonAnnotation(final PdfWriter writer, final float[] coords) {
    super(writer, null);
    put(PdfName.SUBTYPE, POLYGON);//  w  w  w  .j av  a 2 s  .  c om
    put(PdfName.RECT, createRec(coords));
    put(VERTICES, new PdfArray(coords));
}