Easy way to split PDF
A PDF manipulator based on pdftk., (*2)
PHPExtractor is a PDF manipulation tool for PHP., (*3)
pdftk
command must be installed on your systemYou should use use composer to install this library., (*4)
composer require ztomesic/pdfextractor
use ZTomesic\PDFExtractor\PDFExtractor;, (*5)
use ZTomesic\PDFExtractor\PDF;, (*6)
$pdf = new PDF('/file/location/file.pdf');, (*7)
Split a PDF file into one file per page., (*8)
$file = new PDF('/file/location/file.pdf'); PDFExtractor::burst($file)->save('/location/where/to/burst/');
Concatenate pages from several PDF files into a new PDF file., (*9)
PDFExtractor::cat(/location/of/pdf/files/, '*.pdf')->save('location/where/to/save/', 'name_of_new_file.pdf');
Convert PDF to text., (*10)
$pdf = new PDF('/file/location/file.pdf'); PDFExtractor::PDFToText($pdf);
Search PDF file by keywoard(s)., (*11)
$pdf = new PDF('/file/location/file.pdf'); PDFExtractor::searchPDF($pdf, 'wordToSearchBy');
Rebuild PDF(s) by keyword(s), (*12)
$pdf = new PDF('/file/location/file.pdf'); PDFExtractor::rebuildPDFByKeyword($pdf, '/location/where/to/burst/', '/location/where/to/rebuild/', 'keyword_to_rebuild_by');
Change location of specific file, (*13)
$pdf = new PDF('/file/location/file.pdf'); PDFExtractor::relocateFile($pdf, '/new/file/path/');
Delete all content from folder., (*14)
$excludedFiles = ['excluded_file.pdf']; PDFExtractor::clearFolder('/path/to/directory/', $excludedFiles);
Delete directory and content., (*15)
PDFExtractor::removeDirectory('/path/to/directory/');
Create new directory., (*16)
PDFExtractor::createDirectory('/path/to/directory/name/');
Search PDF(s) and rebuild by keyword., (*17)
$pdf = new PDF('/file/location/file.pdf'); $PDFExtractor = PDFExtractor::burst($file)->save('/location/where/to/burst/'); $PDFExtractor->searchMultiplePDFByKeywords('/location/where/to/burst/', 'wordToSearchBy') ->changeFileLocation('/location/where/to/rebuild/') ->mergePDFByKeywords();
Extract metadata to array., (*18)
PDFExtractor::extractMetadata('/path/to/directory/name/') ->save('/location/where/to/save/', 'name_of_file.txt') ->toArray();
Extract metadata to string., (*19)
PDFExtractor::extractMetadata('/path/to/directory/name/') ->save('/location/where/to/save/', 'name_of_file.txt') ->toString();