Skip to main content
Known Participant
February 24, 2023
Question

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

  • February 24, 2023
  • 1 reply
  • 2591 views

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 has been closed for replies.

1 reply

Joel Geraci
Community Expert
Community Expert
February 24, 2023

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.

InqutecAuthor
Known Participant
February 25, 2023

 

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?

Joel Geraci
Community Expert
Community Expert
February 27, 2023

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.