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 B.R. satimis |
One image per page? You could try this, using the netpbm package. First convert the files to Postscript bitmaps:
pngtopnm image.png | pnmtops > image.ps 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: gs -q -dNOPAUSE -dBATCH -sOutputFile=all.pdf -sDEVICE=pdfwrite *.ps If you want other than alphabetical order you will have to specify the .ps individually as a an argument list. |
You could also use ImageMagick.
convert *.png book.mng convert book.mng book.pdf |
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.
|
Hi maroonbaboon,
Tks for your advice. Quote:
Quote:
Quote:
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:
Code:
for i in *.png ; do pngtopnm $i | pnmtops > ${i%.png}.ps ; done \ Quote:
B.R. satimis |
To answer your questions:
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. |
Quote:
Tks for your advice. $ sudo apt-cache showpkg imagemagick Code:
Package: imagemagick $ which convert /usr/bin/convert $ convert /path/to/dir/* book.mng $ convert book.mng book.pdf Done. A .pdf file created. Can I run a single command line to do the job; $ convert /path/to/dir/* | convert - book.pdf ??? TIA B.R. satimis |
Hi maroonbaboon,
Quote:
works for me. Tks. Quote:
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 2) t$ for i in IDC\ Enterprise\ Panel_20070618/* ; do pngtopnm $i | pnmtops > ${i%.png}.ps ; done Code:
bash: ${i%.png}.ps: ambiguous redirect Quote:
B.R. satimis |
Hi b0uncer,
Quote:
The quality of .pdf file created is not good, position shifted. Scribus is not running on this box. B.R. satimis |
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. |
Quote:
$ 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 Code:
pnmtops: warning, image too large for page, rescaling to 0.364286 Still fail. What does it mean "pnmtops: warning, image too large for page, rescaling to 0.364286" ??? Quote:
B.R. satimis |
Quote:
The conversion seems to be failing because some of the input files are not PNG files. |
Quote:
If creating them as .ps file one by one, I can make it w/o problem. Can you see what was the cause??? TIA B.R. satimis |
When you use
for i in IDC_Enterprise_Panel_20070618/* you are trying to process all files, not just PNG ones. You need for i in IDC_Enterprise_Panel_20070618/*.png |
Quote:
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 Code:
#!/bin/bash |
All times are GMT -5. The time now is 09:42 PM. |