Jump to content

Recommended Posts

I have a button that brings up my systems printer....

<button onClick="window.print()">Print this page</button> 

I'm trying to find a way to do the same thing but giving me the ability to save-as to my CPU.  What would be nice is if I could have separate buttons to save-as a PDF and one for CSV.  Each would automatically save to a file, with a comfirmation that its saved. The location would be coded in PHP for the desired format, and all the user has to do is click the button and it is placed in the appropriate folded.  is this possible and easy to do across ie, firefox and chrome?  Thanks for any direction.

.

Edited by Butterbean
Link to comment
https://forums.phpfreaks.com/topic/293932-save-as-button/
Share on other sites

Are these PDF and CSV files something that already exist on the server, or would they have to be created on the fly when someone presses one of the buttons?

 

If they're already existing, just provide links and style them to look like a button or whatever you want:

<a href="/path/to/the/file.pdf">PDF</a>

 

If they don't exist, its a bit more complex as the link would be going to a php page or something, which generates the PDF and then sends it to the browser.

Link to comment
https://forums.phpfreaks.com/topic/293932-save-as-button/#findComment-1503063
Share on other sites

They would have to be created on the fly.  The page where I'm including the buttons is in html.  The one I'm mostly concerned with is the CSV file.  I need to find a way where every time an html invoice is created, a NACHA certified file is created as a CSV file, then emailed to the customer.   I think I can get started on this but its gonna be rocky. 

Link to comment
https://forums.phpfreaks.com/topic/293932-save-as-button/#findComment-1503103
Share on other sites

The header() function in PHP can be used to force the save-as box to appear. Some examples can be found here:

http://php.net/manual/en/function.header.php#refsect1-function.header-examples

 

And here:

http://php.net/manual/en/function.readfile.php

Edited by cyberRobot
Link to comment
https://forums.phpfreaks.com/topic/293932-save-as-button/#findComment-1503144
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.