Skip to content

Commit e70ea61

Browse files
committed
Streaming chunked data
1 parent b0ddd9c commit e70ea61

4 files changed

Lines changed: 1835 additions & 1909 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
vendor/
2+
composer.lock

README.md

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,79 @@
11
# 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!**
42

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/)
68

79
## Installation with [Composer](https://packagist.org/packages/setasign/fpdf)
810

911
If you're using Composer to manage dependencies, you can use
1012

11-
$ composer require setasign/fpdf:^1.8
13+
```
14+
$ composer require arimac/fpdf:^1.8
15+
```
1216

1317
or you can include the following in your composer.json file:
1418

1519
```json
1620
{
1721
"require": {
18-
"setasign/fpdf": "^1.8"
22+
"arimac/fpdf": "^1.8"
1923
}
2024
}
2125
```
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+
```

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "setasign/fpdf",
2+
"name": "arimac/fpdf",
33
"homepage": "http://www.fpdf.org",
44
"description": "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.",
55
"type": "library",
@@ -10,6 +10,11 @@
1010
"name": "Olivier Plathey",
1111
"email": "oliver@fpdf.org",
1212
"homepage": "http://fpdf.org/"
13+
},
14+
{
15+
"name": "Ramesh Kithsiri",
16+
"email": "ramesh@arimaclanka.com",
17+
"homepage": "https://arimaclanka.com/"
1318
}
1419
],
1520
"autoload": {

0 commit comments

Comments
 (0)