Hi, I have the following problem:
Based on 'some' input parameter to Prince command line, I need to switch between two or more sources of an image. In practice right now, it will be a low resolution and high resolution version of the same image. We would prefer it if prince would only load the correct image because the high resolution images could be very big (so the recompression option is less viable as it would impact performance a lot).
Reading through the documentation, one possible solution seemed to be to pass a custom media type using the --media command line switch and then using something like:
Unfortunately, prince doesn't seem to support srcset. So I added a polyfill for this and enabled javascript with --javascript. But this doesn't work. We assume because the matchMedia() function is not available in prince. So I added a polyfill for that too, but it relies on window.media or window.styleMedia which are undefined in prince...
So my question is, is there a good polyfill for matchMedia in prince? Or does anyone know an easier/cleaner way to solve the problem? Maybe using media features or some dpi command line switch?
As far as I could tell the --raster options are only relevant if you are ok with the output being an image (which we don't want). And --css-dpi would affect all css dimensions, not just for images.
Thanks for any pointers.
Based on 'some' input parameter to Prince command line, I need to switch between two or more sources of an image. In practice right now, it will be a low resolution and high resolution version of the same image. We would prefer it if prince would only load the correct image because the high resolution images could be very big (so the recompression option is less viable as it would impact performance a lot).
Reading through the documentation, one possible solution seemed to be to pass a custom media type using the --media command line switch and then using something like:
<picture>
<source srcset="lowres.jpg" media="lowres">
<img srcset="highres.jpg" alt="my image" />
</picture>
Unfortunately, prince doesn't seem to support srcset. So I added a polyfill for this and enabled javascript with --javascript. But this doesn't work. We assume because the matchMedia() function is not available in prince. So I added a polyfill for that too, but it relies on window.media or window.styleMedia which are undefined in prince...
So my question is, is there a good polyfill for matchMedia in prince? Or does anyone know an easier/cleaner way to solve the problem? Maybe using media features or some dpi command line switch?
As far as I could tell the --raster options are only relevant if you are ok with the output being an image (which we don't want). And --css-dpi would affect all css dimensions, not just for images.
Thanks for any pointers.