pdf-lib
pdf-lib copied to clipboard
Convert pixels in 1/72 inches
What are you working on?
Hi, guys. I am working on documents signature implementation. It have few steps:
- User see PDF file and should tap on the place where signature should be placed. On this step I'm using https://github.com/wonday/react-native-pdf this library to display document and take tap's coordinates.
- After step 1 I navigate user to the screen where he should draw his signature.
- After user draw signature I'm using pdf-lib drawImage() method to sign document.
There is few problems in this approach:
- 0, 0 coordinates from react-native-pdf are in top left corner and as I understand coordinates are in pixels.
- pdf-lib as I found out is using 1/72 inch as measurements units and 0, 0 point is in bottom left corner.
As result I can sign the document but with wrong placement of signature. So I need some way to properly convert coordinates taken from react-native-pdf to coordinates that are used by pdf-lib to place signature. I already tried a lot of variants but no one works fine. In current implementation I'm using formula like this: (pageHeight - signatureCoords.y) / (160 * PixelRatio.get()) / 72 So maybe someone can give me an advice how to properly place signature in PDF?
Additional Notes
No response
Hi, any positive progress with this feature? I'm currently struggling with the same problem
Hi, I'm having the same problem as the first two guys, does anyone have a solution yet?
I am also struggling with the same issue. I want the user to drag an image on the pdf page, and on the confirm button insert the image on that location. I have values in terms of left and right of the absolute positioned image but when they are given as x and y of the drawImage method, it just disappears.