We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

TextBoxField not same position while page rotated

Hi,
we use some code for placing a TextBoxField on a page. We found out, that when the page has been originally scanned with a different rotation, the location of our TextBoxField is not the same on the resulting pdf. Is there a possibilty to guarantee the same location. I tried with following code. As log as rotateFactor is 0, the TextBoxField is on the correct location. But when it is 3, the location is changed.
It seems I should set the rectangle2 values with some diplacement from the original textBoxField1 rectangle values. Do you have some algorithm for calculating the new position?

int rotateFactor = pdfPage.getRotate();
TextBoxField textBoxField1 = new TextBoxField(pdfPage, new Rectangle(annotationen.getLeft() * 72 + getCorrMarginLeft()
        , hight - annotationen.getTop() * 72 - annotationen.getHeight() * 72 - getCorrHeight()
        , annotationen.getLeft() * 72 + (annotationen.getWidth() * 72) + getCorrWidth()
        , hight - annotationen.getTop() * 72 + getCorrMarginBottom()));

if (rotateFactor > 0) {
       Rectangle rectangle2 = textBoxField1.getRectangle(false);
       rectangle2.setLLX(textBoxField1.getRect().getLLX());
       rectangle2.setLLY(textBoxField1.getRect().getLLY());
       rectangle2.setURY(textBoxField1.getRect().getURY());
       rectangle2.setURX(textBoxField1.getRect().getURX());
       rectangle2.rotateAngle(rotateFactor*90);
       textBoxField1.setRect(rectangle2);
       textBoxField1.getCharacteristics().setRotate(rotateFactor);
}

@igor.berchtold

While getting the rectangle property of any object in a rotated PDF Page, please use the constructor as below to consider the rotation and get respective values:

annotation.getRectangle(true);

However, if issue still persists, please share complete sample code snippet along with sample PDF document so that we can try to replicate the scenario in our environment and address it accordingly.

Hi Ali, thank your for your response. I tried this but it does not help in my case. I was able to write you a reproducer. Page 1 is correct, the textbox is on the right place. Page 2 is 90 degree rotated and when placing the textbox it is on the wrong place, actually it should be at the same location as on Page 1.
I would be very glad if you can help me out with this problem.

best regards,
IgorAsposeAnnotationen.zip (702.4 KB)

@igor.berchtold

We were able to reproduce the similar issue in our environment. Therefore, it has been logged as PDFJAVA-41175 in our issue tracking system. We will further look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.

We are sorry for the inconvenience.