Skip to content
This repository was archived by the owner on May 21, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions Classes/PDFMerger.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

use setasign\Fpdi\Fpdi;

/**
* PDFMerger created by Jarrod Nettles December 2009
* jarrod@squarecrow.com
*
* v1.0.2
* v1.0.5
*
* Class for easily merging PDFs (or specific pages of PDFs) together into one. Output to a file, browser, download, or return as a string.
* Unfortunately, this class does not preserve many of the enhancements your original PDF might contain. It treats
Expand All @@ -14,12 +16,14 @@
* If you put pages 12-14 before 1-5 then 12-15 will be placed first in the output.
*
*
* Uses FPDI 1.3.1 from Setasign
* Uses FPDF 1.6 by Olivier Plathey with FPDF_TPL extension 1.1.3 by Setasign
* Uses FPDI ^2.0 from Setasign
* Uses FPDF 1.82.1 by Fpdf
*
* Both of these packages are free and open source software, bundled with this class for ease of use.
* They are not modified in any way. PDFMerger has all the limitations of the FPDI package - essentially, it cannot import dynamic content
* such as form fields, links or page annotations (anything not a part of the page content stream).
*
* Updated by Andrey Grin January 2021
*
*/
class PDFMerger
Expand All @@ -32,12 +36,6 @@ class PDFMerger
*/
public function __construct()
{
if(!class_exists("FPDF")) {
require_once('fpdf/fpdf.php');
}
if(!class_exists("FPDI")) {
require_once('fpdi/fpdi.php');
}
}

/**
Expand Down Expand Up @@ -73,7 +71,7 @@ public function merge($outputmode = 'browser', $outputpath = 'newfile.pdf')
{
if (!isset($this->_files) || !is_array($this->_files)): throw new exception("No PDFs to merge."); endif;

$fpdi = new FPDI;
$fpdi = new Fpdi();

//merger operations
foreach ($this->_files as $file) {
Expand All @@ -87,18 +85,18 @@ public function merge($outputmode = 'browser', $outputpath = 'newfile.pdf')
for ($i = 1; $i <= $count; $i++) {
$template = $fpdi->importPage($i);
$size = $fpdi->getTemplateSize($template);
$orientation = ($size['h'] > $size['w']) ? 'P' : 'L';
$orientation = ($size['height'] > $size['width']) ? 'P' : 'L';

$fpdi->AddPage($orientation, array($size['w'], $size['h']));
$fpdi->AddPage($orientation, array($size['width'], $size['height']));
$fpdi->useTemplate($template);
}
} else {
foreach ($filepages as $page) {
if (!$template = $fpdi->importPage($page)): throw new exception("Could not load page '$page' in PDF '$filename'. Check that the page exists."); endif;
$size = $fpdi->getTemplateSize($template);
$orientation = ($size['h'] > $size['w']) ? 'P' : 'L';
$orientation = ($size['height'] > $size['width']) ? 'P' : 'L';

$fpdi->AddPage($orientation, array($size['w'], $size['h']));
$fpdi->AddPage($orientation, array($size['width'], $size['height']));
$fpdi->useTemplate($template);
}
}
Expand Down
272 changes: 0 additions & 272 deletions Classes/fpdf/FAQ.htm

This file was deleted.

Loading