TLDR; Does anyone know if there’s an initiative to use the pdf rendering engines built into most browsers and used while printing a web page in more flexible ways? Ideally from javascript being able to get the pdf as a File.

I’ve been looking into download as pdf functionality we implemented at work. It’s for a single project, relatively small, so we implemented it with html2pdf.js. There seems to be no better way than rendering the webpage as canvas and saving as an image inside PDF. Although I’m thankful that the project exists, with the lack of text selection, poor image quality and/or large file sizes, it feels bad serving it to the customer. Then I started to look into the printed version and I loved it. Learned some new stuff about css, being able to break a page before a specific element. Tables automatically repeat their header across a page break. I can also save this as pdf, better quality, 40x reduction in file size, yay! However, web api to start this is print(), no arguments, no alternatives. Putting this behind a “Download” buttons seems confusing for the end user. I’m amazed we can’t use this built in pdf rendering engine in more flexible ways. (See TLDR for question)

  • take6056
    cake
    OP
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    Yeah, I fear we might have to go for something like that in the long run as well. Feels bad when the browser is capable enough to handle it but is just missing the interfaces.