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.
Post Reply
ciskomi
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 »

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
Last edited by ciskomi on 2014-09-28T11:44:41-07:00, edited 3 times in total.
User avatar
fmw42
Posts: 25562
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.
Post Reply