Page 1 of 1
Convert JPG to PDF in Multiple Pages
Posted: 2016-10-08T03:53:41-07:00
by Paulohpmagalhaes
Hello guys,
I have a huge image, lets say 1000x7000 and I would like to convert to PDF, but fit the width in the page and split the height in multiple pages.
When I Use the simple command below, the page in PDF is adjusted according the image size:
Code: Select all
C:\Program Files\ImageMagick-7.0.3-Q16>convert.exe c:\temp\teste.jpg c:\temp\teste.pdf
When I use the -page A4 parameter the Image is resized to fit in one page only:
Code: Select all
convert.exe c:\temp\teste.jpg -page A4 c:\temp\teste.pdf
What parameter should I user?
Thanks in advance!
Re: Convert JPG to PDF in Multiple Pages
Posted: 2016-10-08T06:30:03-07:00
by snibgo
How many pages do you want to split it across? I'll assume you want 7 pages. You might do it like this:
Code: Select all
convert c:\temp\teste.jpg -crop 1x7@ +repage c:\temp\teste.pdf
Re: Convert JPG to PDF in Multiple Pages
Posted: 2016-10-08T08:00:42-07:00
by Paulohpmagalhaes
Thanks for the answer.
I want as many pages as needed. It could be one, it could be ten. It will depend on the height of the image which can change...
Re: Convert JPG to PDF in Multiple Pages
Posted: 2016-10-08T09:08:04-07:00
by snibgo
"crop x1000" or some other number might suit your needs better. This would give you 1000 rows per page, but the last page could have fewer.
Re: Convert JPG to PDF in Multiple Pages
Posted: 2016-10-08T10:15:50-07:00
by Paulohpmagalhaes
Thank you again snibgo for the reply.
The "crop" parameter is a improvement, but I would like to have pages in A4 format with margins and centered so People can print in paper. I tried the -page a4 but didin't work with crop.
Any suggestions?
Re: Convert JPG to PDF in Multiple Pages
Posted: 2016-10-08T10:32:47-07:00
by snibgo
For margins, "-repage" is useful. For example, if your input is 1000 pixels wide:
Code: Select all
convert c:\temp\teste.jpg -crop x1414 -repage 1200x1614+100+100 c:\temp\teste.pdf
Re: Convert JPG to PDF in Multiple Pages
Posted: 2016-10-09T13:35:13-07:00
by Paulohpmagalhaes
Thank you again for the reply but I wasn't able to export in PDF like I expected. I have searched in the community, and in the command line reference but still no solution. It seems to work when I export to gif, but not to pdf..
Here is the link of a image of example and the PDF expected (I converted using PDF printer)
Image:
http://ntlh.com.br/wp-content/uploads/2 ... xample.jpg
PDF:
http://ntlh.com.br/wp-content/uploads/2 ... xample.pdf
Again, Thank you in advance...
Re: Convert JPG to PDF in Multiple Pages
Posted: 2016-10-09T13:45:28-07:00
by snibgo
The PDF contains four images, one per page. They have different heights: 1580, 1579, 1580 and 1085.
So you need to explicitly crop with those heights.
Re: Convert JPG to PDF in Multiple Pages
Posted: 2016-10-09T14:12:25-07:00
by Paulohpmagalhaes
The idea would be to use -crop x1580. The last one will be the remainder. If I use:
Code: Select all
convert c:\temp\example.jpg -crop x1580 +repage c:\temp\example.pdf
I will have this:
http://ntlh.com.br/wp-content/uploads/2 ... esteA1.pdf
It's almost what I want, I just need in printable format (A4 with margin).
Re: Convert JPG to PDF in Multiple Pages
Posted: 2016-10-09T14:31:46-07:00
by snibgo
Above, I suggested you use "-repage" for the margins. Or you may prefer to use "-borders".