Page 1 of 1

Define PDF description when create PDF in PHP imagick

Posted: 2014-09-23T10:18:49-07:00
by ciskomi
Hello.
I try to create a PDF file with imagick, and it works quite well.
Here you are my code:

Code: Select all

<?
// ciskomi 23 sept 2014. France.

// create magick object
$test=new Imagick();

// create white picture with A4 format ratio
$test->newImage(1240, 1753, new ImagickPixel('white'));

// create font object
$draw = new ImagickDraw();
$draw->setFontSize(16);

// get all available font names
$fonts=$test->queryFonts();

// write each font, 1 per line
$y=5;
foreach ($fonts as $id=>$font) {
  $draw->setFont($font);
  $test->annotateImage($draw,10,$y+=18,0,$font." - id $id");
}

// set 150 dpi, with the 1240 x 1753 pixels image, means 210 x 297mm (A4 format)
$test->setImageResolution(150,150);

// define compression and quality
$test->setImageCompression(Imagick::COMPRESSION_LZW);
$test->setImageCompressionQuality(95); 

// define PDF format
$test->setImageFormat("pdf");

// output file in browser
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="imagicktest.pdf"');
echo $test;

?>
The PHP result can be seen at adress: http://ciskomi.monespace.net/imagick/createpdf.php as a PDF file.

My problem is that I did not find how to set the PDF description.
At this time, the description seen in adobe reader is:

Image

The filename is correct (defined in the php header function).

I did try to add:

Code: Select all

$test->setImageProperty('Author','ciskomi');
$test->setImageProperty('Subject','subject test pdf');
$test->setImageProperty('Title','pdf test title');
but nothing did append.

Question:
in PHP with imagick, how to define the title, author, subject for the imagick pdf created ?


(I apologize for my english, it is not my native language...)

ciskomi

Re: Define description when create PDF in PHP imagick

Posted: 2014-09-23T10:33:00-07:00
by fmw42
I have moved this topic to the Imagick forum, since it is a question about Imagick syntax.