Page 1 of 1

png to pdf always fits height to 1 page

Posted: 2013-07-10T08:22:26-07:00
by noelegdip
I am using imagemagick on a linux box running centos. I have png images that I am converting to pdf files.

An example size of a png in pixels would be 943x3331 (widthxheight) . When I convert this to a pdf it always keeps the pdf on one page so I am left with the image as a thin stripe down the middle of a pdf. I would like to be able to convert the pdf so it fits the png to the width of the page and goes down as many pages as needed for the height. Is this possible?

Re: png to pdf always fits height to 1 page

Posted: 2013-07-10T09:02:36-07:00
by GreenKoopa
This is possible. You would have to -crop the image into tiles before saving the image as a pdf.

Re: png to pdf always fits height to 1 page

Posted: 2013-07-10T09:09:26-07:00
by noelegdip
Just to check are you saying that I need to crop the png into sizes that will each fit a page and then convert all of these into a pdf?

Re: png to pdf always fits height to 1 page

Posted: 2013-07-10T09:20:58-07:00
by GreenKoopa
Break the input png into page sized tiles using -crop, then output to pdf. Something like:

Code: Select all

convert -size 943x3331 gradient: in.png
convert in.png -crop 950x1200 +repage out.pdf
There are many ways to crop and to position the tiles on the pages.

Re: png to pdf always fits height to 1 page

Posted: 2013-07-10T12:19:41-07:00
by noelegdip
but there is no setting that will convert a png to a pdf of more than one page?

Re: png to pdf always fits height to 1 page

Posted: 2013-07-10T13:19:43-07:00
by fmw42
GreenKoopa wrote:convert in.png -crop 950x1200 +repage out.pdf
He is suggesting that you crop the image into horizontal strips of height equal to one proper page. Then output the cropped sections to separate PDF pages.

see
http://www.imagemagick.org/Usage/crop/#crop_tile
http://www.imagemagick.org/Usage/crop/#crop_equal

Re: png to pdf always fits height to 1 page

Posted: 2013-07-10T13:48:10-07:00
by GreenKoopa
noelegdip wrote:but there is no setting that will convert a png to a pdf of more than one page?
Not that I know of. ImageMagick is not specifically a pdf or page layout tool. My example created a png of the size you gave, then created a pdf with that image split over 3 pages. It's not a setting, but it accomplished the same output with little complexity. Try that second line on your image and let us know what specifically more you want it to do.

Re: png to pdf always fits height to 1 page

Posted: 2013-07-12T03:06:47-07:00
by noelegdip
thanks for all your help in this and it worked. i used

convert test.png -crop 943x1360 +repage sample.pdf

I have a perfect 5 page pdf and am very happy. pat on the back for you and all that kind of thing.