Skip to content
/ FPDF Public
forked from Setasign/FPDF

A PDF library that helps you to stream large files as chunked data.

License

Notifications You must be signed in to change notification settings

arimacdev/FPDF

 
 

Repository files navigation

FPDF

This is a fork of official mirror of the FPDF library. We changed it to support streaming chunked data. You can avoid memory exceed errors by using this library.

Official FPDF Documentation

Installation with Composer

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

$ composer require arimac/fpdf:^1.8

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

{
    "require": {
        "arimac/fpdf": "^1.8"
    }
}

Usage

  • To download a file as a stream
<?php
require('fpdf.php');

$pdf = new FPDF();
$pdf->StartDownload('sales_report.pdf');
for($i=0; $i<100000; $i++) {
  $pdf->AddPage();
  $pdf->SetFont('Arial','B',16);
  $pdf->Cell(40,10,'Hello World!');
}
$pdf->Close();

Now FPDF will sending the generated data to the browser without waiting to finish the loop.

  • To present a preview of a file as stream
require('fpdf.php');

$pdf = new FPDF();
$pdf->StartPreview('sales_report.pdf');
for($i=0; $i<100000; $i++) {
  $pdf->AddPage();
  $pdf->SetFont('Arial','B',16);
  $pdf->Cell(40,10,'Hello World!');
}
$pdf->Close();

Same as above method. But it opening the generated PDF file insteed of downloading.

  • To directly write to a file
require('fpdf.php');

$pdf = new FPDF();
$pdf->StartFile('sales_report.pdf');
for($i=0; $i<100000; $i++) {
  $pdf->AddPage();
  $pdf->SetFont('Arial','B',16);
  $pdf->Cell(40,10,'Hello World!');
}
$pdf->Close();

About

A PDF library that helps you to stream large files as chunked data.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 63.0%
  • HTML 36.4%
  • CSS 0.6%