Define PDF description when create PDF in PHP imagick

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Posts: 2
Joined: 2014-09-23T09:33:55-07:00
Authentication code: 6789

Define PDF description when create PDF in PHP imagick

Post by ciskomi »

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();

// get all available font names

// write each font, 1 per line
foreach ($fonts as $id=>$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)

// define compression and quality

// define PDF format

// 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: 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:


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

I did try to add:

Code: Select all

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

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...)

Last edited by ciskomi on 2014-09-28T11:44:41-07:00, edited 3 times in total.

User avatar
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Define description when create PDF in PHP imagick

Post by fmw42 »

I have moved this topic to the Imagick forum, since it is a question about Imagick syntax.