Solved

PDFfile save as dialog box with default file name in PHP

Posted on 2008-10-12
3
514 Views
Last Modified: 2013-11-13
Hello
        I have created  PDF files when i click a link (in PHP) for show data . I need an option to show the save as dialog box with default file name which i give when i open the PDF file link. Can you please  help me for this issue?

Thanks in advance.
define('FPDF_FONTPATH','font/');

	require('html2fpdf.php');
 

        $temp = "Test";
 

	$pdf = new HTML2FPDF();

	$pdf->SetAutoPageBreak(true);

	$pdf->AcceptPageBreak();

	$pdf->AddPage('L');

	$pdf->SetFont('Arial','',8);

	$pdf->WriteHTML($temp);

	$pdf->Output();

Open in new window

0
Comment
Question by:tgunduz
3 Comments
 
LVL 1

Expert Comment

by:lightit
ID: 22706262
Hello tgunduz,

This isn't possible without any extra activeX tools, or java client side implementation


Greetz
0
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 500 total points
ID: 22728206
This is a PDF file you make, right?  The expert above is right you can't force the download or control what the file name will be but there is a way to have the browser prompt for it to be saved and have the file name filled with what you want.
An example of the code to do this can be seen at http://elouai.com/force-download.php .  Of course you would just need the PDF type and have other changes because of the specific use.  In the header that has Content-disposition there is a setting for filename and that is where you can provide something to fill the Save Dialog that appears.
There is no way to force either though.  At least not from PHP (or any server language) or any client side script.  An applet or ActiveX object could do this.
Let me know how this helps or if you have a question.
bol
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now