[ 
https://issues.apache.org/jira/browse/PDFBOX-4826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17108946#comment-17108946
 ] 

Tilman Hausherr commented on PDFBOX-4826:
-----------------------------------------

Please try this code:
{code}
int dpi = 300;

int width = 612;
int height = 792;
int w = (int) (width * dpi / 72f);
int h = (int) (height * dpi / 72f);

BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = (Graphics2D) bim.getGraphics();
graphics.setBackground(Color.white);
graphics.clearRect(0, 0, bim.getWidth(), bim.getHeight());

graphics.scale(dpi / 72f, dpi / 72f);

graphics.translate(0, height);
graphics.scale(1, -1);

System.out.println("Transform: " + graphics.getTransform());

GeneralPath path = new GeneralPath();
path.moveTo(492.55f, 535.8f);
path.lineTo(502.55f, 535.8f);
path.lineTo(502.55f, 545.8f);
path.lineTo(492.55f, 545.8f);
path.closePath();

graphics.setStroke(new BasicStroke(0.5f, 1, 1, 10f, null, 0));

graphics.setColor(Color.black);
graphics.draw(path);

graphics.dispose();
ImageIO.write(bim, "jpg", new File("PDFBOX4826.jpg"));
{code}

> PDF rendering produces distorted images at various DPI
> ------------------------------------------------------
>
>                 Key: PDFBOX-4826
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4826
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Rendering
>    Affects Versions: 2.0.19
>         Environment: Java8, docker container
>            Reporter: Himanshu Pandey
>            Priority: Critical
>              Labels: docker
>         Attachments: 05_-_Form_5_old(1).pdf, 05_-_Form_5_old(1)2-tilman.jpg, 
> 300_DPI.jpeg, 301_DPI.jpeg, PDFBOX-4826-reduced1.pdf, reduced_render.jpeg
>
>
> I am getting different output for a pdf document when converting into image.
> At 300 DPI the checkboxes are rendered at random places and have different 
> shapes.
> At 301 or 209 DPI they are being rendered properly. For different DPI it is 
> having this behavior like at 150 DPI it is again distorted and 149 it looks 
> fine. 
>  
> I have attached the pdf. The page number 2 of the pdf document has issues.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to