PDFMerger
v0.5.0
clegginabox/pdf-merger에서 영감을 받은 setasign/fpdi 및 fpdf 라이브러리를 기반으로 하는 PHP >= 7.2용 PDF 병합을 위한 간단한 래퍼입니다.
Symfony 프레임워크를 사용하는 경우 tomsgu/pdf-merger-bundle 번들을 사용할 수 있습니다.
composer require tomsgu/pdf-merger
$ pdfCollection = new PdfCollection ();
$ pdfCollection -> addPdf ( ' filename.pdf ' , PdfFile :: ALL_PAGES , PdfFile :: ORIENTATION_PORTRAIT );
$ pdfCollection -> addPdf ( ' filename2.pdf ' , ' 1-4,9 ' , PdfFile :: ORIENTATION_LANDSCAPE );
$ pdfCollection -> addPdf ( ' filename3.pdf ' , ' 1-4,9 ' , PdfFile :: ORIENTATION_AUTO_DETECT );
$ pdfCollection -> addPdf ( ' filename4.pdf ' );
// You can also pass a resource
$ resource = fopen ( ' filename4.pdf ' , ' r ' );
$ pdfCollection -> addPdf ( $ resource );
$ fpdi = new Fpdi ();
$ merger = new PdfMerger ( $ fpdi );
/**
* Available modes: MODE_FILE, MODE_DOWNLOAD, MODE_STRING, MODE_BROWSER
* Orientation: This is a fallback if the orientation wasn't specified when adding pdf.
*/
$ merger -> merge ( $ pdfCollection , ' output.pdf ' , PdfMerger :: MODE_FILE , PdfFile :: ORIENTATION_LANDSCAPE );