You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by "M. Niedermair" <m_...@gmx.de> on 2016/02/18 10:26:04 UTC
PDRectangle.java and POINTS_PER_INCH
Hi developers,
it is possible to set POINTS_PER_INCH and MM_PER_INCH from private to
public, because you can do it in many conversions and so does not have
to redefine.
greeting
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: PDRectangle.java and POINTS_PER_INCH
Posted by John Hewson <jo...@jahewson.com>.
> On 18 Feb 2016, at 01:26, M. Niedermair <m_...@gmx.de> wrote:
>
> Hi developers,
>
> it is possible to set POINTS_PER_INCH and MM_PER_INCH from private to public,
We probably won't do this because PDRectangle is not the place for such things.
> because you can do it in many conversions and so does not have to redefine.
If that’s the case then you’re probably not using the APIs in the best manner. If you want to work in inches, then transform the page so that the user space is in inches, rather than points. You can do this by concatenating a scaling matrix to the CTM.
> greeting
> Michael
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: PDRectangle.java and POINTS_PER_INCH
Posted by John Hewson <jo...@jahewson.com>.
> On 18 Feb 2016, at 15:43, Roberto Nibali <rn...@gmail.com> wrote:
>
> Hi
>
> On Thu, Feb 18, 2016 at 11:03 PM, Gilad Denneboom <gilad.denneboom@gmail.com
>> wrote:
>
>> Probably just a type-o. It should be renamed POINTS_PER_MM, which is indeed
>> 2.83465.
>>
>
> At some point in my code I defined those values as such:
>
> private static final float POINTS_PER_INCH = 72;
> private static final float MM_PER_INCH = 25.4f;
> private static final float MM_PER_POINT = MM_PER_INCH / POINTS_PER_INCH;
> private static final float POINTS_PER_MM = POINTS_PER_INCH / MM_PER_INCH;
>
> I used them as abstraction hints for an API call to position data matrix
> and other stuff by relative metric measurements. Example:
>
> pdf.addDataMatrix(srcDoc, page, "Sometext", 87 * POINTS_PER_MM, PAGE_H - 60
> * POINTS_PER_MM - DM_H_ABS, 1f);
It would be better to just transform the CTM, when you want relative positioning, use
a translation matrix, when you want to work with a different unit of measure, use a
scaling matrix. PDF gives you the ability to work in any units you want.
— John
> This for example would mean that the text had to be positioned
> 87millimeters from the left hand side and 60 millimeters from the top of
> the page minus the expected height of the data matrix. It allows the user
> of the API to directly use typical CI/CD guideline measurements in metric
> format, while the drawImage() method of the PDPageContentStream object
> inside PDFBox always expects points in floats as input.
>
> Your mileage might vary on this level of abstraction. I found them to be
> very useful and certainly wished that those be accessible via public
> interface instead inside PDFBox.
>
> Cheers
>
> Roberto
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: PDRectangle.java and POINTS_PER_INCH
Posted by Roberto Nibali <rn...@gmail.com>.
Hi
On Thu, Feb 18, 2016 at 11:03 PM, Gilad Denneboom <gilad.denneboom@gmail.com
> wrote:
> Probably just a type-o. It should be renamed POINTS_PER_MM, which is indeed
> 2.83465.
>
At some point in my code I defined those values as such:
private static final float POINTS_PER_INCH = 72;
private static final float MM_PER_INCH = 25.4f;
private static final float MM_PER_POINT = MM_PER_INCH / POINTS_PER_INCH;
private static final float POINTS_PER_MM = POINTS_PER_INCH / MM_PER_INCH;
I used them as abstraction hints for an API call to position data matrix
and other stuff by relative metric measurements. Example:
pdf.addDataMatrix(srcDoc, page, "Sometext", 87 * POINTS_PER_MM, PAGE_H - 60
* POINTS_PER_MM - DM_H_ABS, 1f);
This for example would mean that the text had to be positioned
87millimeters from the left hand side and 60 millimeters from the top of
the page minus the expected height of the data matrix. It allows the user
of the API to directly use typical CI/CD guideline measurements in metric
format, while the drawImage() method of the PDPageContentStream object
inside PDFBox always expects points in floats as input.
Your mileage might vary on this level of abstraction. I found them to be
very useful and certainly wished that those be accessible via public
interface instead inside PDFBox.
Cheers
Roberto
Re: PDRectangle.java and POINTS_PER_INCH
Posted by Gilad Denneboom <gi...@gmail.com>.
Probably just a type-o. It should be renamed POINTS_PER_MM, which is indeed
2.83465.
On Thu, Feb 18, 2016 at 10:36 PM, Tilman Hausherr <TH...@t-online.de>
wrote:
> Am 18.02.2016 um 10:26 schrieb M. Niedermair:
>
>> Hi developers,
>>
>> it is possible to set POINTS_PER_INCH and MM_PER_INCH from private to
>> public, because you can do it in many conversions and so does not have to
>> redefine.
>>
>
> I could do that, but what would be the javadoc?
>
> POINTS_PER_INCH is really: user space units per inch. (The PDF spec
> mentions that the user space unit is 1⁄72 inch)
>
> but what is MM_PER_INCH ? It is not millimeter per inch, that is 2.54.
>
> 1 / (10 * 2.54f) * POINTS_PER_INCH = 2.83. I wonder what this is - maybe
> the count of user space units per millimeter?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>
Re: PDRectangle.java and POINTS_PER_INCH
Posted by Tilman Hausherr <TH...@t-online.de>.
Am 18.02.2016 um 10:26 schrieb M. Niedermair:
> Hi developers,
>
> it is possible to set POINTS_PER_INCH and MM_PER_INCH from private to
> public, because you can do it in many conversions and so does not have
> to redefine.
I could do that, but what would be the javadoc?
POINTS_PER_INCH is really: user space units per inch. (The PDF spec
mentions that the user space unit is 1⁄72 inch)
but what is MM_PER_INCH ? It is not millimeter per inch, that is 2.54.
1 / (10 * 2.54f) * POINTS_PER_INCH = 2.83. I wonder what this is - maybe
the count of user space units per millimeter?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org