问题
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.
回答1:
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);
来源:https://stackoverflow.com/questions/39031462/set-8-1-2-x-12-itext-page-size