0

We are using convertAPI to convert webpages to PDF. One of our requierements is that the webpage content fits onto exactly one PDF page. We know the height of the page in pixels and are trying to convert that pixel value to a PageHeight parameter (specified in mm). Pixel to MM converters require a PPI argument to give an accurate value (see https://pixelsconverter.com/millimeters-to-pixels). What is the PPI used by ConvertAPI's system? In other words, If i have a div element with height 100px, what will the height of that element be in the result PDF in mm?

I've tried using some guess and check strategies for determining the PPI used, but this has been somewhat fruitless

Edit: adding more information I'm using a viewport size of 1900 x 1024. I know the exact height of my page in pixels (it's dynamic, but let's use 2048px for this example). I'm using the default PDF page width (216mm is default) and overriding the margin options to 0 for all. I'm looking to solve for the PageHeight parameter to send to ConvertAPI in mm. What is the conversion factor I need to translate my page height (2048px) into mm?

  • Is this an answer that you are looking for? https://stackoverflow.com/a/3833980/625521 Use https://developer.mozilla.org/en-US/docs/Web/CSS/break-after – Jonas Apr 28 '23 at 07:44
  • 1
    Wouldn't you _compute_ that value for each site you're trying to convert? It should be something like `max(pix_height / page_height, pix_width / page_width)`. – ChrisGPT was on strike Apr 30 '23 at 15:26
  • Thanks for the responses. I'll clarify my problem statement even further: I'm using a viewport width of 1900 x 1024. I know the exact height of my page in pixels (it's dynamic, but let's use 2048px for this example). I'm using the default PDF page width (216mm is default), but looking to solve for the PageHeight parameter to send to ConvertAPI in mm. What is the conversion factor I need to translate my page height (2048px) into mm? – Zach Hislop May 01 '23 at 19:03

0 Answers0