Is there any way to get and download a pdf from the output of the window.print () mand.
For example:
I have a button that launches the window.print () method, this launches a popup of browser print options with print options, and I can select pdf and generate the document correctly.
What I need is that by clicking I download the PDF file automatically.
Is there any way to use the result of windows.print to download the pdf, either bining it with some js library. All on the client side?
thank you.
ok I'll try. The plugin that I use to generate the pdf is datable buttons and exports the table to pdf, all this works fine, but there is a screen print button that also generates a tab with the view to print, the problem is that when using this function in chrome, everything works ok, but it allows me to return to the main view, and the printing tab for this is linked to the main view so no action is allowed in the main view, I would like to block the main view when it opens the printing tab
Is there any way to get and download a pdf from the output of the window.print () mand.
For example:
I have a button that launches the window.print () method, this launches a popup of browser print options with print options, and I can select pdf and generate the document correctly.
What I need is that by clicking I download the PDF file automatically.
Is there any way to use the result of windows.print to download the pdf, either bining it with some js library. All on the client side?
thank you.
ok I'll try. The plugin that I use to generate the pdf is datable buttons and exports the table to pdf, all this works fine, but there is a screen print button that also generates a tab with the view to print, the problem is that when using this function in chrome, everything works ok, but it allows me to return to the main view, and the printing tab for this is linked to the main view so no action is allowed in the main view, I would like to block the main view when it opens the printing tab
Share edited Dec 14, 2017 at 23:17 Carlos Aguilar asked Aug 18, 2017 at 13:59 Carlos AguilarCarlos Aguilar 731 gold badge1 silver badge6 bronze badges 02 Answers
Reset to default 0I think you might want to have a look at something like jsPDF from Parallax (https://parall.ax/products/jspdf).
This is a clientside PDF generation library that should be able to render your page and offer it as a download.
You may try to use the download attribute inside your <a>
tag:
<a href="content/yourfile.pdf" download > pdf link of your choice </a>
<a href="content/yourfile.doc" download > doc link of your choice </a>