List of usage examples for org.apache.pdfbox.pdmodel.interactive.annotation PDAnnotation getPage
public PDPage getPage()
From source file:at.knowcenter.wag.egov.egiz.pdf.PDFPage.java
License:EUPL
public void processAnnotation(PDAnnotation anno) { float current_y = anno.getRectangle().getLowerLeftY(); float upper_y = 0; PDPage page = anno.getPage(); if (page == null) { page = getCurrentPage();/*from w w w. j a v a 2s. c om*/ } if (page == null) { logger.warn("Annotation without page! The position might not be correct!"); return; } int pageRotation = page.findRotation(); // logger_.debug("PageRotation = " + pageRotation); if (pageRotation == 0) { float page_height = page.findMediaBox().getHeight(); current_y = page_height - anno.getRectangle().getLowerLeftY(); upper_y = page_height - anno.getRectangle().getUpperRightY(); } if (pageRotation == 90) { current_y = anno.getRectangle().getUpperRightX(); upper_y = anno.getRectangle().getLowerLeftX(); } if (pageRotation == 180) { current_y = anno.getRectangle().getUpperRightY(); upper_y = anno.getRectangle().getLowerLeftY(); } if (pageRotation == 270) { float page_width = page.findMediaBox().getWidth(); current_y = page_width - anno.getRectangle().getLowerLeftX(); upper_y = page_width - anno.getRectangle().getUpperRightX(); } if (current_y > this.effectivePageHeight) { if (!this.legacy40 && upper_y < this.effectivePageHeight) { // Bottom of annotation is below footer line, // but top of annotation is above footer line! // so no place left on this page! this.max_character_ypos = this.effectivePageHeight; } return; } // store ypos of the char if it is not empty if (current_y > this.max_character_ypos) { this.max_character_ypos = current_y; } }
From source file:at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage.java
License:EUPL
public void processAnnotation(PDAnnotation anno) { float current_y = anno.getRectangle().getLowerLeftY(); float upper_y = 0; PDPage page = anno.getPage(); if (page == null) { page = getCurrentPage();//w ww .j ava 2 s.com } if (page == null) { logger.warn("Annotation without page! The position might not be correct!"); return; } int pageRotation = page.getRotation(); // logger_.debug("PageRotation = " + pageRotation); if (pageRotation == 0) { float page_height = page.getMediaBox().getHeight(); current_y = page_height - anno.getRectangle().getLowerLeftY(); upper_y = page_height - anno.getRectangle().getUpperRightY(); } if (pageRotation == 90) { current_y = anno.getRectangle().getUpperRightX(); upper_y = anno.getRectangle().getLowerLeftX(); } if (pageRotation == 180) { current_y = anno.getRectangle().getUpperRightY(); upper_y = anno.getRectangle().getLowerLeftY(); } if (pageRotation == 270) { float page_width = page.getMediaBox().getWidth(); current_y = page_width - anno.getRectangle().getLowerLeftX(); upper_y = page_width - anno.getRectangle().getUpperRightX(); } if (current_y > this.effectivePageHeight) { if (!this.legacy40 && upper_y < this.effectivePageHeight) { // Bottom of annotation is below footer line, // but top of annotation is above footer line! // so no place left on this page! this.max_character_ypos = this.effectivePageHeight; } return; } // store ypos of the char if it is not empty if (current_y > this.max_character_ypos) { this.max_character_ypos = current_y; } }