Several things come to mind:

1)
Use a PdfGraphics2D from your PdfContentByte.  Java's "Graphics" classes use 
the same sort of coordinate system, and PdfGraphics2D irons out all that for 
you.

Warning: PdfGraphics2D isn't terribly efficient... by necessity.  It takes some 
extra effort to iron out the differences between the Graphics system and PDF.

2)
Use the same trick on the text matrix:

cb.beginText();
cb.setFont( font, pointsize );
for (...) {
  cb.setTextMatrix( textX, textY );
  cb.saveState();
  cb.setTextMatrix( 1, 0, 0, -1, 0, textFont.getAscentPoint(text, fontSize) );
  cb.showText( text );
  cb.restoreState();
}

cb.endText();


I believe this will work, but it's just off the top of my head.  My 
matrix-related code generally needs a few iterations before it'll behave 
properly... Caveat Coedor.

3)
Recalculate your coordinates /for everything/ in advance.  Just change all your 
Y coordinates to "pageHeight - origY" when calling the various PdfContentByte 
functions.  Your rectangles and bounding boxes will all end up with negative 
heights... so you may have to "normalize" them.


I recommend #3.  That's what LiquidOffice does.

4)
Start off with PDF's coordinate system so you don't have to mess around with 
all this stuff.

:\



--Mark Storer 
  Senior Software Engineer 
  Cardiff.com

#include <disclaimer> 
typedef std::Disclaimer<Cardiff> DisCard; 



> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] 
> Behalf Of John
> Duff
> Sent: Tuesday, October 17, 2006 11:47 AM
> To: [email protected]
> Subject: [iText-questions] Document coordinate system
> 
> 
> I'm trying to print some objects I have, but the work on a coordinate
> system that starts in the upper left, not lower left as the pdfWriter
> does by default.  I've looked at the docs and there is an example of
> inverting the coordinates:
> 
> 
> 
> PdfContentByte cb = writer.getDirectContent();
>             cb.concatCTM(1f, 0f, 0f, -1f, 0f, PageSize.A4.height());
> 
> 
> 
> 
> However, this also inverts the text that is printed.  Is there any way
> to invert the coordinates without inverting what is written to the
> pdf?
> 
> 
> 
> Thanks,
> 
> 
> 
> John
> 
> --------------------------------------------------------------
> -----------
> Using Tomcat but need to do more? Need to support web 
> services, security?
> Get stuff done quickly with pre-integrated technology to make 
> your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on 
> Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&;
dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to