2-----------1
|                        |
|                        |        
|                        |               --> reader.getPageRotation (i2)
== 0
|                        |
3---------------4

3-----------------2        
|                                    |               -->
reader.getPageRotation (i2) == 90
|                                    |
4-----------------------1

1-----------------4        
|                                    |               -->
reader.getPageRotation (i2) == 270
|                                    |
2-----------------------3

These rectangles represent PDF pages according to their rotation and how
positions shift, in order for stamps to be correctly placed. It seem
that coordinates are always referenced without taking rotation into
account. (that is, for instance, for both figure #1 & #2 origin is left
bottom corner).

Stamp's to be placed in right top corner.

Without rotation, there's no problem:
 
*int valorx =180;
int valory =180;*
*imagen.setAbsolutePosition(rect2.right() -valorx,rect2.top() - valory );*

(valorx and valory are constants).

If there's a 90 deg. rotation, stamp should be placed where corner 2 is
in figure 2 (notice the swap between coordinates x and y of top value):

*imagen.setAbsolutePosition(rect2.top() - valory,rect2.left() -valorx );*

If there's a 270 deg. rotation, stamp should be placed where corner 4 is
in figure 3 (notice the swap between coordinates x and y of top value).
The key here is that, once more, origin is left bottom corner. This is
important, because of the following:

2                    1
+--------------------+
|                    |
|                    |
|  +----------+      |
|  |         *|      |
|  +----------+      |
|                    |
+--------------------+
3                    4

If you rotate 90,  the largest size would be 2 units far from y axis.
That is, rotated-left=left. But if you rotate 270, largest size would be
4 units far from y axis. Hence, you have to substract the real (full)
page size to get it placed in right position.
*

imagen.setAbsolutePosition(rect2.bottom() - valory, rect2.right() -valorx );
imagen.setAbsolutePosition(reader.getPageSize(i2).height() - 
rect2.bottom() - valory, rect2.right() -valorx );
*
As you can see, this is a bit messy, but it's been the only way we've
found to get always the stamp in desired position. The main problem is
to reference where clipped rectangle is with respect of real rectangle.

Could anyone figure out a cleanest solution?

Thanks in advance.

Bruno Lowagie escribió:
> Alejandro wrote:
>   
>> PDFReader.GetCropBox method gives real and cropped horizontal and 
>> vertical dimensions, but it appearently doesn't provide information on 
>> relative position of cropped frame.
>>     
>
>   
>> imagen.setAbsolutePosition(rect2.height(),rect2.width());
>>     
>
> You are asking rect2 for its height and width...
> I don't understand this. X and Y seem to be switched,
> and why not use something like this:
>
> imagen.setAbsolutePosition(rect2.left(), rect2.bottom());
>
> I may have misinterpreted your question, but please
> have a look at the API of class Rectangle and I'm sure
> you'll find some useful methods you haven't tried yet.
> br,
> Bruno
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> Buy the iText book: http://itext.ugent.be/itext-in-action/
>
>
>   


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to