Where is the Origin (x,y) of a PDF page?

前端 未结 2 749
执念已碎
执念已碎 2020-12-03 13:02

I am using iText to create my PDF files.

I want to position text at some specific place in the document using the method I found here:

2条回答
  •  渐次进展
    2020-12-03 13:28

    Please note that in most PDF generators, PDF page origin is from the left bottom (0,0).

    1 inch = 72 points and 1 cm = 1/2.54 inch = 0.3937 inch = 28.3 points.
    where,
    (lower left x coordinate)l l x=margin from left.
    (lower left y coordinate)l l y=margin from bottom(bottom of rectangle)
    (upper right x coordinate)u r x=width of article
    (upper right y coordinate)u r y=margin from bottom of upper boundary of article.
    

    To draw a Rectangle in PDF, using such generators, which contain A-4 size pages then, you need to define Rectangle as:

    rectangle = new Rectangle(25, 25, 575, 820);
    rectangle. set Border(Rectangle.BOX);
    rectangle. set Border Width(1);
    document.add(rectangle);
    

提交回复
热议问题