How to print/save a bundle of .png files as a single .pdf file
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
How to print/save a bundle of .png files as a single .pdf file
Hi folks,
Ubuntu Desktop 7.04
Gnome desktop
I have a bundle of .png files, about 30 files. I need to print all of them together as a single .pdf file. I have cup-pdf printer installed. Instead of printing each of them as .pdf file and then adding them together as a single .pdf file afterwards, is there a simple way to do the job??? TIA
Or you just could launch OpenOffice Writer (or any app for that matter that can do pdf), add the images and save/export it as a pdf file. I'm not sure how the output quality depends on the program you do, but this is one way. Of course there are other programs that may do more precise output (Scribus?) but I'm not sure if they export pdf.
An image.ps file was created. But the document was rotated 90 deg anti-clockwise. I think it was because the page length being not sufficient. Any suggestion ??? TIA
Quote:
pnmtops has options for scaling and so on that you might want to look into (see the man page). Once you are satisfied you can convert the lot using
for i in *.png ; do pngtopnm $i | pnmtops > ${i%.png}.ps ; done
(adding in any options you need). Finally ghostscript will combine everything into a single PDF:
The pnmtops command can be given an argument -turn or -noturn to determine if it gets rotated 90 degrees. The manual page gives many other options for the command, controlling width, height, scaling, aspect ratio and so on. Try them out on a single image until you have things the way you want.
For the following commands, just run each on its own on the command line. Check what you get after the first. If it's OK, run the second.
As for the order, if your images are called one.ps, two.ps and three.ps and you run the command with argument *.ps this always expands out in alphabetical order, so it is equivalent to
...command... one.ps three.ps two.ps
If that's not what you want you have to list the arguments explicitly in the order you need. If the files are image00.ps, image01.ps, image02.ps etc. you are probably OK with *.ps of course.
The other two solutions posted look reasonable also. I like netpbm because I can control each stage, but if ImageMagick works it may be simpler.
The pnmtops command can be given an argument -turn or -noturn to determine if it gets rotated 90 degrees. The manual page gives many other options for the command, controlling width, height, scaling, aspect ratio and so on. Try them out on a single image until you have things the way you want.
For the following commands, just run each on its own on the command line. Check what you get after the first. If it's OK, run the second.
pnmtops -noturn image.ps
works for me. Tks.
Quote:
As for the order, if your images are called one.ps, two.ps and three.ps and you run the command with argument *.ps this always expands out in alphabetical order, so it is equivalent to
...command... one.ps three.ps two.ps
If that's not what you want you have to list the arguments explicitly in the order you need. If the files are image00.ps, image01.ps, image02.ps etc. you are probably OK with *.ps of course.
The files are named as;
file_name01.png
file_name02.png
file_name03.png
etc.
There are 29 files.
Performed following test without result;
1)
$ for i in IDC\ Enterprise\ Panel_20070618/*.png ; do pngtopnm $i | pnmtops > ${i%.png}.ps ; done
Code:
bash: ${i%.png}.ps: ambiguous redirect
pngtopnm: IDC - No such file or directory
bash: ${i%.png}.ps: ambiguous redirect
pngtopnm: IDC - No such file or directory
bash: ${i%.png}.ps: ambiguous redirect
pngtopnm: IDC - No such file or directory
bash: ${i%.png}.ps: ambiguous redirect
pngtopnm: IDC - No such file or directory
bash: ${i%.png}.ps: ambiguous redirect
pngtopnm: IDC - No such file or directory
bash: ${i%.png}.ps: ambiguous redirect
etc.
2)
t$ for i in IDC\ Enterprise\ Panel_20070618/* ; do pngtopnm $i | pnmtops > ${i%.png}.ps ; done
Code:
bash: ${i%.png}.ps: ambiguous redirect
pngtopnm: IDC - No such file or directory
bash: ${i%.png}.ps: ambiguous redirect
pngtopnm: IDC - No such file or directory
bash: ${i%.png}.ps: ambiguous redirect
pngtopnm: IDC - No such file or directory
bash: ${i%.png}.ps: ambiguous redirect
pngtopnm: IDC - No such file or directory
bash: ${i%.png}.ps: ambiguous redirect
pngtopnm: IDC - No such file or directory
bash: ${i%.png}.ps: ambiguous redirect
pngtopnm: IDC - No such file or directory
bash: ${i%.png}.ps: ambiguous redirect
etc.
Failed.
Quote:
The other two solutions posted look reasonable also. I like netpbm because I can control each stage, but if ImageMagick works it may be simpler.
Noted with tks. I'm interested to learn an alternative with command lines.
Or you just could launch OpenOffice Writer (or any app for that matter that can do pdf), add the images and save/export it as a pdf file. I'm not sure how the output quality depends on the program you do, but this is one way. Of course there are other programs that may do more precise output (Scribus?) but I'm not sure if they export pdf.
Tks for your advice.
The quality of .pdf file created is not good, position shifted.
You problem is caused by the spaces in the directory name. There are rules for dealing with this in shell commands, but if you are also doing filename expansion (e.g. using * to match filenames) they are not so easy to understand. Better just rename the directory to get rid of the spaces.
If you really want to know the rules, check the manual page for bash, in the section headed QUOTING.
You problem is caused by the spaces in the directory name. There are rules for dealing with this in shell commands, but if you are also doing filename expansion (e.g. using * to match filenames) they are not so easy to understand. Better just rename the directory to get rid of the spaces.
$ for i in IDC_Enterprise_Panel_20070618/* ; do pngtopnm $i | pnmtops > ${i%.png}.ps ; done
Code:
pnmtops: warning, image too large for page, rescaling to 0.471429
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.471429
pnmtot$ for i in IDC_Enterprise_Panel_20070618/* ; do pngtopnm $i | pnmtops -noturn > ${i%.png}.ps ; done
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pngtopnm: input file not a PNG file
pnmtops: EOF / read error reading magic number
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pngtopnm: input file not a PNG file
pnmtops: EOF / read error reading magic number
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pngtopnm: input file not a PNG file
pnmtops: EOF / read error reading magic number
ps: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.471429
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.471429
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.471429
....
etc.
$ for i in IDC_Enterprise_Panel_20070618/* ; do pngtopnm $i | pnmtops -noturn > ${i%.png}.ps ; done
Code:
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pngtopnm: input file not a PNG file
pnmtops: EOF / read error reading magic number
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pngtopnm: input file not a PNG file
pnmtops: EOF / read error reading magic number
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pngtopnm: input file not a PNG file
pnmtops: EOF / read error reading magic number
....
pngtopnm: input file not a PNG file
pnmtops: EOF / read error reading magic number
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pngtopnm: input file not a PNG file
pnmtops: EOF / read error reading magic number
Still fail. What does it mean "pnmtops: warning, image too large for page, rescaling to 0.364286"
???
Quote:
If you really want to know the rules, check the manual page for bash, in the section headed QUOTING.
I guess it means exactly that. If you don't like the output, try adding options to the pnmtops command to get the effect you want.
The conversion seems to be failing because some of the input files are not PNG files.
On that directory there are .ps and .ps.ps files created. All .ps files exeed 10MB in capacty and .ps.ps files are all empty. the .png files are screenshop only.
If creating them as .ps file one by one, I can make it w/o problem. Can you see what was the cause??? TIA
I wasn't able to create from png files to a pdf directly.
You could create a script to do it, and put it in your ~/bin/ directory.
This one can be called like: pics2pdf book.pdf *.png
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.