Hi,

First of all, thanks for all your efforts with iText, it is a really useful 
package! 

My question is...I want to create a Document instance with the page size and 
margins based on a PageFormat object (which I'm retrieving from a page setup 
dialog).  I've written the following code which seems like a lot of effort, 
so I wondered if there is a better way (I've only recently started using 
iText so I might have missed something):

        float urx = (float)this.pageFormat.getWidth();
        float ury = (float)this.pageFormat.getHeight();

        float marginLeft = (float)this.pageFormat.getImageableX();
        float marginRight = (float)(this.pageFormat.getWidth() 
-this.pageFormat.getImageableWidth() -this.pageFormat.getImageableX());
        float marginTop = (float)this.pageFormat.getImageableY();
        float marginBottom = (float)(this.pageFormat.getHeight() 
-this.pageFormat.getImageableHeight() -this.pageFormat.getImageableY());
        Rectangle pageSize = new Rectangle(urx, ury);

        try {
            this.document = new Document(pageSize, marginLeft, marginRight,
                                                   marginTop, marginBottom);
         ...etc.

If there isn't a better way to do this, would it be possible (well, I'm sure 
it is possible but is it a good idea?) to implement a new constructor for the 
Document class that accepts a PageFormat parameter and does the work for me.

Regards,

Dave Gilbert
http://www.jrefinery.com

_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to