[cairo] cropping an SVG image
jan aerts (RI)
jan.aerts at bbsrc.ac.uk
Mon May 7 09:40:55 PDT 2007
Daniel,
Looks like I got it working, but I don't entirely understand why... The
code looks like this (using the ruby bindings):
<BEGIN CODE SNIPPET>
big_surface = Cairo::SVGSurface.new('big.svg', 200, 500)
big_context = Cairo::Context.new(big_surface)
# Draw 2 rectangles
big_context.set_source_rgb(1,1,0)
big_context.rectangle(20,20,50,50).fill
big_context.rectangle(50,50,80,80).fill
# big_context.show_page
# big_surface.finish
small_surface = Cairo::SVGSurface.new('small.svg', 100,100)
small_context = Cairo::Context.new(small_surface)
small_context.set_source(big_surface,0,0)
small_context.rectangle(0,0,100,100).fill
small_context.show_page
small_surface.finish
<END CODE SNIPPET>
The file 'big.svg' shows no rectangles at all unless I uncomment the
big_context.show_page line, but it's created even though the
big_surface.finish line is commented out...
Where would I find a full-blown explanation (and simple to understand
for a novice) of what all the different methods do?
Thanks,
jan.
-----Original Message-----
From: Daniel Amelang [mailto:daniel.amelang at gmail.com]
Sent: 07 May 2007 06:22
To: jan aerts (RI)
Cc: cairo at cairographics.org
Subject: Re: [cairo] cropping an SVG image
On 5/2/07, jan aerts (RI) <jan.aerts at bbsrc.ac.uk> wrote:
> All,
>
> Is it in any way possible to crop an SVG surface? I've found code in
> one of Carl's answers to do the very thing for PNGs
> (http://lists.freedesktop.org/archives/cairo/2007-March/009988.html),
> but I just can't get it to work for an SVG or PDF... The trick seemed
> to be to create a smaller surface and copy the wanted part from the
> big surface onto that one.
Hi Jan, yes, that technique should work for SVG and PDF (AFAIK). Can you
share some code with us and explain how your expected results and
observed results differ?
Dan
More information about the cairo
mailing list