Discussion:
[reportlab-users] SVGlib howto
Martin Herceg
2004-04-23 15:07:54 UTC
Permalink
halo,
can u help me pls with SVG library?
i need some example how can i draw converted (from SVG2RTG) graphics
thanx
--
Martin Herceg
==========================================
Dinu Gherman
2004-04-24 08:58:58 UTC
Permalink
Post by Martin Herceg
halo,
can u help me pls with SVG library?
i need some example how can i draw converted (from SVG2RTG) graphics
thanx
Hi Martin,

I'm not sure I know what you mean by SVG2RTG, but I assume you mean
SVG2RLG, where RLG means "ReportLab Graphics". The svglib module
that you have probably downloaded from the following page contains
eight sample SVG files plus their PDF equivalents generated by
svglib: http://python.net/~gherman/svglib.html .

Here's what I do to convert one such sample SVG file to PDF:

[localhost:svglib/sources] dinu% python svglib.py
svglib.py (v. 0.5) - an experimental SVG to RLG/PDF converter
Usage: python svglib.py [--help] <file1.svg(z)> [<file2.svg(z)> ...]
[localhost:svglib/sources] dinu%
[localhost:svglib/sources] dinu% python svglib.py ../samples/newlion.svg
../samples/newlion.svg
[localhost:svglib/sources] dinu%

I hope that helps.

Dinu

--
Dinu C. Gherman - http://python.net/~gherman
......................................................................
"Terrorism is the war of the poor, and war is the terrorism
of the rich." (Peter Ustinov)
Martin Herceg
2004-04-24 15:03:23 UTC
Permalink
hi dinu
Post by Dinu Gherman
SVG2RLG, where RLG means "ReportLab Graphics". The svglib module
u have right its SVG2RLG
but my my problem is here
u write in svglib.py
=A0 =A0 from svglib import svg2rlg, svg2pdf
=A0 =A0 drawing =3D svg2rlg('foo.svg') # then use drawing as you like...
but what next
i need explain how can i draw object "drawing" on canvas?
=2D-=20
Martin Herceg
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Dinu Gherman
2004-04-26 06:45:00 UTC
Permalink
drawing = svg2rlg('foo.svg') # then use drawing as you like...
but what next i need explain how can i draw object "drawing"
on canvas?
Try this:

drawing = svg2rlg(svgPath)
drawing.drawOn(canvas, x, y)

Dinu

--
Dinu C. Gherman - http://python.net/~gherman
......................................................................
"The first principle is that you must not fool yourself - and you are
the easiest person to fool." (Richard Feynman)
Andy Robinson
2004-04-26 12:26:40 UTC
Permalink
Post by Martin Herceg
i need explain how can i draw object "drawing" on canvas?
Drawing objects are the core of reportlab/graphics and this
no longer concerns SVG. Possible ways to use them are...

Draw on a canvas:
from reportlab.graphics import renderPDF
renderPDF.draw(myDrawing, myCanvas, x, y)

Include in a story in Platypus:
story.append(myDrawing)

Save to a standalone PDF file:

renderPDF.drawToFile(myDrawing, filename)
or call
myDrawing.save(...)

See the docstring for reportlab/graphics/shapes.py, class Drawing, method
save
for help on the many args to the last one.

HTH,

Andy

Loading...