Page 1 of 1

Image to PDF conversion

Posted: 2014-06-05T06:51:16-07:00
by mariusz.pala
Hi,

how can I convert an image (gif,jpg,tiff,png) to a PDF with A4 page size and image fit into the page with some margin defined?
RIght now the PDF size is the same as image size when I convert it.

Thanks in advance for any help,

Mariusz

Re: Image to PDF conversion

Posted: 2014-06-05T09:32:16-07:00
by fmw42
You will have to resize the image to the desired A4 size with margin subtracted. IM is a raster processor and will convert and image into raster format. If the output format is PDF, the image will be put into a vector shell, but will contain raster data. Thus you will not be able to interactively stretch the file without processing it to a different size via -density or -resize.

So you need to get the pixel dimensions of the A4, subtract the margin you want, then resize the image to that size and then add the appropriate border. see the page sizes at http://www.imagemagick.org/script/comma ... s.php#page

A4 is 595x842. If your margin is say 20 pixels. Then your need to resize to 575x823

Code: Select all

convert rasterimage -resize 575x823 -gravity center -background white -extent 595x842 image.pdf

Re: Image to PDF conversion

Posted: 2014-07-04T00:51:30-07:00
by mariusz.pala
Thank you! I found two problems with that command:
1. Smaller images are resized and I'd like to keep them in the original size.
- Solution was actually very simple, just use a different resize syntax: 575x823^>
2. PDF size is incorrect: 8.26x11.69inch, whether A4 generated from MS Word is 8.5x11inch
- According to this page (http://www.indigorose.com/forums/archiv ... 13334.html) it is actually a correct format.

So I should be fine! Thank you again!
Mariusz