I did not know that. Thanks for the explanation.

My code works perfectly now. :)
-Chip

From: Mark Storer [mailto:[email protected]]
Sent: Tuesday, March 22, 2011 3:01 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Mismatch between coordinates and viewable text

The pages has both media and crop boxes.

Media Box (the "normal" one): 0, 0, 595, 842
Crop Box (clips the media box): 0, 24, 595, 817

Odd, but perfectly legal.  8.26" x 11.01".  Might make more sense in metric, 
dunno.

Anyway, the visible page depends entirely on the CROP box.  The default value 
of the crop box if it isn't present is the media box.

Never assume the lower left corner is 0,0, even when there's no media box.  
It's perfectly legal to put 0,0 in the center of the page, or sail off into the 
furthest reaches of the coordinate system if you're so inclined.  [-200, -250, 
200, 250] is perfectly legal, as is [1000, 1000, 1595, 1817], just to pull some 
examples out of thin air.

Moral:  Check the crop box's lower left corner.

Oh, and don't forget that page's can be rotated too.  That's always fun.

--Mark Storer
  Senior Software Engineer
  Cardiff.com

import legalese.Disclaimer;
Disclaimer<Cardiff> DisCard = null;



________________________________
From: Chip Whitmer [mailto:[email protected]]
Sent: Tuesday, March 22, 2011 1:19 PM
To: Post all your questions about iText 
here([email protected])
Subject: [iText-questions] Mismatch between coordinates and viewable text
I'm using iText-5.0.2 for Java. I have attached the original and result for a 
PDF document that was modified using PdfStamper. In the lower-left corner of 
each page, you can see a series of coordinates displayed.

The code is simple:

                                PdfContentByte page = stamper.getOverContent( 
pageNum );
                                page.beginText();
                                for( int i = 0 ; i < 100 ; i += 10)
                                {
                                                page.showTextAligned( 
Element.ALIGN_LEFT, "[" + i + "," + i + "]", i, i, 0 );
                                }
                                page.endText();

Note that the first coordinates that you can see in the lower-left are [20, 20] 
(and you can see only the top half of this string). Apparently the text written 
at [0, 0] and [10, 10] is actually being written outside of the page boundaries.

I thought [0, 0] was the "origin" for the drawing grid - the point at the 
bottom-left corner of the page. But if this is true, then I would expect text 
written at [0, 0] to be visible.

If [0, 0] is not the viewable origin, then how can I know what value to use for 
the Y-coordinate, to ensure that the resulting text visible on the page?

Thanks,
-Chip Whitmer
  Service Repair Solutions, Inc.

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to