#49 proposes removing the current pdf-mustache approach to "rendering PDFs" from the current specification text with the plan to lean on the new "sandboxed HTML" approach. However, it's not clear from either the past or the proposed future what the expected rendering / experience might be.
Is the expectation that a PDF will be displayed within the Wallet/Renderer UX? or offered for download? or sent to a printer? or all of the above?
In recent tests, the sandboxed iframe environment prevents many of the approaches typically used to do "HTML to PDF". For example html2pdf.js completely fails due to being unable to clone HTML within a sandboxed iframe.
That said, other options exist for doing PDF creation in JavaScript, they just avoid HTML (and therefore HTML-based templates). For example, pdfmake uses a JSON structure to create PDFs. See the pdfmake playground for examples of what's possible there.
I've got some demo code in progress for using pdfmake, however, because the sandboxed iframe cannot create another iframe within itself--nor use <embed>, <object>, etc. the browser-based PDF renderers cannot be used to render the application/pdf that's generated. It can, however, be linked do as a download.
Consequently, to fully display a PDF generated from within the sandboxed iframe, the sandboxed iframe would need to send back (via postMessage) the generated application/pdf and allow the Wallet/Renderer to do the display. However, doing that "voids the warranty" of the sandbox a bit because PDFs may contain server-side communication and make network requests.
Which brings me back to the main question around expectations of display/experience with PDFs in Wallets/Renderers.
#49 proposes removing the current
pdf-mustacheapproach to "rendering PDFs" from the current specification text with the plan to lean on the new "sandboxed HTML" approach. However, it's not clear from either the past or the proposed future what the expected rendering / experience might be.Is the expectation that a PDF will be displayed within the Wallet/Renderer UX? or offered for download? or sent to a printer? or all of the above?
In recent tests, the sandboxed iframe environment prevents many of the approaches typically used to do "HTML to PDF". For example html2pdf.js completely fails due to being unable to clone HTML within a sandboxed iframe.
That said, other options exist for doing PDF creation in JavaScript, they just avoid HTML (and therefore HTML-based templates). For example, pdfmake uses a JSON structure to create PDFs. See the pdfmake playground for examples of what's possible there.
I've got some demo code in progress for using pdfmake, however, because the sandboxed iframe cannot create another iframe within itself--nor use
<embed>,<object>, etc. the browser-based PDF renderers cannot be used to render theapplication/pdfthat's generated. It can, however, be linked do as a download.Consequently, to fully display a PDF generated from within the sandboxed iframe, the sandboxed iframe would need to send back (via
postMessage) the generatedapplication/pdfand allow the Wallet/Renderer to do the display. However, doing that "voids the warranty" of the sandbox a bit because PDFs may contain server-side communication and make network requests.Which brings me back to the main question around expectations of display/experience with PDFs in Wallets/Renderers.