Add option to control PDF filenames when users download print results through browser preview
See original GitHub issueHello When I try to print a pdf in base64 format the document title does not work.
let opt = {
"printable": data,
"type": "pdf",
"documentTitle": "Test Base64",
"base64": true
}
printJS(opt);
Thanks for sharing this amazing tool.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Viewing PDFs and viewing preferences, Adobe Acrobat
Follow these steps to view PDFs in Read or Full Screen mode, set the Full Screen nav bar preference, read a document in...
Read more >How do I force files to open in the browser instead of ...
Browser tries to open it: use header("Content-Disposition", "inline; filename=myfilename.myextension");. No control over the server code: Use the HTML5 download ...
Read more >Common file name extensions in Windows - Microsoft Support
Learn what file name extensions are, which extensions are common in Windows, and how to view them in File Explorer.
Read more >View and modify files and folders in Files on iPad
Modify and rearrange documents. When viewing a file in a supported document format, you can modify and rearrange the document's contents using the...
Read more >Add Files, Images, Audio, and Video - Blackboard Help
To edit the file's alternative text or display behavior, select the file in the editor and then select the Edit Attachment icon. Insert...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Got it. That’s what I thought. Currently, the lib won’t use the document title for this. Also, keep in mind that the main purpose for this library is to print. It just happens that users are now trying to download the print results using their browser (the lib doesn’t manage downloads, it dispatch print jobs). Firefox for example doesn’t even show a preview, therefore, if users are going to primarily download the PDFs, I would recommend just giving them a download button on top of the print button.
That said, here is how we print the base64 data: https://github.com/crabbly/Print.js/blob/master/src/js/pdf.js#L48
The lib creates a local blob and url, then it sets the iframe src with that url. If the browser (or OS) gives the user an option to save the print job as PDF, it will use the auto generated id / filename in the url. If we could find a way to control this, we could possibly pass the
documentTitle
string to it and it may work.I’ll try to play with this whenever I have a chance. It would be nice if we could add this feature to the lib. A PR is welcomed 😃
2022年了 这个问题要不要改了