When I run the following code and print the resulting PDF file (using Acrobat Reader 
5.1) I expect to get a rectangle 4 inches wide by 5 inches high spaced 1 inch from the 
bottom left margin.

Instead I get a rectangle that is about 3.75 inches wide by 4.68 inches high. Also, 
the rectangle is spaced about 1.18 inches from the left margin and 1.31 inches from 
the bottom margin.  What is the reason for this?  Is the PDF format not this accurate? 
 Is this an Acrobat issue?  Is it an itext issue?

I would appreciate any assistance offered.

Thanks,

Michael L. Gantz



import java.io.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;

public class Test {

    public static float toPoints(double inches) {
        return(float) (inches * 72.0);
    }

    public static void main(String args[]) {

        try {
            FileOutputStream fos;
            Document         document;
            PdfWriter        writer;
            PdfContentByte   cb;
            Rectangle        pageSize;

            fos      = new FileOutputStream("test.pdf");
            pageSize = new Rectangle(toPoints(8.5), toPoints(11.0));
            document = new Document(pageSize);

            writer = PdfWriter.getInstance(document, fos);

            document.open();

            cb = writer.getDirectContent();

            cb.rectangle(toPoints(1.0), toPoints(1.0), 
                         toPoints(4.0), toPoints(5.0));
            cb.stroke();
            document.close();
        } catch(Throwable t) {
            t.printStackTrace();
        }
    }
}





-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to