471,353 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,353 software developers and data experts.

automatical pdf generating

Hi, all,

There are 50 folders in my hard driver C:
C:\01.c:\02,...,c:\50

There are 4 pictures in each folder:
1.jpg,2.jpg,3.jpg,4.jpg

For each folder, I want to print the 4 pictures into a single-paged
pdf file (letter sized; print horizontally). All together, I want to
get 50 pdf files with names: 01.pdf,02.pdf,...,50.pdf.

Is it possible to use Python to realized the above process? I know
there is a module named "reportlab". Is there any easy command in the
module to do my job?

Thanks

Jackie

Jun 24 '07 #1
6 1167
Jackie wrote:
Hi, all,

There are 50 folders in my hard driver C:
C:\01.c:\02,...,c:\50

There are 4 pictures in each folder:
1.jpg,2.jpg,3.jpg,4.jpg

For each folder, I want to print the 4 pictures into a single-paged
pdf file (letter sized; print horizontally). All together, I want to
get 50 pdf files with names: 01.pdf,02.pdf,...,50.pdf.

Is it possible to use Python to realized the above process? I know
there is a module named "reportlab". Is there any easy command in the
module to do my job?

Thanks

Jackie
Generate HTML for such pages, open them with OpenOffice, and
have OpenOffice generate the PDF file.

John Nagle
Jun 24 '07 #2
Is it possible to use Python to realized the above process?
I know there is a module named "reportlab".
Possible? Yes!

Jun 24 '07 #3
On 2007-06-24, Jackie <ja*********@gmail.comwrote:
For each folder, I want to print the 4 pictures into a single-paged
pdf file (letter sized; print horizontally). All together, I want to
get 50 pdf files with names: 01.pdf,02.pdf,...,50.pdf.

Is it possible to use Python to realized the above process?
Yes.
I know there is a module named "reportlab". Is there any easy
command in the module to do my job?
Yes.

http://www.reportlab.org/rl_toolkit.html
http://www.reportlab.com/docs/userguide.pdf

--
Grant Edwards grante Yow! You mean you don't
at want to watch WRESTLING
visi.com from ATLANTA?
Jun 24 '07 #4
On Jun 24, 10:03 pm, Grant Edwards <gra...@visi.comwrote:
On 2007-06-24, Jackie <jackie.B...@gmail.comwrote:
For each folder, I want to print the 4 pictures into a single-paged
pdf file (letter sized; print horizontally). All together, I want to
get 50 pdf files with names: 01.pdf,02.pdf,...,50.pdf.
Is it possible to use Python to realized the above process?

Yes.
I know there is a module named "reportlab". Is there any easy
command in the module to do my job?

Yes.

http://www.reportlab.org/rl_toolkit..../userguide.pdf

--
Grant Edwards grante Yow! You mean you don't
at want to watch WRESTLING
visi.com from ATLANTA?
There are many different ways to do what you want, as the other
replies say.

1. If you're not a programmer, the OpenOffice suggestion is good.

2.1 If you're a programmer, read up on the ReportLab docs shown in a
previous reply by Grant Edwards, and try it out. Equivalently, you
could use Ruby and PDF::Writer. Both ReportLab and PDF::Writer have
support for creating PDFs with images, and both Python and Ruby can
automate the part of iterating over the multiple files and
directories.

2.2 Also you could try another approach - use some scripting language
like Python (or Perl or Ruby) together with one of the free PDF
creation / conversion tools that you can easily find on the Internet
by a Google search (using suitable keywords like "HTML to PDF", "PDF
conversion", etc. Make sure to try out various combinations /
variations of keywords if you don't get a solution at once - this is
fundamental to Web searching.

And ... if you're not a programmer, consider becoming one :-)
It's good fun, and will help you do a lot of things ...

Vasudev Ram
http://www.dancingbison.com
http://jugad.livejournal.com
http://sourceforge.net/projects/xtopdf

Jun 24 '07 #5
On 6/24/07, Jackie <ja*********@gmail.comwrote:
Hi, all,

There are 50 folders in my hard driver C:
C:\01.c:\02,...,c:\50

There are 4 pictures in each folder:
1.jpg,2.jpg,3.jpg,4.jpg

For each folder, I want to print the 4 pictures into a single-paged
pdf file (letter sized; print horizontally). All together, I want to
get 50 pdf files with names: 01.pdf,02.pdf,...,50.pdf.

Is it possible to use Python to realized the above process? I know
there is a module named "reportlab". Is there any easy command in the
module to do my job?
It might be easier for you to use a simpler scripting language, like
bash. I realize that you're on Windows, but I've done a lot of neat
things to do PDF transformations in the past with bash and pdftk. In
addition to pdftk, there are a number of other open source tools for
manipulating pdfs (and I believe you can also use ImageMagick and
treat them as images). It might be worthwhile to install Cygwin and
explore this option.
--
Evan Klitzke <ev**@yelp.com>
Jun 25 '07 #6
Jackie <ja*********@gmail.comwrote:
There are 50 folders in my hard driver C:
C:\01.c:\02,...,c:\50

There are 4 pictures in each folder:
1.jpg,2.jpg,3.jpg,4.jpg

For each folder, I want to print the 4 pictures into a single-paged
pdf file (letter sized; print horizontally). All together, I want to
get 50 pdf files with names: 01.pdf,02.pdf,...,50.pdf.
ImageMagick eats this sort of thing for lunch. It is a set of command
line tools for unix. You can get them with cygwin also

Eg

montage -geometry 1000x1000+100+100 1.jpg 2.jpg 3.jpg 4.jpg 01.pdf

Which resizes each image to a max dimension of 1000 pixels and then
tiles them into a PDF.
--
Nick Craig-Wood <ni**@craig-wood.com-- http://www.craig-wood.com/nick
Jun 25 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by paul | last post: by
reply views Thread by Dan Gass | last post: by
17 posts views Thread by flupke | last post: by
3 posts views Thread by skn | last post: by
3 posts views Thread by Raed Sawalha | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.