Example usage for org.apache.pdfbox.pdmodel.interactive.annotation PDAnnotation getCOSObject

List of usage examples for org.apache.pdfbox.pdmodel.interactive.annotation PDAnnotation getCOSObject

Introduction

In this page you can find the example usage for org.apache.pdfbox.pdmodel.interactive.annotation PDAnnotation getCOSObject.

Prototype

@Override
public COSDictionary getCOSObject() 

Source Link

Document

Interface method for COSObjectable.

Usage

From source file:com.formkiq.core.service.generator.pdfbox.PdfEditorServiceImpl.java

License:Apache License

/**
 * Generate {@link Map} {@link COSDictionary} to Page Numbers.
 * @param doc {@link PDDocument}//ww  w .j a v a2  s . co  m
 * @return {@link Map} of {@link COSDictionary} to {@link Integer}
 * @throws IOException IOException
 */
private Map<COSDictionary, Integer> getCOSDictionaryToPageNumberMap(final PDDocument doc) throws IOException {

    Map<COSDictionary, Integer> map = new HashMap<>();

    PDPageTree pages = doc.getPages();
    for (int i = 0; i < pages.getCount(); i++) {
        for (PDAnnotation annotation : pages.get(i).getAnnotations()) {
            COSDictionary annotationObject = annotation.getCOSObject();
            map.put(annotationObject, Integer.valueOf(i));
        }
    }

    return map;
}