Skip to main content
Known Participant
Feb 24, 2023 9:56 AM UTC
Question

Converting PDF user units in PDF Extract API's output to browser compatible pixel values

What formula can be used to convert PDF user units into browser-compatible measurement units (for eg: pixels)?

 

For eg: `TextDecorationThickness`'s value is in PDF user units, how should this be translated into pixels or any other browser compatible value?

This topic is closed to new replies. Start a new post to keep the conversation going.

14 replies

Joel Geraci
Community Expert
Community Expert
Feb 24, 2023 3:47 PM UTC

Generally, the units are 72 points per inch. Also, note that the coordinate system has it's origin (0,0) at the bottom left of the page. The values are already browser compatible in that you can use "xx pt" to represent points in CSS.

Translate
InqutecAuthor
Known Participant
Feb 25, 2023 6:23 AM UTC

 

That makes republishing simpler! Thanks for the clarity @Joel Geraci. So, would it be correct to assume that the co-ordinates mentioned in BBox can be represented as "xx pt" without any conversion?

 

While I will refer to the schema here when required, is there anything else one needs to consider when using the co-ordinate values?

Translate
Joel Geraci
Community Expert
Community Expert
Feb 27, 2023 3:27 PM UTC

With the BBox, you will need take into consideration that the coordinate system origin points for PDF and HTML canvas are flipped. As I mentioned, the origin for a PDF page is at the bottom left, HTML canvas is at the top left. What you can do is use the BBox to calculate the height and width and simply use the "pt" units for setting those dimensions.

Translate