I am attempting to rotate text stamps to either 90, 180, or 270 degree angles. While all other operations on the TextStamp object seem to work as expected, the rotation is rotating the entire page, and the text stamp seems to stay the same. I tried a few different combinations of values and rotation functions (setRotate, setRotateAngle) and none seemed to work.
protected static void addWordToTextLayer(
com.aspose.pdf.Page targetPage,
Word word
) {
TextStamp textStamp = new TextStamp( word.getWd()+" " );
textStamp.getTextState().setFontSize( 12 );
textStamp.getTextState().setInvisible( true );
textStamp.setOpacity( 0 );
textStamp.setXIndent( 250 );
textStamp.setYIndent( 250 );
textStamp.setRotate( Rotation.on90 );
// textStamp.setRotateAngle(90 );
targetPage.addStamp(textStamp);
}
Version number appears to be 21.10. I also tried upgrading to 23.7 and this issue still remained.
@Cameron_G
Would you kindly share the sample PDF document for our reference so that we can also test the scenario in our environment to replicate the issue and address it accordingly?
@asad.ali
It seems to be with any PDF, but here’s two I encountered it with
ocr.pdf (16.9 KB)
poc.pdf (40.7 KB)
@Cameron_G
Please check the attached output generated in our environment using Aspose.PDF for Java 23.7 and the below code snippet:
TextStamp textStamp = new TextStamp("Aspose.PDF for Java 23.7");
textStamp.getTextState().setFontSize( 12 );
textStamp.setOpacity( 0.5 );
textStamp.setXIndent( 250 );
textStamp.setYIndent( 250 );
textStamp.setRotate( Rotation.on90 );
Document doc = new Document(dataDir + "ocr.pdf");
doc.getPages().get_Item(1).addStamp(textStamp);
doc.save(dataDir + "stamped.pdf");
stamped.pdf (18.1 KB)
After looking into this more, it turns out the issue happened somewhere else in the process, outside of this library. Using your example I confirmed this part is working correctly. Sorry and thank you.
@Cameron_G
It is nice to know that your issue has been resolved. Please keep using our API and feel free to create a new topic in case you face any issues.