Create PDF files with PHP and FPDF Output Methods

4 minutes read

FPDF is a class to create PDF files with PHP, that is to say without using the PDFlib library.

fpdf_php
For those who are already familiar with FPDF, this post will show you how to output your PDF file using FPDF. There are 4 methods that you can use according to your own needs:
Method 1: Saving the PDF to a file:

Method 1 (for server): Saving the PDF file to server (make sure you have 777 writing permissions for that folder!):

Method 2: Prompting user to choose where to save the PDF file:

Method 3: Automatically open PDF in your browser after being generated:

Method 4: Returning the PDF file content as a string:

 

Facebook Twitter LinkedIn Telegram Whatsapp

Related Posts:

What is PHP ? PHP stands for Hypertext Preprocessor and is a server-side language. PHP allows web developers to create dynamic content that interacts with databases. PHP is relatively new (compared to languages such as Perl (CGI) and Java) but is quickly becom...
How to upload a file from one server to another server using PHP cURL POST method. How to send files using PHP and cURL The cURL functions in PHP can be used to make HTTP requests to remote servers. The curl_setopt  method allows us a wide range of options to ...
Some times we need the visitor’s IP address for validation, security, spam prevention etc. Getting the Visitor’s IP address is very easy in PHP. We can get the Internet Protocol (IP) address of any visitor by using PHP. Get Clients IP address using PHP script ...