List of usage examples for org.apache.pdfbox.pdmodel.common PDRectangle PDRectangle
public PDRectangle(COSArray array)
From source file:gov.samhsa.c2s.common.pdfbox.enhance.HexPdf.java
License:Apache License
/** * Close the current page (if any), and open a new one. Cursor position is * reset to top-left corner of writable area (within margins) * * @see #closePage()//from w ww .j av a 2 s. c om */ public void newPage() { numPages++; if (currentPage != null) { closePage(); } currentPage = new PDPage(); float x1 = this.pageSize.getLowerLeftX(); float y1 = this.pageSize.getLowerLeftY(); float x2 = this.pageSize.getUpperRightX(); float y2 = this.pageSize.getUpperRightY(); float w = this.pageSize.getWidth(); float h = this.pageSize.getHeight(); if (orientation == HexPdf.PORTRAIT) { pageWidth = w; pageHeight = h; currentPage.setMediaBox(new PDRectangle(new BoundingBox(x1, y1, x2, y2))); } else { pageWidth = h; pageHeight = w; currentPage.setMediaBox(new PDRectangle(new BoundingBox(y1, x1, y2, x2))); } setDimensions(); cursorX = contentStartX; cursorY = contentStartY; try { cs = new PDPageContentStream(this, currentPage); cs.setFont(font, fontSize); } catch (IOException ex) { Logger.getLogger(HexPdf.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:net.heksemann.hexpdf.HexPDF.java
License:Apache License
/** * Close the current page (if any), and open a new one. Cursor position is * reset to top-left corner of writable area (within margins) * * @see #closePage()/*from w w w . j ava 2s . c o m*/ */ public void newPage() { numPages++; if (currentPage != null) { closePage(); } currentPage = new PDPage(); float x1 = this.pageSize.getLowerLeftX(); float y1 = this.pageSize.getLowerLeftY(); float x2 = this.pageSize.getUpperRightX(); float y2 = this.pageSize.getUpperRightY(); float w = this.pageSize.getWidth(); float h = this.pageSize.getHeight(); if (orientation == HexPDF.PORTRAIT) { pageWidth = w; pageHeight = h; currentPage.setMediaBox(new PDRectangle(new BoundingBox(x1, y1, x2, y2))); } else { pageWidth = h; pageHeight = w; currentPage.setMediaBox(new PDRectangle(new BoundingBox(y1, x1, y2, x2))); } setDimensions(); cursorX = contentStartX; cursorY = contentStartY; try { cs = new PDPageContentStream(this, currentPage); cs.setFont(font, fontSize); } catch (IOException ex) { Logger.getLogger(HexPDF.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.wangwei.pdf.hexpdf.HexPDF.java
License:Apache License
/** * Close the current page (if any), and open a new one. Cursor position is reset to top-left corner of writable area * (within margins)//from w ww . ja v a 2s .c om * * @see #closePage() */ public void newPage() { numPages++; if (currentPage != null) { closePage(); } currentPage = new PDPage(); float x1 = pageSize.getLowerLeftX(); float y1 = pageSize.getLowerLeftY(); float x2 = pageSize.getUpperRightX(); float y2 = pageSize.getUpperRightY(); float w = pageSize.getWidth(); float h = pageSize.getHeight(); if (orientation == HexPDF.PORTRAIT) { pageWidth = w; pageHeight = h; currentPage.setMediaBox(new PDRectangle(new BoundingBox(x1, y1, x2, y2))); } else { pageWidth = h; pageHeight = w; currentPage.setMediaBox(new PDRectangle(new BoundingBox(y1, x1, y2, x2))); } setDimensions(); cursorX = contentStartX; cursorY = contentStartY; try { cs = new PDPageContentStream(this, currentPage); cs.setFont(font, fontSize); } catch (IOException ex) { Logger.getLogger(HexPDF.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.wangwei.pdf.hexpdf.HexPDF2.java
License:Apache License
/** * Close the current page (if any), and open a new one. Cursor position is reset to top-left corner of writable area * (within margins)//w ww. j a v a 2 s . c om * * @see #closePage() */ public void newPage() { numPages++; if (currentPage != null) { closePage(); } currentPage = new PDPage(); float x1 = pageSize.getLowerLeftX(); float y1 = pageSize.getLowerLeftY(); float x2 = pageSize.getUpperRightX(); float y2 = pageSize.getUpperRightY(); float w = pageSize.getWidth(); float h = pageSize.getHeight(); if (orientation == HexPDF2.PORTRAIT) { pageWidth = w; pageHeight = h; currentPage.setMediaBox(new PDRectangle(new BoundingBox(x1, y1, x2, y2))); } else { pageWidth = h; pageHeight = w; currentPage.setMediaBox(new PDRectangle(new BoundingBox(y1, x1, y2, x2))); } setDimensions(); cursorX = contentStartX; cursorY = contentStartY; try { cs = new PDPageContentStream(this, currentPage); cs.setFont(font, fontSize); } catch (IOException ex) { Logger.getLogger(HexPDF2.class.getName()).log(Level.SEVERE, null, ex); } }