Forum


Replies: 2   Views: 210
Watermarkpdf image sizes
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 17-03-2022 - 21:17

Hello,

The watermarkDocx method uses px to set height and width values. From the API doc page (https://www.phpdocx.com/api-documentation/docxutilities/insert-watermark-Word-document-with-PHP):

height int Watermark image height in pixels (optional).

width int Watermark image width in pixels (optional).

But the watermarkPdf method doesn't use pixels to set height and width values. From the API doc page (https://www.phpdocx.com/api-documentation/docxutilities/insert-watermark-pdf-document-with-PHP):

height int Height value (proportional).

width int Width value (proportional).

If you don't want to autodetect it (not setting width and height values), the exact height and width values to be used depends on the dpi and the image size. In your code, the values you are setting exceed the page size so the image is moved to the next page. For example, using a sample image included in the package (example PdfUtilities/watermarkPdf):

$docx->watermarkPdf($source, $target, 'image', array('image' => '../../files/image.png', 'width' => 78, 'height' => 64));

Regards.