On 18 March 2011 09:18, David Jones <[email protected]> wrote: > Notes and slides (and a script to convert SVG files to PNG) for my > short presentation last night are here: > > > http://code.google.com/p/ccc-gistemp/source/browse/#svn%2Ftrunk%2Fdoc%2F2011-03-15%2Fpython3
I really enjoyed the session on Thursday. It's was real eye-opener. Many thanks for the slides and for volunteering to (a) lay bare your code and (b) grin and bear porting it in front of a barking audience! For those that couldn't attend, I'll post some brief meeting notes in due course. > > I added this link to our Wiki (which I almost forgot we had): > http://pynw.org.uk/Talks It hasn't forgotten you ;) > > Now, how do I convert 5 InkScape SVG files into one PDF? Or is there > some other way I should bundle my presentation? > Interesting question. Anand in last month's meeting showed us how he uses wkhtmltopdf (http://code.google.com/p/wkhtmltopdf/) to convert svg to pdf. Using this followed by pdftk would do the trick. The following just about gets you there in bash, the only issue being centralisation of text in the PDF so options to wkhtmltopdf might need tweaking: for i in slide*.svg; do wkhtmltopdf -O landscape $i ${i%svg}pdf; done; pdftk slide*.pdf cat output presentation.pdf For something more Pythonic to convert SVG to PDF, I've always kept the following under my pillow which uses Cairo and rsvg. Disclaimer: I've not used it for a while and haven't got round to installing rsvg yet on my newish laptop: import sys import os import cairo import rsvg def size_points(svg): props = svg.props return props.width / props.dpi_x * 72, props.height / props.dpi_y * 72 infile = sys.argv[1] outfile = sys.argv[2] if len(sys.argv) > 2 else os.path.splitext(infile)[0] + '.pdf' svg = rsvg.Handle(file=infile) with open(outfile, 'wb') as fout: surface = cairo.PDFSurface(fout, *size_points(svg)) ctx = cairo.Context(surface) svg.render_cairo(ctx) surface.finish() Cheers, Safe > Cheers, > drj > > -- > To post: [email protected] > To unsubscribe: [email protected] > Feeds: http://groups.google.com/group/python-north-west/feeds > More options: http://groups.google.com/group/python-north-west > -- To post: [email protected] To unsubscribe: [email protected] Feeds: http://groups.google.com/group/python-north-west/feeds More options: http://groups.google.com/group/python-north-west
