Set 8 1/2“ x 12” itext page size [duplicate]

2020-08-02 02:54发布

I am using itext PDF, and I need to set PDF document size as German Std. Fanfold(8 1/2" x 12"),I don't know how set Inches In Itext document.

// Now I can set paper size as A4 but i need to set 8 1/2" x 12" or German Std. Fanfold size 
document(name: fileName,pageSize: PageSize.A4,leftMargin:8, rightMargin:8, topMargin:8, bottomMargin:3)

Thanks in advance.

标签: itext
1条回答
爷的心禁止访问
2楼-- · 2020-08-02 03:26

Please do yourself a favor and read the documentation!

As explained in the Getting started section, measurements are expressed in user units, and there are 72 user units in an inch, so:

8.5 inch x 72 points = 612 user units
12 inch x 72 points = 861 user units

So you need to create a rectangle like this:

Rectangle pagesize = new Rectangle(612, 861);

and a document like this:

Document document = new Document(pagesize);
查看更多
登录 后发表回答