|
1 | 1 | # FPDF |
2 | | -**This repository is only made for cloning official FPDF releases which are available at: http://www.fpdf.org** |
3 | | -**THERE WILL BE NO DEVELOPMENT IN THIS REPOSITORY!** |
4 | 2 |
|
5 | | -FPDF is a PHP class which allows to generate PDF files with pure PHP. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs. |
| 3 | +This is a fork of official mirror of the FPDF library. We changed it to |
| 4 | +support streaming chunked data. You can avoid memory exceed errors by |
| 5 | +using this library. |
| 6 | + |
| 7 | +[Official FPDF Documentation](http://www.fpdf.org/) |
6 | 8 |
|
7 | 9 | ## Installation with [Composer](https://packagist.org/packages/setasign/fpdf) |
8 | 10 |
|
9 | 11 | If you're using Composer to manage dependencies, you can use |
10 | 12 |
|
11 | | - $ composer require setasign/fpdf:^1.8 |
| 13 | +``` |
| 14 | +$ composer require arimac/fpdf:^1.8 |
| 15 | +``` |
12 | 16 |
|
13 | 17 | or you can include the following in your composer.json file: |
14 | 18 |
|
15 | 19 | ```json |
16 | 20 | { |
17 | 21 | "require": { |
18 | | - "setasign/fpdf": "^1.8" |
| 22 | + "arimac/fpdf": "^1.8" |
19 | 23 | } |
20 | 24 | } |
21 | 25 | ``` |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +- To download a file as a stream |
| 30 | + |
| 31 | +``` |
| 32 | +<?php |
| 33 | +require('fpdf.php'); |
| 34 | +
|
| 35 | +$pdf = new FPDF(); |
| 36 | +$pdf->StartDownload('sales_report.pdf'); |
| 37 | +for($i=0; $i<100000; $i++) { |
| 38 | + $pdf->AddPage(); |
| 39 | + $pdf->SetFont('Arial','B',16); |
| 40 | + $pdf->Cell(40,10,'Hello World!'); |
| 41 | +} |
| 42 | +$pdf->Close(); |
| 43 | +``` |
| 44 | + |
| 45 | +Now FPDF will sending the generated data to the browser without waiting |
| 46 | +to finish the loop. |
| 47 | + |
| 48 | +- To present a preview of a file as stream |
| 49 | + |
| 50 | +``` |
| 51 | +require('fpdf.php'); |
| 52 | +
|
| 53 | +$pdf = new FPDF(); |
| 54 | +$pdf->StartPreview('sales_report.pdf'); |
| 55 | +for($i=0; $i<100000; $i++) { |
| 56 | + $pdf->AddPage(); |
| 57 | + $pdf->SetFont('Arial','B',16); |
| 58 | + $pdf->Cell(40,10,'Hello World!'); |
| 59 | +} |
| 60 | +$pdf->Close(); |
| 61 | +``` |
| 62 | + |
| 63 | +Same as above method. But it opening the generated PDF file insteed of |
| 64 | +downloading. |
| 65 | + |
| 66 | +- To directly write to a file |
| 67 | + |
| 68 | +``` |
| 69 | +require('fpdf.php'); |
| 70 | +
|
| 71 | +$pdf = new FPDF(); |
| 72 | +$pdf->StartFile('sales_report.pdf'); |
| 73 | +for($i=0; $i<100000; $i++) { |
| 74 | + $pdf->AddPage(); |
| 75 | + $pdf->SetFont('Arial','B',16); |
| 76 | + $pdf->Cell(40,10,'Hello World!'); |
| 77 | +} |
| 78 | +$pdf->Close(); |
| 79 | +``` |
0 commit comments