By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,492 Members | 1,289 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,492 IT Pros & Developers. It's quick & easy.

Generate report containing pdf or ps figures?

P: n/a
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?
Apr 23 '07 #1
Share this Question
Share on Google+
21 Replies


P: n/a
On Apr 23, 6:30 pm, Grant Edwards <gra...@visi.comwrote:
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

Apr 23 '07 #2

P: n/a
On 2007-04-23, Kjell Magne Fauske <kj*****@gmail.comwrote:
>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.
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.

--
Grant Edwards grante Yow! The Korean War must
at have been fun.
visi.com
Apr 23 '07 #3

P: n/a
On Apr 23, 9:30 am, Grant Edwards <gra...@visi.comwrote:
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/graphicsi...andquartz.html

~Sean

Apr 23 '07 #4

P: n/a
On Apr 23, 9:30 am, Grant Edwards <gra...@visi.comwrote:
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.

Apr 23 '07 #5

P: n/a
On 2007-04-23, ha**********@gmail.com <ha**********@gmail.comwrote:
>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?

On a Mac...

http://developer.apple.com/graphicsi...andquartz.html
Something that's easy to do and builtin to MacOS that's
painful or difficult to do under Windows?

Nah, couldn't be...

--
Grant Edwards grante Yow! Kids, don't gross me
at off ... "Adventures with
visi.com MENTAL HYGIENE" can be
carried too FAR!
Apr 23 '07 #6

P: n/a
On 2007-04-23, infidel <sa***********@gmail.comwrote:
>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.
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.

--
Grant Edwards grante Yow! I'm totally DESPONDENT
at over the LIBYAN situation
visi.com and the price of CHICKEN
...
Apr 23 '07 #7

P: n/a
In article <13*************@corp.supernews.com>,
Grant Edwards <gr****@visi.comwrote:
>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?
Apr 24 '07 #8

P: n/a
On 2007-04-24, Cameron Laird <cl****@lairds.uswrote:

[...]
>>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.
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....onverters.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.
I've taken the liberty of cross-posting to c.t.p. Python
alone isn't big enough (yet) to solve your problem.

--
Grant Edwards grante Yow! Did I do an INCORRECT
at THING??
visi.com
Apr 24 '07 #9

P: n/a
Cameron Laird wrote:
In article <13*************@corp.supernews.com>,
Grant Edwards <gr****@visi.comwrote:
>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....onverters.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
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Recent Ramblings http://holdenweb.blogspot.com

Apr 24 '07 #10

P: n/a
On 2007-04-24, Steve Holden <st***@holdenweb.comwrote:
>>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.

--
Grant Edwards grante Yow! I am covered with
at pure vegetable oil and I am
visi.com writing a best seller!
Apr 24 '07 #11

P: n/a
Grant Edwards wrote:
On 2007-04-24, Steve Holden <st***@holdenweb.comwrote:
>>>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
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Recent Ramblings http://holdenweb.blogspot.com

Apr 24 '07 #12

P: n/a
In article <13*************@corp.supernews.com>,
Grant Edwards <gr****@visi.comwrote:
Apr 24 '07 #13

P: n/a
On 2007-04-24, Grant Edwards <gr****@visi.comwrote:
On 2007-04-24, Steve Holden <st***@holdenweb.comwrote:
>>>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.

--
Grant Edwards grante Yow! I want the presidency
at so bad I can already taste
visi.com the hors d'oeuvres.
Apr 24 '07 #14

P: n/a
In article <13*************@corp.supernews.com>,
Grant Edwards <gr****@visi.comwrote:
>>>
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.
Apr 24 '07 #15

P: n/a
On 2007-04-24, Cameron Laird <cl****@lairds.uswrote:
>>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.
.
.
.
<URL: http://www.reportlab.com/pricing.html >
Uh huh, can't afford that. :)

--
Grant Edwards grante Yow! World War Three can
at be averted by adherence
visi.com to a strictly enforced
dress code!
Apr 24 '07 #16

P: n/a
On Tuesday 24 April 2007 20:42, Cameron Laird wrote:
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....onverters.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
Apr 24 '07 #17

P: n/a
Grant Edwards wrote:
On 2007-04-23, Kjell Magne Fauske <kj*****@gmail.comwrote:
>>Is there a PDF generation library that can place EPS or PDF
figures on a page?
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.

H.
Apr 24 '07 #18

P: n/a
On 2007-04-24, David Boddie <da***@boddie.org.ukwrote:
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.
http://pybrary.net/pyPdf/
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. ;)

--
Grant Edwards grante Yow! Hey, waiter! I want
at a NEW SHIRT and a PONY TAIL
visi.com with lemon sauce!
Apr 24 '07 #19

P: n/a
On 2007-04-24, hlubenow <hl*******@gmx.netwrote:
Grant Edwards wrote:
>On 2007-04-23, Kjell Magne Fauske <kj*****@gmail.comwrote:
>>>Is there a PDF generation library that can place EPS or PDF
figures on a page?

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.

--
Grant Edwards grante Yow! This is a NO-FRILLS
at flight -- hold th' CANADIAN
visi.com BACON!!
Apr 24 '07 #20

P: n/a
Cameron Laird wrote:
In article <13*************@corp.supernews.com>,
Grant Edwards <gr****@visi.comwrote:
>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.
<snip>

I have also done quite a bit of work in this area, and keep coming back
to LaTeX (pdfLaTeX). For automatic document production--if you have
a good quantity of very similar documents--you can produce the LaTeX
from XML, hence many other input formats.

The graphics need to be converted into pdf format, and you need to be
careful that the vector nature of the file is preserved during this
conversion, as well as transparency. Unfortunately this is still
uncommon for SVG. Also Adobe seem to have lost their one-time enthusiasm
for SVG, since they acquired Flash and Friends.

A rather new entry into the arena is 'Altsoft Xml2PDF Workstation' which
is free for command-line use, but not for server use. Seems to produce
PDF of reasonable quality and to use vector format, transparency and
gradient fills.

Another possibility is to wrap things up as SMIL. The latest versions of
Acrobat reader can use them, using RealPlayer (for example) as the
actual multimedia engine. There is at least one LaTeX package that can
produce PDF that incorporates such multi-media.

I've rather given up on ReportLab. Trying to extend it (the free part)
to use graduated fills completely did my head in!

May 1 '07 #21

P: n/a
On 2007-04-23, Grant Edwards <gr****@visi.comwrote:
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).
[...]
Is there a PDF generation library that can place EPS or PDF
figures on a page?
I finally gave up trying to generate a PDF report. I did come
up with two alternative solutions that partly work.

1) XHTML+SVG

Unfortunately a lot of SVG renderers are rather broken.
Opera and Firefox both seem to have rather nasty font
sizing issues.

2) PyRTF+EMF

Seems to work pretty well. However, some Unix apps that
support RTF don't include EMF graphics support (Ted and
Abiword appear to fall into that group). Still, it does
work with OOo, MS Word, and with both versions of the
gratis MS Word viewer.

--
Grant Edwards grante Yow! NEWARK has been
at REZONED!! DES MOINES has
visi.com been REZONED!!
May 19 '07 #22

This discussion thread is closed

Replies have been disabled for this discussion.