[ACCEPTED]-Creating two pdf pages with Imagick-imagick

Accepted answer
Score: 15

I know this is long past due, but this result 3 came up when I was trying to do the same 2 thing. Here is how you create a multi-page 1 PDF file in PHP and Imagick.

    $images = array(
$pdf = new Imagick($images);
if (!$pdf->writeImages('combined.pdf', true)) {
    die('Could not write!');
Score: 2

Accepted answer wasn't working for me, as 4 a result, it always generated one page pdf 3 (last image from constructor), to make this 2 work I had to get file descriptor first, like 1 this:

$images = array(
  'img1.png', 'img2.png'
$fp = fopen('combined.pdf', 'w');
$pdf = new Imagick($images);
Score: 1

Is this working?



exec("convert file*.pdf all.pdf");


Score: 1

CAM::PDF is a pure-Perl solution for low-level PDF 10 manipulation like this. You can either 9 use the appendpdf.pl command-line tool, or do it programmatically 8 like this:

use CAM::PDF; my $doc1 = CAM::PDF->new('file1.pdf'); my 7 $doc2 = CAM::PDF->new('file2.pdf'); $doc1->appendPDF($doc2); $doc1->cleanoutput('out.pdf');

If 6 you can figure out how to make ImageMagick 5 write to a string instead of to a file (I'm 4 not an ImageMagick expert...) then you save 3 some performance overhead by keeping it 2 all in Perl.

(I'm the author of CAM::PDF. It's 1 free software: GPL+Artistic dual-licensed).

Score: 0

I do not know php or this Imagick library, but 8 if calling an external program is acceptable 7 I can recommend the program pdfjoin to merge pdf 6 files.

It does have an dependency to pdflatex, so 5 if this is something you intend to run on 4 a server you might have to install extra 3 latex stuff, but the end result from pdfjoin 2 is very good, so I think it will be worth 1 it.

More Related questions