20.01.2013 Views

ReportLab Graphics and SVG Integratation

ReportLab Graphics and SVG Integratation

ReportLab Graphics and SVG Integratation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

portLab<br />

epor ReportL<br />

portLa<br />

#!/usr/bin/env python<br />

portLa<br />

Sample code: <strong>SVG</strong> to PNG "tool"<br />

Repor Rep<br />

"svg2png.py"<br />

portL Repor<br />

import sys<br />

from os.path import splitext<br />

from reportlab.graphics import renderPM<br />

from svglib import svg2rlg<br />

inPath = sys.argv[1]<br />

drawing = svg2rlg(inPath)<br />

outPath = splitext(inPath)[0] + '.png'<br />

renderPM.drawToFile(drawing, outPath, 'PNG')

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!