You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by Craig Ringer <cr...@postnewspapers.com.au> on 2012/03/08 14:50:18 UTC

[PATCH] Overlay.java: support translation, rotation and scaling of overlay

Hi all

As part of some ground-testing work I've been doing for pdf embedding 
enhancements in Apache FOP, I've modified PDFBox's Overlay.java to 
support translation, rotation and scaling of the PDF being overlaid.

This may be a useful feature for PDFBox, so I thought I'd send it in.

Right now it uses the target PDF document's co-ordinate units for 
translations, so it's hard for users to know what translation to specify 
without trial and error. I'm not sure what the best way to remedy this 
is to make for a better user interface, but I suspect that adding the 
ability to set an origin (TL, BL, TR, BR, or center) that'd help. That 
way it's easier for them to say "position the overlay on the top left" 
for example. The actual translation amount could be given as a 
percentage of the target document size in that axis, maybe, or accept 
different unit suffixes like "%" or "cm". I'm not sure what the best 
approach is, and I won't need to explore it for my current project, but 
it should be easy enough to add.

I hope this is useful. If you'd prefer the patch to be added to a 
tracker, let me know.

diffstat:

Overlay.java |  168 
+++++++++++++++++++++++++++++++++++++++++++----------------
  1 file changed, 123 insertions(+), 45 deletions(-)


--
Craig Ringer


POST Newspapers
276 Onslow Rd, Shenton Park
Ph: 08 9381 3088     Fax: 08 9388 2258
ABN: 50 008 917 717
http://www.postnewspapers.com.au/

Re: [PATCH] Overlay.java: support translation, rotation and scaling of overlay

Posted by Craig Ringer <ri...@ringerc.id.au>.
On 14/03/12 15:00, Andreas Lehmkuehler wrote:
> Hi,
>
> Am 14.03.2012 07:33, schrieb Craig Ringer:
>> On 09/03/12 06:08, Andreas Lehmkuehler wrote:
>>>> I hope this is useful. If you'd prefer the patch to be added to a
>>>> tracker, let
>>>> me know.
>>> That would be nice. Please create an issue on JIRA [1] and attach the
>>> patch to it.
>>
>> As requested:
>>
>> https://issues.apache.org/jira/browse/PDFBOX-1254
> You've created a duplicate issue PDFBOX-1255, I guess by accident.
> I've closed PDFBOX-1254 as you attached your patch to PDFOX-1255.

Yeah, I got an error from JIRA saying that "The JIRA server could not be
contacted, please try again in a few seconds". I guess it must've posted
the create request fine but never received a reply confirming success.

--
Craig Ringer

Re: [PATCH] Overlay.java: support translation, rotation and scaling of overlay

Posted by Andreas Lehmkuehler <an...@lehmi.de>.
Hi,

Am 14.03.2012 07:33, schrieb Craig Ringer:
> On 09/03/12 06:08, Andreas Lehmkuehler wrote:
>>> I hope this is useful. If you'd prefer the patch to be added to a
>>> tracker, let
>>> me know.
>> That would be nice. Please create an issue on JIRA [1] and attach the
>> patch to it.
>
> As requested:
>
> https://issues.apache.org/jira/browse/PDFBOX-1254
You've created a duplicate issue PDFBOX-1255, I guess by accident. I've closed 
PDFBOX-1254 as you attached your patch to PDFOX-1255.


> I've also just pushed another change up to JIRA, which will be used as
> the base for fixing up how Overlay.java changes clashing names in
> reference dictionaries (and the associated content stream). I'll then be
> using the same new code in fop-pdf-image for Apache FOP. The proposed
> change is here:
>
> https://issues.apache.org/jira/browse/PDFBOX-1256
I already had a quick look, seems to be a lot of stuff.

> Expect another patch that makes Overlay.java handle resource dict
> renaming more safely in a while.
+1

Thanks for your contribution!

> --
> Craig Ringer

BR
Andreas Lehmkühler

Re: [PATCH] Overlay.java: support translation, rotation and scaling of overlay

Posted by Craig Ringer <ri...@ringerc.id.au>.
On 09/03/12 06:08, Andreas Lehmkuehler wrote:
>> I hope this is useful. If you'd prefer the patch to be added to a
>> tracker, let
>> me know.
> That would be nice. Please create an issue on JIRA [1] and attach the
> patch to it.

As requested:

https://issues.apache.org/jira/browse/PDFBOX-1254

I've also just pushed another change up to JIRA, which will be used as
the base for fixing up how Overlay.java changes clashing names in
reference dictionaries (and the associated content stream). I'll then be
using the same new code in fop-pdf-image for Apache FOP. The proposed
change is here:

https://issues.apache.org/jira/browse/PDFBOX-1256

Expect another patch that makes Overlay.java handle resource dict
renaming more safely in a while.

--
Craig Ringer

Re: [PATCH] Overlay.java: support translation, rotation and scaling of overlay

Posted by Andreas Lehmkuehler <an...@lehmi.de>.
Am 08.03.2012 14:50, schrieb Craig Ringer:
> Hi all
>
> As part of some ground-testing work I've been doing for pdf embedding
> enhancements in Apache FOP, I've modified PDFBox's Overlay.java to support
> translation, rotation and scaling of the PDF being overlaid.
I had a quick look and it looks good to me.

> This may be a useful feature for PDFBox, so I thought I'd send it in.
Thanks!!

> Right now it uses the target PDF document's co-ordinate units for translations,
> so it's hard for users to know what translation to specify without trial and
> error. I'm not sure what the best way to remedy this is to make for a better
> user interface, but I suspect that adding the ability to set an origin (TL, BL,
> TR, BR, or center) that'd help. That way it's easier for them to say "position
> the overlay on the top left" for example. The actual translation amount could be
> given as a percentage of the target document size in that axis, maybe, or accept
> different unit suffixes like "%" or "cm". I'm not sure what the best approach
> is, and I won't need to explore it for my current project, but it should be easy
> enough to add.
>
> I hope this is useful. If you'd prefer the patch to be added to a tracker, let
> me know.
That would be nice. Please create an issue on JIRA [1] and attach the patch to it.

> diffstat:
>
> Overlay.java | 168 +++++++++++++++++++++++++++++++++++++++++++----------------
> 1 file changed, 123 insertions(+), 45 deletions(-)
>
>
> --
> Craig Ringer
>
>
> POST Newspapers
> 276 Onslow Rd, Shenton Park
> Ph: 08 9381 3088 Fax: 08 9388 2258
> ABN: 50 008 917 717
> http://www.postnewspapers.com.au/

Thanks again for your contribution!

BR
Andreas Lehmkühler

[1] https://issues.apache.org/jira/browse/PDFBOX