With SetaPdf_Stamper from Setasign, when i importing certain document and trying to stamp image to some page. The position of image is wrong. The position of image must be in the upper left corner, when i set position:
SetaPDF_Stamper::POSITION_LEFT_TOP, 'translateX' => 0, 'translateY' => 0
I've read manual from setasign. I get some clue like as give $page->getStreamProxy()->encapsulateExistingContentInGraphicState();
. but still it does'nt work.
$document = SetaPDF_Core_Document::loadByFilename(
'oprek.pdf', $writer
);
$stamp = new SetaPDF_Stamper_Stamp_Image(SetaPDF_Core_Image::getByPath('arrow-annotation.png'));
$pages = $document->getCatalog()->getPages();
$page = $pages->getPage(1);
$stamp->setWidth(80);
$stamp->setHeight(40);
$stamper = new SetaPDF_Stamper($document);
$page->getStreamProxy()->encapsulateExistingContentInGraphicState();
$stamper->addStamp(
$stamp,
array(
'position' => SetaPDF_Stamper::POSITION_LEFT_TOP,
'showOnPage' => 1,
'translateX' => 0,
'translateY' => 0,
'rotation' => 90
)
);
$stamper->stamp();
The result in this image: