[cairo] Strange bug (?) when painting/cropping recording surface to PDF surface

Bernhard R. Fischer bf at abenteuerland.at
Sat Apr 9 17:55:19 UTC 2016


Hi!

_Background_
In my project a record all drawing operations to a recording surface.
Finally, to output files I create surfaces of specific backends (PNG,
PDF, and SVG) and "crop" (the final surface is smaller than the
recording source surface), rotate, and paint the recording surface to it.


_Strange Behavior_
When using PDF as backend, not everything is painted from the source
(recording) surface to the PDF surface. On PNG and SVG it works as expected.


_Examples_
There is a PNG and PDF example to show the behavior. Look at the right
lower corner: right of the string "015°30" the short black lines in the
axis are missing compared to the PNG.
http://www.abenteuerland.at/download/eagle/output.pdf
http://www.abenteuerland.at/download/eagle/output.png


_Trigger_
I observed, that this behavior is triggered as soon as the PDF surface
is smaller than the recording surface.


_Code Snippet_
The following code snippets shows how I create the PDF and PNG surface
from the recording surface (sfc_).


	/* create PDF from sfc_ */
	sfc = cairo_pdf_surface_create("output.pdf", width*.7, height*1.3);
	dst = cairo_create(sfc);
	cairo_rotate(dst, DEG2RAD(15));
	cairo_set_source_surface(dst, sfc_, 0, 0);
        cairo_paint(dst);
        cairo_show_page(dst);
        cairo_destroy(dst);
        cairo_surface_destroy(sfc);


	/* create PNG from sfc_ */
         sfc = cairo_image_surface_create(CAIRO_FORMAT_RGB24, width*.7,
height*1.3);
         dst = cairo_create(sfc);
         cairo_rotate(dst, DEG2RAD(15));
         cairo_set_source_surface(dst, sfc_, 0, 0);
         cairo_paint(dst);
         cairo_show_page(dst);
         cairo_destroy(dst);
         cairo_surface_write_to_png(sfc, "output.png");
         cairo_surface_destroy(sfc);


Any hints appreciated.

Best regards,
Bernhard


More information about the cairo mailing list