It's probably missing a PdfReader.getCropboxWithRotation() or a generalization for any box.
Paulo > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Alex > Sent: Monday, March 26, 2007 10:43 AM > To: Post all your questions about iText here > Subject: Re: [iText-questions] PDFReader GetCropBox > > 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/ > Aviso Legal: Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem. Disclaimer: This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message. ------------------------------------------------------------------------- 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/
