pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: AffineTransform
Date Thu, 06 Dec 2018 18:07:09 GMT
Am 06.12.2018 um 18:57 schrieb Mark Gargan:
> Just in case, the final values that seemed to have done the trick are
>
> AffineTransform at = new AffineTransform(576, 0, 0, 811, 31, 48);
>
> That scales and centres an A4 image(2480X2508) within the centre of an SRA3 document
(8.86 X 12.6 inches)
>
> I appreciate any help I was hoping I could've been able to solve it mathematically so
that I could apply it to other document sizes if necessary.


The scale I answered; how to get the center - first getMediaBox() of 
your target PDF page. Calculate the sizes (vertical and horizontal). 
Substract the respective image size (after the scale!!!), divide by two, 
and that is the translation offset.


(It gets more tricky if your target PDF page has a cropbox... then you'd 
have to add the cropbox x y coordinates)

Tilman


>
> Thanks,
> Mark.
>
> -----Original Message-----
> From: Mark Gargan [mailto:mark.gargan@aviva.com]
> Sent: 06 December 2018 17:34
> To: users@pdfbox.apache.org
> Subject: RE: AffineTransform
>
> And apologies Tilman,
> I'm using PDFBox 2.0.3 and the question about the AffineTransformation was asked the
wrong way, it was more a question as to why the signature would be that way as it doesn't
make intuitive sense to me. Perhaps it's something to do with the structure of the 3x3 matrix??
>
> Thanks,
> Mark.
>
> -----Original Message-----
> From: Tilman Hausherr [mailto:THausherr@t-online.de]
> Sent: 06 December 2018 17:15
> To: users@pdfbox.apache.org
> Subject: Re: AffineTransform
>
> Hi,
>
> You didn't upload the PDF, attachments don't go through.
>
> Please mention what PDFBox version you are using (hopefully 2.0.13) and include your
code. I assume you want to draw an image. If you would use
>
> 2480 0 0 3508 0 0
>
> Then the image would appear at the original size. So 700 0 0 700 x y will have a weird
effect.
>
> The coordinates start at the bottom left.
>
> "it's quite unintuitive to place two shearing factors between two scaling" complain to
the designers of the java language :-) Tilman
>
> Am 06.12.2018 um 17:55 schrieb Mark Gargan:
>> Hi folks,
>>
>>               I'm trying to work with the Affine transform to superimpose a snapshot
of an A4 document into an SRA3 document which has crop lines.
>>
>> The SRA3 template size is or  (8.86in x 12.6in) in inches. The original A4 document
I'm taking the snapshot of is typical A4 ( 8.27in × 11.69in).
>>
>> I've taken a snapshot of the first page of the A4 original document and it produces
an image in typical A4 size 2480 X 3508 pixels.
>>
>> I'm trying to figure out the AffineTransform that will place the A4 snapshot into
the centre of the SRA3 document and within the croplines.
>>
>> So far I have
>>
>> AffineTransform at = new AffineTransform(700, 0, 0, 700, 100, 200);
>>
>> with the Affine constructor as follows
>>
>>
>> *
>> * @param m00 the X coordinate scaling element of the 3x3 matrix
>> * @param m10 the Y coordinate shearing element of the 3x3 matrix
>> * @param m01 the X coordinate shearing element of the 3x3 matrix
>> * @param m11 the Y coordinate scaling element of the 3x3 matrix
>> * @param m02 the X coordinate translation element of the 3x3 matrix
>> * @param m12 the Y coordinate translation element of the 3x3 matrix
>> * @since 1.2
>> */
>> @ConstructorProperties({ "scaleX", "shearY", "shearX", "scaleY",
>> "translateX", "translateY" }) public AffineTransform(float m00, float m10,
>>                          float m01, float m11,
>>                          float m02, float m12) {
>>
>> I.e. x-scaling, y-shearing, x-shearing, y-scaling, x-translation,
>> y-translation
>>
>> I guess the questions are
>>
>>
>>     1.  Why the signature was presented like this, it's quite unintuitive to place
two shearing factors between two scaling.
>>     2.  Also I can't understand why the x & y scaling factors need to be in the
hundreds. i.e. 700 and 700
>>     3.  The translation factors, are they taken from the top right of the image/object
being imported or from the centre?
>>
>> Thanks in advance for any help folks,
>> Mark.
>>
>>
>>
>>
>> Aviva Insurance Limited, trading as Aviva, is authorised by the Prudential Regulation
Authority in the UK and is regulated by the Central Bank of Ireland for conduct of business
rules.
>>
>> Registered Branch Office in Ireland No 900175, Registered Branch Address One Park
Place, Hatch Street, Dublin 2. Registered in Scotland No 2116. Registered Office Pitheavlis,
Perth, PH2 0NH.
>>
>> Aviva Direct Ireland Limited is regulated by the Central Bank Of Ireland. A private
company limited by shares. Registered in Ireland No 374895. Registered Office One Park Place,
Hatch Street, Dublin 2.
>>
>> Aviva Life & Pensions UK Limited, trading as Aviva Life & Pensions Ireland,
is authorised by the Prudential Regulation Authority in the UK and is regulated by the Central
Bank of Ireland for conduct of business rules.
>>
>> Aviva Life & Pensions UK Limited, trading as Aviva Life & Pensions Ireland,
is also regulated in the UK: by the Prudential Regulation Authority for prudential rules and,
to a limited extent, by the Financial Conduct Authority for applicable UK conduct rules.
>> Registered Branch Office in Ireland (No 906464) at One Park Place,
>> Hatch Street, Dublin 2. Registered in England (3253947) at Wellington
>> Row, York, YO90 1WR
>>
>> Aviva Life Services Ireland Limited is regulated by the Central Bank Of Ireland.
A private company limited by shares. Registered in Ireland No 406616. Registered Office One
Park Place, Hatch Street, Dublin 2.
>>
>>
>> www.aviva.ie
>>
>> The information transmitted is intended only for the person or entity to which it
is addressed and may contain confidential and/or privileged material. Any review, retransmission,
dissemination or other use of, or taking of any action or reliance upon this information by
persons or entities other than the intended recipient is prohibited. If you received this
in error, please contact the sender and delete the material from your computer.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
> Aviva Insurance Limited, trading as Aviva, is authorised by the Prudential Regulation
Authority in the UK and is regulated by the Central Bank of Ireland for conduct of business
rules.
>
> Registered Branch Office in Ireland No 900175, Registered Branch Address One Park Place,
Hatch Street, Dublin 2. Registered in Scotland No 2116. Registered Office Pitheavlis, Perth,
PH2 0NH.
>
> Aviva Direct Ireland Limited is regulated by the Central Bank Of Ireland. A private company
limited by shares. Registered in Ireland No 374895. Registered Office One Park Place, Hatch
Street, Dublin 2.
>
> Aviva Life & Pensions UK Limited, trading as Aviva Life & Pensions Ireland, is
authorised by the Prudential Regulation Authority in the UK and is regulated by the Central
Bank of Ireland for conduct of business rules.
>
> Aviva Life & Pensions UK Limited, trading as Aviva Life & Pensions Ireland, is
also regulated in the UK: by the Prudential Regulation Authority for prudential rules and,
to a limited extent, by the Financial Conduct Authority for applicable UK conduct rules.
> Registered Branch Office in Ireland (No 906464) at One Park Place, Hatch Street, Dublin
2. Registered in England (3253947) at Wellington Row, York, YO90 1WR
>
> Aviva Life Services Ireland Limited is regulated by the Central Bank Of Ireland. A private
company limited by shares. Registered in Ireland No 406616. Registered Office One Park Place,
Hatch Street, Dublin 2.
>
>
> www.aviva.ie
>
> The information transmitted is intended only for the person or entity to which it is
addressed and may contain confidential and/or privileged material. Any review, retransmission,
dissemination or other use of, or taking of any action or reliance upon this information by
persons or entities other than the intended recipient is prohibited. If you received this
in error, please contact the sender and delete the material from your computer.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
> Aviva Insurance Limited, trading as Aviva, is authorised by the Prudential Regulation
Authority in the UK and is regulated by the Central Bank of Ireland for conduct of business
rules.
>
> Registered Branch Office in Ireland No 900175, Registered Branch Address One Park Place,
Hatch Street, Dublin 2. Registered in Scotland No 2116. Registered Office Pitheavlis, Perth,
PH2 0NH.
>
> Aviva Direct Ireland Limited is regulated by the Central Bank Of Ireland. A private company
limited by shares. Registered in Ireland No 374895. Registered Office One Park Place, Hatch
Street, Dublin 2.
>
> Aviva Life & Pensions UK Limited, trading as Aviva Life & Pensions Ireland, is
authorised by the Prudential Regulation Authority in the UK and is regulated by the Central
Bank of Ireland for conduct of business rules.
>
> Aviva Life & Pensions UK Limited, trading as Aviva Life & Pensions Ireland, is
also regulated in the UK: by the Prudential Regulation Authority for prudential rules and,
to a limited extent, by the Financial Conduct Authority for applicable UK conduct rules.
> Registered Branch Office in Ireland (No 906464) at One Park Place, Hatch Street, Dublin
2. Registered in England (3253947) at Wellington Row, York, YO90 1WR
>
> Aviva Life Services Ireland Limited is regulated by the Central Bank Of Ireland. A private
company limited by shares. Registered in Ireland No 406616. Registered Office One Park Place,
Hatch Street, Dublin 2.
>
>
> www.aviva.ie
>
> The information transmitted is intended only for the person or entity to which it is
addressed and may contain confidential and/or privileged material. Any review, retransmission,
dissemination or other use of, or taking of any action or reliance upon this information by
persons or entities other than the intended recipient is prohibited. If you received this
in error, please contact the sender and delete the material from your computer.
>
> ---------------------------------------------------------------------
> 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


Mime
View raw message