Home:ALL Converter>Converting coordinates from React to iText in Java

Converting coordinates from React to iText in Java

Ask Time:2018-07-26T22:39:24         Author:Amith

Json Formatter

I have a react application which is using pdf.js from mozilla to highlight a word or sentences and add comments to the highlighted section.

They are sending the coordinates of highlighted section into java service. From java side, we are required to do the actual highlighting and adding of comments into the the pdf using iText.

The problem here is that in pdf.js the coordinates are calculated from top-left of the screen (i.e 0,0 starts from top-left of the screen) while in iText the coordinates are calculated from bottom-left of the screen.

So can someone tell me how to map the coordinates given from pdf.js into iText coordinate system as directly using the coordinates passed from UI is not giving the correct highlighted area in pdf?

Author:Amith,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/51541525/converting-coordinates-from-react-to-itext-in-java
yy