[cairo] copying cairo surfaces to pdf/svg surface
Maarten Bosmans
mkbosmans at gmail.com
Wed Nov 30 01:29:27 PST 2011
2011/11/29 Zoltán Vörös <zvoros at gmail.com>:
> Hi All,
>
> I have a cairo surface that is implemented as a gdk drawable, and I would
> like to save the content as a pdf file. However, if I do this
>
> surface = cairo.PDFSurface('pdffile.pdf', 800, 1200);
> cairo_ctx = cairo.Context(surface)
> cairo_ctx.set_source_surface(drawable_surface, 0, 0)
> cairo_ctx.paint()
> cairo_ctx.show_page()
>
> then the output looks grainy, and it seems as if the content was saved as a
> bitmap image, and not as a vector file. (The drawable is about 400 times 500
> pixels large, but it does not really matter). My question is whether it is
> possible to force cairo to take the drawable_surface's content as a set of
> vector objects, or I have to re-draw the content to the pdf surface?
> Thanks,
> Zoltán
The gdk drawable is inherently a bitmap surface, there's no way around that.
If it's your own drawing you want to save to pdf, you can use a tee
surface or a recording surface.
Maarten
More information about the cairo
mailing list