Page 1 of 1

FPDI - File size problem when splitting PDF

Posted: Tue Oct 04, 2016 12:34 pm
by apor
If I have a PDF on 10 pages with a file size of 4.5mb. When I split all the pages of this larger pdf into 10 pdf files with one page each, each file will then also be 4.5mb. So the size of every individual page split into single pdf's does not reduce size.

Is there anyway I can reduce the size? because when I rearrange the 10 pages and combine the 10 pdf's again into a new file it will be 45mb, which is super unhandy.

Code: Select all

require_once "$docroot/fpdf/fpdf.php"; 
require_once "$docroot/fpdi/fpdi.php"; 

function split_sample_pdf() 
{ 

$files = glob("./samplepdfs/*"); 

$pdf = new FPDI(); 
$pageCount = $pdf->setSourceFile($files[0]); 
$pdf->close(); 
for ($x = 1; $x <= $pageCount; $x++) 
{ 
$pdf = new FPDI(); 
$pdf->addPage(); 
$pdf->setSourceFile($files[0]); 

$pdf->useTemplate($pdf->importPage($x)); 

$pdf->Output("./split_samples/pdf-". $x .".pdf", "F"); 

$pdf->close(); 

} 

}