Questions tagged [fpdf]

A PHP class which allows developers to generate PDF files with pure PHP instead of the PDFlib library.

Home page of FPDF

FPDF is a PHP class which allows developers to generate PDF files with pure PHP, that is to say without using the PDFlib library. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs.

FPDF has other advantages: high level functions. Here is a list of its main features:

  • Choice of measure unit, page format and margins
  • Page header and footer management
  • Automatic page break
  • Automatic line break and text justification
  • Image support (JPEG, PNG and GIF)
  • Colors
  • Links
  • TrueType, Type1 and encoding support
  • Page compression

FPDF requires no extension (except zlib to activate compression and GD for GIF support). It works with PHP 4 and PHP 5

2301 questions
12
votes
2 answers

Convert pixels to points for pdf

I am using php and fpdf to generate a pdf. How can I scale a 400 pixel high image to fit in a 300 point high space? The dimensions are just examples, the image and available space are dynamic.
maddogandnoriko
  • 980
  • 2
  • 13
  • 31
12
votes
2 answers

View pdf file in browser instead of downloading

header("Content-Length: " . filesize ('theme/assets/pdf/ci.pdf' ) ); header("Content-type: application/pdf"); header("Content-disposition: attachment; filename=".basename('theme/assets/pdf/ci.pdf')); header('Expires:…
user1894647
  • 613
  • 3
  • 11
  • 22
12
votes
3 answers

FPDF align text LEFT, Center and Right

I've have three cells and i'am trying to align the text to Left, Center and Right. function Footer() { $this->SetY( -15 ); $this->SetFont( 'Arial', '', 10 ); $this->Cell(0,10,'Left text',0,0,'L'); $this->Cell(0,10,'Center…
user2929483
12
votes
4 answers

FPDF - Determining height of MultiCell before placing?

The basic question: Is it possible to determine the height of a MultiCell before placing it in the document? The reason: I've been tasked with creating a PDF version of a form. This form allows text input, with a resulting variable length. One…
Roger Asbury
  • 351
  • 1
  • 4
  • 13
12
votes
3 answers

Using fpdf to modify existing pdf in php

I have a bank of pdfs on my server which when downloaded need text appended to every page. I am using fpdf to try and open the file, append the text to each page, close the file and serve to the browser. $pdf = new…
Steve Smith
  • 734
  • 6
  • 14
  • 29
11
votes
7 answers

Set PDF to print with no scaling

I am generating a PDF (using fpdf) and I am wondering if there is a way to set the document's properties to to default to print with no scaling. So when you select print from the print dialogue menu, scaling is set to none. I'm trying to determine…
JCam
  • 604
  • 3
  • 9
  • 16
11
votes
6 answers

fpdf Output('filename.pdf','F'); downloading file on browser instead of saving it on the server

When running code the file is the pdf file is getting saved in the browser instead of it getting saved on the server fpdf Output('filename.pdf','F'); downloading file on browser instead of saving it on the server
user3766591
  • 357
  • 1
  • 2
  • 11
11
votes
6 answers

FPDI with Multiple Pages

I am new to PHP and am having a bit of a hard time with using FPDI when it comes to inserting multiple pages. I have a .pdf file which consists of 3 pages. I ended up saving page 1 as a separate page out of the 3 and that worked with my code, but…
hiter202
  • 109
  • 1
  • 2
  • 6
11
votes
4 answers

FPDF height of a MultiCell Element

I use the FPDF library to export some document files as PDF. One document includes a list of strings which have a different length. I print all strings as $pdf->MultiCell(). Now I would like to have the current height of that MultiCell to have the…
Thomas1703
  • 1,152
  • 5
  • 16
  • 33
11
votes
5 answers

How could you dynamically create a pdf within wordpress?

I'm using a Contact Form 7 to have the users enter data, then based on their data entry, I need to add different text to the pdf before outputting the entire pdf. For example, if the user says they like red balloons, the created balloon pdf will…
user1784593
  • 111
  • 1
  • 1
  • 4
10
votes
3 answers

FPDF: Decide when to set header/footer data

I've been struggling with the header and footer data for quite some time now and thought it was time to ask it here on the forum. What I'm trying to do is decide that if a page is added if the header / footer should be added or not. so code-wise I…
GuZzie
  • 974
  • 1
  • 6
  • 23
10
votes
4 answers

FPDF.php is ~20 times smaller filesize than TCPDF.php? Why?

I know there have been a lot of posts about these two but figured I'd address a glaring question I have. A designer of ours recently sent me a few files with TCPDF already tied in because a friend of him said it was "better". In the past we have…
JM4
  • 6,740
  • 18
  • 77
  • 125
10
votes
5 answers

FPDF error: Could not include font metric file

I have a app which was done by someone else and now i am asked to look into one issue. When a pdf report is generated it throws an error. This app uses FPDF to generate the PDF FPDF error: Could not include font metric file Earlier it was throwing…
Prady
  • 10,978
  • 39
  • 124
  • 176
10
votes
4 answers

UnicodeEncodeError: 'latin-1' codec can't encode character '\u2013' (writing to PDF)

I am having an issue with Unicode with a variable contents when writing to a .pdf with python. It's outputting this error: UnicodeEncodeError: 'latin-1' codec can't encode character '\u2013' Which is it getting caught on an em dash basically. I…
Dr Upvote
  • 8,023
  • 24
  • 91
  • 204
10
votes
3 answers

FPDF Page Break Question

I am using PHP and FPDF to generate a PDF with a list of items. My problem is if the item list goes on to a second or third page, I want to keep the Item Name, Quantity and Description together. Right now, it will go to a second page, but it may…
Michael
  • 2,276
  • 15
  • 49
  • 80