In PDFBox, how to change the origin (0,0) point of a PDRectangle object?

前端 未结 4 1084

The Situation:
In PDFBox, PDRectangle objects\' default origin (0,0) seems to be the lower-left corner of a page.

For example, the following code gives

4条回答
  •  [愿得一人]
    2020-12-06 02:51

    The following seems to be the best way to "adjust" the TextPosition coordinates:

    x_adjusted =  x_original + page.findCropBox().getLowerLeftX();
    y_adjusted = -y_original + page.findCropBox().getUpperRightY();
    

    where page is the PDPage on which the TextPosition object is located

提交回复
热议问题