[ https://issues.apache.org/jira/browse/PDFBOX-3801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16019249#comment-16019249 ]
Tilman Hausherr commented on PDFBOX-3801: ----------------------------------------- Here's an example derived from code in PDFBOX-3359: {code} protected void paintComponent(Graphics g) { try { g.setColor(Color.red); g.fillRect(0, 0, getWidth(), getHeight()); PDPage page = doc.getPage(0); PDRectangle cropBox = page.getCropBox(); boolean rot = false; if (page.getRotation() == 90 || page.getRotation() == 270) { rot = true; } // https://stackoverflow.com/questions/1106339/resize-image-to-fit-in-bounding-box float imgWidth = rot ? cropBox.getHeight() : cropBox.getWidth(); float imgHeight = rot ? cropBox.getWidth() : cropBox.getHeight(); float xf = getWidth() / imgWidth; float yf = getHeight() / imgHeight; float scale = Math.min(xf, yf); if (yf < xf) { g.translate((int) ((getWidth() - imgWidth * yf) / 2), 0); } else { g.translate(0, (int) ((getHeight() - imgHeight * xf) / 2)); } renderer.renderPageToGraphics(pageNum-1, (Graphics2D) g, scale); } catch (IOException e) { e.printStackTrace(); } } {code} > PDFToImage : Can the output image be generated with specified size details? > --------------------------------------------------------------------------- > > Key: PDFBOX-3801 > URL: https://issues.apache.org/jira/browse/PDFBOX-3801 > Project: PDFBox > Issue Type: Wish > Reporter: Kamna > Priority: Minor > -- This message was sent by Atlassian JIRA (v6.3.15#6346) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org