I'm happy to answer just about anything ;). The PDF coordinate system is a full Cartesian coordinate system with the standard origin at (0,0) BUT you can transform that any way that you'd like.
As Mark said, I've seen all sorts of strange coordinate systems on PDFs - origins in negative space (like this one), scaling values by 14400 (can you say "twips"?!?!), etc. That's one beauty (and difficulty) of PDF... Leonard -----Original Message----- From: Lloyd [mailto:lloydgold2...@gmail.com] Sent: Thursday, October 08, 2009 7:48 AM To: itext-questions@lists.sourceforge.net Subject: Re: [iText-questions] Acro form positioning + margins Thanks for your reply, I feel like a complete idiot. I was using the Rectangle's (MediaBox) constant LEFT and BOTTOM to get the left and bottom positioning, NOT getLeft(), getBottom(). I have everything working correctly now. I still have one question though. Why are the coordinates on the MediaBox negative? If 0,0 is the bottom left of a PDF document, then shouldn't the MediaBox be positive since it's +46 from the left, and +31 from the bottom? To get my coordinates to work I made the numbers positive and added them onto my calculation, but I was hoping for a better explanation on why this is happening or if I'm miss understanding something so I don't come across a document in the future that messes it all up. Thanks again Leonard for the help, even if you don't feel like answering this question. Leonard Rosenthol-3 wrote: > > Are you assuming that the origin is (0,0)? If so, that's your problem. > The origin of page 1 of that document is (-46.4879, -31.968). Perhaps > that > is why you are seeing the offset?? > > Get the values for the MediaBox of the page - that's what you need to use > as > your relative origin for the page and the field coordinate. > > Leonard > > > On 10/7/09 8:27 PM, "Lloyd" <lloydgold2...@gmail.com> wrote: > >> >> Okay, hopefully this will explain it a little better. For testing, I'm >> using >> the PDF document http://www.irs.gov/pub/irs-pdf/fw9.pdf -- Here is an >> image >> I made to better explain what I'm doing: >> http://img64.imageshack.us/img64/2097/pdf.png >> >> Now, The blue box is where that field should be (you can check on the >> main >> PDF), I also put the white spacing I'm talking about, along with a red >> border around the part of the PDF that isn't in the white spacing. >> (Pulling >> a PDF into Photoshop, or opening it in Adobe Reader and "remove white >> margins" removes everything on the outside of the red border). >> >> Now the green box is 30 points to where the field is supposed to be in >> terms >> of left on the field position. The yellow is 65 which would include the >> white spacing. Now for some reason, that field, iText is giving me a >> position of left: 23.690000534057617 / bottom: 651.7000122070312 >> >> Is there something I'm doing wrong that I'd get these positions? I'm >> using >> getFieldPositions to figure out the positions of the fields. >> >> Thanks Leonard for your time, if I sound confusing let me know and I'll >> try >> to explain a bit better. I know there is no such thing as "margins" in >> PDF's, I was hoping that the red border is a box (see image), but >> getCropBox() is returning the pages width/height (611x791) which I'm >> guessing is because there isn't a cropbox so it's defaulting to the page >> size. >> >> >> Leonard Rosenthol-3 wrote: >>> >>> I don't know where you heard that "positioning is relative to >>> whitespace" >>> - that is simply NOT TRUE. >>> >>> All coordinates in the PDF are relative to the origin of the MediaBox of >>> the page. PERIOD. >>> >>> That said - if the page has no CropBox then everything is perfect and no >>> problems. >>> >>> HOWEVER, when the page HAS a CropBox (which impacts the VISUAL DISPLAY >>> but >>> not the coordinates) then you need to be sure to adjust your coordinates >>> relative to the new coordinate system. >>> >>> Leonard >>> >>> -----Original Message----- >>> From: Lloyd [mailto:lloydgold2...@gmail.com] >>> Sent: Wednesday, October 07, 2009 2:48 PM >>> To: itext-questions@lists.sourceforge.net >>> Subject: [iText-questions] Acro form positioning + margins >>> >>> >>> Hello, >>> >>> I'm writing an application that grabs the field positions in a PDF. I >>> noticed that the positioning of these (LEFT, BOTTOM) are relative to the >>> white spacing in a PDF. Now, from what I've read on the mailing list, >>> there >>> is no such things as margins. I've noticed that when loading the PDF up >>> in >>> a >>> program like Photoshop, the spacing disappears, while if I load the PDF >>> up >>> in Adobe Reader, or I capture an image of it in GhostScript the spacing >>> is >>> there. >>> >>> My question is, is there anyway to get the spacing details? Is the >>> "content" >>> inside some kind of rectangle box so I can figure out the spacing? >>> >>> The reason I want this is I'm converting the field positions to pixels, >>> and >>> placing them over an image of the PDF. This image will contain the white >>> spacing and I need these numbers to position the fields correctly. >>> >>> The only option I've come up with is to get the width of the PDF with >>> the >>> spacing, then use a program like GhostScript to generate the PDF with no >>> margin at all, and then compare the width/height to get the spacing. I'm >>> hoping there is an easier way. >>> >>> If anyone has any suggestions it would be greatly appreciated. Thanks in >>> advanced. >>> -- >>> View this message in context: >>> http://www.nabble.com/Acro-form-positioning-%2B-margins-tp25795037p25795037.h >>> tml >>> Sent from the iText - General mailing list archive at Nabble.com. >>> >>> >>> > ----------------------------------------------------------------------------->> > - >>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >>> is the only developer event you need to attend this year. Jumpstart your >>> developing skills, take BlackBerry mobile applications to market and >>> stay >>> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >>> http://p.sf.net/sfu/devconference >>> _______________________________________________ >>> iText-questions mailing list >>> iText-questions@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/itext-questions >>> >>> Buy the iText book: http://www.1t3xt.com/docs/book.php >>> Check the site with examples before you ask questions: >>> http://www.1t3xt.info/examples/ >>> You can also search the keywords list: >>> http://1t3xt.info/tutorials/keywords/ >>> >>> > ----------------------------------------------------------------------------->> > - >>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >>> is the only developer event you need to attend this year. Jumpstart your >>> developing skills, take BlackBerry mobile applications to market and >>> stay >>> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >>> http://p.sf.net/sfu/devconference >>> _______________________________________________ >>> iText-questions mailing list >>> iText-questions@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/itext-questions >>> >>> Buy the iText book: http://www.1t3xt.com/docs/book.php >>> Check the site with examples before you ask questions: >>> http://www.1t3xt.info/examples/ >>> You can also search the keywords list: >>> http://1t3xt.info/tutorials/keywords/ >>> >>> > > -- > Leonard Rosenthol > PDF Standards Architect > Adobe Systems > > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > iText-questions mailing list > iText-questions@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/itext-questions > > Buy the iText book: http://www.1t3xt.com/docs/book.php > Check the site with examples before you ask questions: > http://www.1t3xt.info/examples/ > You can also search the keywords list: > http://1t3xt.info/tutorials/keywords/ > > -- View this message in context: http://www.nabble.com/Acro-form-positioning-%2B-margins-tp25795037p25803230.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/ ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/