Generate report containing pdf or ps figures?

G

Grant Edwards

I need to be able to generate a PDF report which consists
mostly of vector images (which I can generate as encapsulated
Postscript, PDF, or SVG). What I need is a way to combine
these figures into a single PDF document. Right now the
reports consist entire of these figures, so I just write the
figures out to temp files and then use os.system() to run
ghostscript with appropriate options to combine them into a
single PDF file.

I'd like to be able to add some text and/or place the figures
in a manner other than one per page in the output document.

I've looked at ReportLab's documentation, but although it
appears to be able to use bitmap images (e.g jpeg) it doesn't
appear to be able to use vector images (EPS/PDF/SVG).

Is there a PDF generation library that can place EPS or
PDF figures on a page?
 
K

Kjell Magne Fauske

I need to be able to generate a PDF report which consists
mostly of vector images (which I can generate as encapsulated
Postscript, PDF, or SVG). What I need is a way to combine
these figures into a single PDF document. Right now the
reports consist entire of these figures, so I just write the
figures out to temp files and then use os.system() to run
ghostscript with appropriate options to combine them into a
single PDF file.

I'd like to be able to add some text and/or place the figures
in a manner other than one per page in the output document.

I've looked at ReportLab's documentation, but although it
appears to be able to use bitmap images (e.g jpeg) it doesn't
appear to be able to use vector images (EPS/PDF/SVG).

Is there a PDF generation library that can place EPS or
PDF figures on a page?

If you are familiar with LaTeX, an easy solution would be to
automatically generate a LaTeX document that includes your images.
This also allows you to add captions, scale the images and much more.
You can then run the generated document through pdflatex and you have
a nice looking report.

Regards,
Kjell Magne Fauske
http://www.fauskes.net
 
G

Grant Edwards

If you are familiar with LaTeX, an easy solution would be to
automatically generate a LaTeX document that includes your
images.

Yea, I've been using TeX and LaTeX for 20+ years. :) I worked
on a DoD project back in the 80's where we generated a 1000+
page requirements spec using LaTeX. It had to be broken up
into a few dozen separate documents because LaTeX under VAX/VMS
kept overflowing various internal counters. Doing a build of
the document kept a VAX 780 busy most of the night.

However, bundling a working copy of LaTeX with my Python app
doesn't fall into the "easy" category. This app needs to be
moderately cross-platform and "distributable". Using either
LaTeX or Ghostscript (my current solution) makes it rather
painful to bundle up the app and distrubute it.
 
H

half.italian

I need to be able to generate a PDF report which consists
mostly of vector images (which I can generate as encapsulated
Postscript, PDF, or SVG). What I need is a way to combine
these figures into a single PDF document. Right now the
reports consist entire of these figures, so I just write the
figures out to temp files and then use os.system() to run
ghostscript with appropriate options to combine them into a
single PDF file.

I'd like to be able to add some text and/or place the figures
in a manner other than one per page in the output document.

I've looked at ReportLab's documentation, but although it
appears to be able to use bitmap images (e.g jpeg) it doesn't
appear to be able to use vector images (EPS/PDF/SVG).

Is there a PDF generation library that can place EPS or
PDF figures on a page?

--
Grant Edwards grante Yow! Is a tattoo real, like
at a curb or a battleship?
visi.com Or are we suffering in
Safeway?

On a Mac...

http://developer.apple.com/graphicsimaging/pythonandquartz.html

~Sean
 
I

infidel

I need to be able to generate a PDF report which consists
mostly of vector images (which I can generate as encapsulated
Postscript, PDF, or SVG). What I need is a way to combine
these figures into a single PDF document. Right now the
reports consist entire of these figures, so I just write the
figures out to temp files and then use os.system() to run
ghostscript with appropriate options to combine them into a
single PDF file.

I'd like to be able to add some text and/or place the figures
in a manner other than one per page in the output document.

I've looked at ReportLab's documentation, but although it
appears to be able to use bitmap images (e.g jpeg) it doesn't
appear to be able to use vector images (EPS/PDF/SVG).

Is there a PDF generation library that can place EPS or
PDF figures on a page?

I've had great success using Apache's FOP utility (http://
xmlgraphics.apache.org/fop) to generate PDFs out of XSL-FO, which can
contain SVG graphics (at least the 0.20.5 version can, the newer
rewrite version doesn't yet). FOP is a java library but has a
suitable command line interface.
 
G

Grant Edwards

I've had great success using Apache's FOP utility (http://
xmlgraphics.apache.org/fop) to generate PDFs out of XSL-FO, which can
contain SVG graphics (at least the 0.20.5 version can, the newer
rewrite version doesn't yet). FOP is a java library but has a
suitable command line interface.

Unfortunately, trying to bundle a Java installation with
my app is going to be harder than bundling Ghostscript or
LaTeX (the other two solutions that come to mind).

I should have mentioned it in my OP, but I need something
that's cross-platform (At least Linux and Windows), and not
difficult to bundle using something like py2exe.
 
C

Cameron Laird

I need to be able to generate a PDF report which consists
mostly of vector images (which I can generate as encapsulated
Postscript, PDF, or SVG). What I need is a way to combine
these figures into a single PDF document. Right now the
reports consist entire of these figures, so I just write the
figures out to temp files and then use os.system() to run
ghostscript with appropriate options to combine them into a
single PDF file.

I'd like to be able to add some text and/or place the figures
in a manner other than one per page in the output document.

I've looked at ReportLab's documentation, but although it
appears to be able to use bitmap images (e.g jpeg) it doesn't
appear to be able to use vector images (EPS/PDF/SVG).

Is there a PDF generation library that can place EPS or
PDF figures on a page?
.
.
.
You're stuck.

If I understand what you're after, you're probably going to
end up finding a way to leverage Ghostscript. There are a
lot of ways to move forward in this area, but GS has most of
'em beat, despite all its liabilities.

That's my summary. I've done quite a bit in this area, and
am happy to talk about specifics.

I have two recommendations: see if anything in <URL:
http://phaseit.net/claird/comp.text.pdf/PDF_converters.html >
resonates with you; and e-mail the nice folks at <URL:
http://www.pdf-tools.com/ >.

I've taken the liberty of cross-posting to c.t.p. Python
alone isn't big enough (yet) to solve your problem.
 
G

Grant Edwards

[...]
.
.
.
You're stuck.

If I understand what you're after, you're probably going to
end up finding a way to leverage Ghostscript. There are a
lot of ways to move forward in this area, but GS has most of
'em beat, despite all its liabilities.

Yup, GS is what I'm using now, and it's working fine. I was
hoping there would be something that'd be easier to bundle as
part of a Win32 application. You can pretty much except a
Linux platform to have ghostscript available, but for Win32
users it'll have to be bundled. :/
That's my summary. I've done quite a bit in this area, and
am happy to talk about specifics.

I have two recommendations: see if anything in <URL:
http://phaseit.net/claird/comp.text.pdf/PDF_converters.html >
resonates with you; and e-mail the nice folks at <URL:
http://www.pdf-tools.com/ >.

Thanks. I'll take a look at those.

It's too bad that ReportLab can't use vector image formats such
as PDF or SVG. I would have thought that sticking a PDF image
into a PDF document would be a pretty straight-forward thing to
do, but it must not be something in high demand.
 
S

Steve Holden

Cameron said:
.
.
.
You're stuck.

If I understand what you're after, you're probably going to
end up finding a way to leverage Ghostscript. There are a
lot of ways to move forward in this area, but GS has most of
'em beat, despite all its liabilities.

That's my summary. I've done quite a bit in this area, and
am happy to talk about specifics.

I have two recommendations: see if anything in <URL:
http://phaseit.net/claird/comp.text.pdf/PDF_converters.html >
resonates with you; and e-mail the nice folks at <URL:
http://www.pdf-tools.com/ >.

I've taken the liberty of cross-posting to c.t.p. Python
alone isn't big enough (yet) to solve your problem.

In fairness to ReportLab I'd like to say that their *commercial*
products can do everything the OP asks for and more besides, but
unfortunately they are mostly targeted at the "enterprise" (read: big
money) market.

regards
Steve
 
G

Grant Edwards

.
.
.
You're stuck.
[...]

In fairness to ReportLab I'd like to say that their *commercial*
products can do everything the OP asks for and more besides, but
unfortunately they are mostly targeted at the "enterprise" (read: big
money) market.

This is just a smallish app for internal use by 1-2 people, so
I probably can't justify spending much cash. I'll check on the
ReportLab pricing. By the time I figure out how to bundle
Ghostscript with py2exe, it will probably have been cheaper to
pay for a copy of ReportLab. But it's usually easier to spend
a week of engineering time that it is to spend $1000.
 
S

Steve Holden

Grant said:
I've looked at ReportLab's documentation, but although it
appears to be able to use bitmap images (e.g jpeg) it doesn't
appear to be able to use vector images (EPS/PDF/SVG).

Is there a PDF generation library that can place EPS or
PDF figures on a page?
.
.
.
You're stuck.
[...]
In fairness to ReportLab I'd like to say that their *commercial*
products can do everything the OP asks for and more besides, but
unfortunately they are mostly targeted at the "enterprise" (read: big
money) market.

This is just a smallish app for internal use by 1-2 people, so
I probably can't justify spending much cash. I'll check on the
ReportLab pricing. By the time I figure out how to bundle
Ghostscript with py2exe, it will probably have been cheaper to
pay for a copy of ReportLab. But it's usually easier to spend
a week of engineering time that it is to spend $1000.
In which case you can safely spend almost six months before anyone
complains about the cost justification :-(

regards
Steve
 
C

Cameron Laird

.
.
.
part of a Win32 application. You can pretty much except a
Linux platform to have ghostscript available, but for Win32
users it'll have to be bundled. :/ .
.
.
It's too bad that ReportLab can't use vector image formats such
as PDF or SVG. I would have thought that sticking a PDF image
into a PDF document would be a pretty straight-forward thing to
do, but it must not be something in high demand.
.
.
.
I want to make sure we're all keeping up with each other, so
I'll make explicit a couple of points, despite the risk of
redundancy:
A. Bundling GS is a little touchy, depending on
what you mean by that. Check out its license.
My summary: it's feasible, but not as trans-
parent as the technology in isolation might
suggest.
B. As Steve's already noted, the for-fee ReportLab
*does* (at least some of) the things you want.
 
G

Grant Edwards

I've looked at ReportLab's documentation, but although it
appears to be able to use bitmap images (e.g jpeg) it doesn't
appear to be able to use vector images (EPS/PDF/SVG).

Is there a PDF generation library that can place EPS or
PDF figures on a page?
.
.
.
You're stuck.
[...]

In fairness to ReportLab I'd like to say that their *commercial*
products can do everything the OP asks for and more besides, but
unfortunately they are mostly targeted at the "enterprise" (read: big
money) market.

This is just a smallish app for internal use by 1-2 people, so
I probably can't justify spending much cash. I'll check on
the ReportLab pricing.

I can't even find any mention of a commercial version of
ReportLab on the web site. The FAQ says ReportLib is available
under the BSD license. Period.

There are some other "projects" listed, but they don't appear
to be relevent.
 
D

David Boddie

I want to make sure we're all keeping up with each other, so
I'll make explicit a couple of points, despite the risk of
redundancy:
A. Bundling GS is a little touchy, depending on
what you mean by that. Check out its license.
My summary: it's feasible, but not as trans-
parent as the technology in isolation might
suggest.

I'm surprised you don't have more suggestions, Cameron, given that you
collect links to PDF convertors. ;-)

http://phaseit.net/claird/comp.text.pdf/PDF_converters.html
B. As Steve's already noted, the for-fee ReportLab
*does* (at least some of) the things you want.

Another interesting approach might be to look at other members of
ReportLab's family tree:

http://sping.sourceforge.net/
http://sping.sourceforge.net/notesPDF/index.html

However, it doesn't seem that either are capable of inserting the kinds of
vector files you are using.

It may be worth writing a quick and dirty PDF writer using an existing
backend library, though I can imagine that the hard work would involve
reading the different input formats you want to use.

Anyway, for future reference, the following projects might prove to be
inspiring:

http://pyx.sourceforge.net/
http://pybrary.net/pyPdf/

David
 
G

Grant Edwards

However, it doesn't seem that either are capable of inserting the kinds of
vector files you are using.

It may be worth writing a quick and dirty PDF writer using an
existing backend library, though I can imagine that the hard
work would involve reading the different input formats you
want to use.

I can generate quite a few different vector formats, and I'll
use whichever one the library can accept.
Anyway, for future reference, the following projects might prove to be
inspiring:

http://pyx.sourceforge.net/

It looks like that's Postscript output rather than PDF.

That's almost what I'm looking for, except it appears it can
only rotate/crop pages and not scale/translate them.

I've been looking at the new version (4.20 of Gnuplot, and some
features have been added to the pdf terminal type that almost
solves my problem as well. It appears I've got a number of 80%
solutions from which to choose. ;)
 
G

Grant Edwards

What about

http://pybrary.net/pyPdf/

It does some very interesting things. But I'm not really sure, if it does
what you're after. At least it can merge one page onto another.

It's close to what I was looking for, except I'd like to be
able to scale and translate pages (e.g. so I can print them
2-up). Based on the documentation and examples, it looks like
it can only rotate and crop. Still, it's probably closer than
the other options, so it's worth a closer look.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top