Hi community,
At the moment I am using the pdfJSViewerBase64 webblock from this component. To achieve a base64 text I am converting my binary to base64 using the BinaryToBase64 action from the BinaryData component.
This is all working correctly, but the business wants the option of naming the pdf when downloading it from the toolbar. By default it is document.pdf. Is this possible with the base64 webblock?
Kind regards,
Bart
Hi Bart,
Unfortunately, with the pdfJSViewerBase64 webblock specifically, renaming the downloaded PDF file directly from its toolbar (while rendering it in Base64 format) isn't inherently supported as it relies on the browser's native handling of the file. By default, the filename is determined by the viewer or the browser, usually defaulting to "document.pdf."
If you want to allow for a custom filename when the user downloads the PDF, you would need to handle this at the point of download rather than relying on the viewer's toolbar. Here's one way to approach this:
Use a Download Button: Provide a separate download button or link on the page. Instead of relying on the toolbar, you can leverage OutSystems to prepare the PDF on the server with a custom filename.
Custom Download with BinaryData: Convert your PDF's binary data to Base64 using the BinaryToBase64 action (as you're already doing), and then serve it via a download endpoint. You can specify the Content-Disposition header with your desired filename programmatically.
BinaryToBase64
Content-Disposition
Embed PDF into Viewer: Continue using the PDF.js Viewer (if preferred) for viewing, but manage downloads independently using the above method.
Alternatively, you might consider adapting or extending the pdfJSViewerBase64 component's implementation to include a custom file naming feature, but this would require modifications directly to the component's source.
For more insights into manipulating PDFs in OutSystems, you might find the following articles helpful:
Let me know if you need further clarification!
Kind regards.