On 27/07/2011 18:04, Jason Berk wrote: > I change page margins in the onEndPage event, so the changes will affect > the next page. > > When I add my table to the document via doc.add(myTable), the new > margins are respected and my PDF looks great. What's funny is that if > use doc.bottomMargin(), I get back the wrong size. In other words, the > correct margins are being used by doc.add(), but not returned via the > getters. > > Anybody else ever seen this Whether it's a bug or not... that's debatable. In any case: the reason for this behavior is clear.
When you create a Document object, you don't indicate that you want to produce PDF. In the past, you could create a Document object to create RTF, HTML, PDF... It isn't up until you create a PdfWriter that you're actually creating a PDF document. You aren't limited to creating just one PDF document from one Document object. You can create different PdfWriter instances for the same document. For instance: to simultaneously create one PDF that is stored on disk and one PDF that is sent to a browser. (Warning: don't use ColumnText when you do this; don't use direct content either.) You are using page events. Page events are linked to one (and only one) PdfWriter instance. You have access to a Document object in the event's methods. HOWEVER (as documented in the book), this Document object IS NOT the original Document object you created. Instead it's an instance of the PdfDocument class that is created for INTERNAL use. As explained in the book, you should use this PdfDocument object for READ-ONLY purposes. You shouldn't add any content to this object, nor should you change the margins! If you do, you'll experience strange side-effects. Hope this helps. ------------------------------------------------------------------------------ Got Input? Slashdot Needs You. Take our quick survey online. Come on, we don't ask for help often. Plus, you'll get a chance to win $100 to spend on ThinkGeek. http://p.sf.net/sfu/slashdot-survey _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net 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