Saving Files to a Folder using TCPDF

For a solution, instead of changing anything, one can remove the java in index.php and remove the headers in create_pdf.php. The user has a question regarding saving a DPF file that has been generated by TCDPF and sending information about it to another script. Additionally, they want to generate and open a PDF when a user clicks on a button.


I am attempting to create a PDF that will launch upon the user clicking a button. Here is the current progress of my code:



Output('test.pdf', 'I');
//$pdf->Output('test.pdf', 'FD');

I have attempted various Output() options, but none have been successful in either opening a new window with the generated PDF or prompting the user with a “save as” dialog to download the PDF. Can you suggest an alternative solution?

Solution 1:

Have you tried this


The user will be prompted to select a location for saving the
PDF file

Solution 2:

Ajax has the capability to retrieve only textual data, but it lacks the ability to display PDF files directly or in a new window via response.

To proceed, you can either opt to submit a form instead of using AJAX or utilize an AJAX call to create a file and receive a response regarding the file’s creation, such as its name. Then, you can open a new window based on the received information.

Solution 3:



Download PDF

Eliminate the Java code from the file named index.php and take out the headers from the create_pdf.php file.

Frequently Asked Questions

Posted in Php