Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

[iText-questions] Margin Trouble

Michael McCall

2007-07-31

Replies:

To Whom It May Concern:

 

I am currently developing a web application that uses Spring Framework and iText to take in values (through a series of forms) and generate a PDF from them.

I want the PDF to have specific margins (90, 90, 72, 50).  I have a PDF.java class with the following method in it:

 

protected void buildPdfDocument(Map model, Document document, PdfWriter writer, HttpServletRequest request, HttpServletResponse response) throws Exception

{

            …

}

 

I would use the simple “document.setMargins();” method, but it only takes effect on the second page, and I need the given margins used for the entire output.

 

In the tutorial examples, the first page margins are set with the constructor “new Document(PageSize.A5, 36, 72, 108, 180),” and then “setMargins()” is used for the subsequent pages.  Because of the Spring setup, my Document is actually passed as a parameter, so I never really create it myself.  I did try re-initializing the Document using the aforementioned constructor, but Tomcat would suddenly tell me that “document” had no pages (I tried both re-opening and never opening the Document after re-initialization—neither eliminated the error).

 

Is there another method that will set the current page’s margins?  Or, is there any other way I can affect Spring’s creation of the Document—maybe by altering Spring or iText defaults?

 

Thanks.

 

___________________________

Michael McCall
IT Intern 
T 617.674.6330

M 860.967.6178
mmccall@endeca.com

Endeca
101 Main Street, 14th Floor

Cambridge, MA, 02142
www.endeca.com

find / analyze / understand

 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/
©2008 junlu.com - Jax Systems, LLC, U.S.A.