Here's my situation:
I'm sending a canvas element into a PHP file via AJAX. I'm utilizing the Fabric.js library, so that I'm able to add and manipulate text on a canvas that is 1050px wide and 675px high. When I use Imagick, make the conversion to PDF, and send that file into a local folder, the end result looks great. The resolution, placement, and size of the text seems to be accurate.
In addition to converting that canvas element to a PDF, I'm also converting a local EPS file to a PDF. (I'm needing this image to serve as my background when I overlay the first image on top of it.) When I go through a similar conversion process with only this separate image, I get another great looking PDF as an end result.
However, when I use compositeImage to overlay the text PDF on top of the background PDF, the placement and size of the text is incorrect. (The resolution still looks good, though.) I'm using setSize to make the columns and rows of both PDFs identical (the same as the canvas element: 1050 x 675), so I'm not sure why this is happening. (I noticed when I look at the two separate image in Preview, that the Page sizes are different.) What am I missing?
Here's my PHP code:
Code: Select all
//First Image: Background Image $background = ***local EPS file*** $background_image = new Imagick(); $background_image->setResolution(450,450); $background_image->setSize(1050,675); $background_image->readImage($background); $background_image->setImageFormat("pdf"); //Second Image: Text Image $text = base64_decode($text_data); $text_image = new Imagick(); $text_image->setResolution(450,450); $text_image->setSize(1050,675); $text_image->readImageBlob($text); $text_image->setImageFormat("pdf"); //Combining Images $background_image->compositeImage($text_image, imagick::COMPOSITE_ATOP, 0, 0);