You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by "Kirk, Kenneth" <Kk...@ILSOS.GOV> on 2019/03/20 19:19:50 UTC

Scaling Rectangle

We have document management application that creates graphic annotations for documents of various types such as word, text, spreadsheets, PDF and such.  I need to take the PDFs and merge the graphic annotations by creating PDF annotations and placing them in the PDF.  The problem I am having is that the graphic annotation were positioned using 96 dpi and the PDF specification is 72 dpi.    I tried scaling the rectangle from document management application down by 25 percent as this is roughly the difference going from 96 to 72 but the annotations don't line up.  Below is the code I use to scale  the rectangle.

                                  java.awt.Rectangle borderRect = annotation.getRefreshRect();
                                  float x = (float) (borderRect.x / 1.25);
                                  float y = (float) (borderRect.y / 1.25);
                                  float h = (float) (borderRect.height/ 1.25);
                                  float w = (float) (borderRect.width/ 1.25);
                                  PDRectangle borderLocation = new PDRectangle(x,
                                                                            (pageHeight - y)-h,
                                                                                           w,
                                                                                            y);
The placement is in the ballpark but still way off.  How should I approach this problem.

Kenneth D. Kirk
Information Systems Advisor
Document Management
Information Technology









************************************************
Disclaimer - This email and any files transmitted with it are confidential and contain privileged or copyright information. You must not present this message to another party without gaining permission from the sender. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify the Office of the Illinois Secretary of State. 

If you have received this message in error, please notify the sender immediately, and delete this email from your system. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of the Office of the Illinois Secretary of State. 
************************************************











RE: External: Re: Scaling Rectangle

Posted by "Kirk, Kenneth" <Kk...@ILSOS.GOV>.
Thank you for your help.  The "getRefreshRect" method is an API method from the document management application that the users used to create the annotations.  Your suggestions worked.  I don't know what I was thinking.  It was so obvious only after the fact where my error was.

Kenneth

-----Original Message-----
From: Tilman Hausherr <TH...@t-online.de> 
Sent: Wednesday, March 20, 2019 2:46 PM
To: users@pdfbox.apache.org
Subject: External: Re: Scaling Rectangle

1 / 96 * 72 = 0.75  so you should multiply by 0.75 instead of dividing by 1.25.  Because 1 / 1.25 = 0.8

Another idea:
Could it be that the PDF has a cropbox and that the application didn't know what when it calculated the position?

There is no "getRefreshRect" method in PDFBox.

If you still don't get it to work, how about creating a PDF that has a grid at 100, 200, 300 etc. and then place annotations to see what numbers come up. To draw in a PDF, see the CreateLandscapePDF.java example in the source code download (moveto, lineto, stroke)

Tilman

Am 20.03.2019 um 20:19 schrieb Kirk, Kenneth:
> We have document management application that creates graphic annotations for documents of various types such as word, text, spreadsheets, PDF and such.  I need to take the PDFs and merge the graphic annotations by creating PDF annotations and placing them in the PDF.  The problem I am having is that the graphic annotation were positioned using 96 dpi and the PDF specification is 72 dpi.    I tried scaling the rectangle from document management application down by 25 percent as this is roughly the difference going from 96 to 72 but the annotations don't line up.  Below is the code I use to scale  the rectangle.
>
>                                    java.awt.Rectangle borderRect = annotation.getRefreshRect();
>                                    float x = (float) (borderRect.x / 1.25);
>                                    float y = (float) (borderRect.y / 1.25);
>                                    float h = (float) (borderRect.height/ 1.25);
>                                    float w = (float) (borderRect.width/ 1.25);
>                                    PDRectangle borderLocation = new PDRectangle(x,
>                                                                              (pageHeight - y)-h,
>                                                                                             w,
>                                                                                              
> y); The placement is in the ballpark but still way off.  How should I approach this problem.
>
> Kenneth D. Kirk
> Information Systems Advisor
> Document Management
> Information Technology
>
>
>
>
>
>
>
>
>
> ************************************************
> Disclaimer - This email and any files transmitted with it are confidential and contain privileged or copyright information. You must not present this message to another party without gaining permission from the sender. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify the Office of the Illinois Secretary of State.
>
> If you have received this message in error, please notify the sender immediately, and delete this email from your system. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of the Office of the Illinois Secretary of State.
> ************************************************
>
>
>
>
>
>
>
>
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org









************************************************
Disclaimer - This email and any files transmitted with it are confidential and contain privileged or copyright information. You must not present this message to another party without gaining permission from the sender. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify the Office of the Illinois Secretary of State. 

If you have received this message in error, please notify the sender immediately, and delete this email from your system. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of the Office of the Illinois Secretary of State. 
************************************************












---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Scaling Rectangle

Posted by Tilman Hausherr <TH...@t-online.de>.
1 / 96 * 72 = 0.75  so you should multiply by 0.75 instead of dividing 
by 1.25.  Because 1 / 1.25 = 0.8

Another idea:
Could it be that the PDF has a cropbox and that the application didn't 
know what when it calculated the position?

There is no "getRefreshRect" method in PDFBox.

If you still don't get it to work, how about creating a PDF that has a 
grid at 100, 200, 300 etc. and then place annotations to see what 
numbers come up. To draw in a PDF, see the CreateLandscapePDF.java 
example in the source code download (moveto, lineto, stroke)

Tilman

Am 20.03.2019 um 20:19 schrieb Kirk, Kenneth:
> We have document management application that creates graphic annotations for documents of various types such as word, text, spreadsheets, PDF and such.  I need to take the PDFs and merge the graphic annotations by creating PDF annotations and placing them in the PDF.  The problem I am having is that the graphic annotation were positioned using 96 dpi and the PDF specification is 72 dpi.    I tried scaling the rectangle from document management application down by 25 percent as this is roughly the difference going from 96 to 72 but the annotations don't line up.  Below is the code I use to scale  the rectangle.
>
>                                    java.awt.Rectangle borderRect = annotation.getRefreshRect();
>                                    float x = (float) (borderRect.x / 1.25);
>                                    float y = (float) (borderRect.y / 1.25);
>                                    float h = (float) (borderRect.height/ 1.25);
>                                    float w = (float) (borderRect.width/ 1.25);
>                                    PDRectangle borderLocation = new PDRectangle(x,
>                                                                              (pageHeight - y)-h,
>                                                                                             w,
>                                                                                              y);
> The placement is in the ballpark but still way off.  How should I approach this problem.
>
> Kenneth D. Kirk
> Information Systems Advisor
> Document Management
> Information Technology
>
>
>
>
>
>
>
>
>
> ************************************************
> Disclaimer - This email and any files transmitted with it are confidential and contain privileged or copyright information. You must not present this message to another party without gaining permission from the sender. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify the Office of the Illinois Secretary of State.
>
> If you have received this message in error, please notify the sender immediately, and delete this email from your system. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of the Office of the Illinois Secretary of State.
> ************************************************
>
>
>
>
>
>
>
>
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org