Define PDF description when create PDF in PHP imagick
Posted: 2014-09-23T10:18:49-07:00
Hello.
I try to create a PDF file with imagick, and it works quite well.
Here you are my code:
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:
The filename is correct (defined in the php header function).
I did try to add:
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
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;
?>
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('Author','ciskomi');
$test->setImageProperty('Subject','subject test pdf');
$test->setImageProperty('Title','pdf test title');
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