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
  • 2593 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?

InqutecAuthor
Known Participant
March 10, 2023

All I can suggest it to try some stuff and see if it works for your use case. When I convert PDF to HTML using the output from Extract, I'm generally not trying to replicate the PDF layout, I'm republishing it so I don't expect the measurements to be even close. If I want the exact layout in an HTML page without it being a PDF viewer experience, I use our Embed API in IN_LINE mode so the PDF just acts like an image.


Using Embed API is an interesting approach. Thanks for sharing. 

 

I'm republishing it so I don't expect the measurements to be even close.

Until now was assuming republishing to be as reproducing the PDF in a different file format. Thanks for adding g