The way to get the surface status is to call cairo_surface_finish() to finish writing the PS or PDF file. Then cairo_surface_status() can be called to obtain the final status before calling cairo_surface_destroy() to release the surface object.
If cairo detects an error while writing a PS/PDF file it will set the
surface status to something other than CAIRO_STATUS_SUCCESS and abort
writing the file or stream. In this case the PS/PDF file will almost
certainly be in a broken state and the error should be reported to the user.
Comments:
[ellson] Thanks for this. Its in CVS
[adrian] I just checked out CVS and it appears to be missing this one line from the patch:
+ status = cairo_surface_status(surface);
[ellson] Got it. Thx.
Fix:
This is the patch that I used to get the cairo status.
Index: plugin/pango/gvrender_pango.c
===================================================================
RCS file: /home/cvsroot/graphviz2/plugin/pango/gvrender_pango.c,v
retrieving revision 1.55
diff -u -p -r1.55 gvrender_pango.c
--- plugin/pango/gvrender_pango.c 24 Dec 2007 04:26:41 -0000 1.55
+++ plugin/pango/gvrender_pango.c 10 Jan 2008 07:41:03 -0000
@@ -187,6 +187,7 @@ static void cairogen_end_page(GVJ_t * jo
{
cairo_t *cr = (cairo_t *) job->context;
cairo_surface_t *surface;
+ cairo_status_t status;
switch (job->render.id) {
@@ -201,8 +202,14 @@ static void cairogen_end_page(GVJ_t * jo
case FORMAT_PDF:
case FORMAT_SVG:
cairo_show_page(cr);
+ surface = cairo_surface_reference(cairo_get_target(cr));
cairo_destroy(cr);
job->context = NULL;
+ cairo_surface_finish(surface);
+ status = cairo_surface_status(surface);
+ cairo_surface_destroy(surface);
+ if (status != CAIRO_STATUS_SUCCESS)
+ fprintf(stderr, "cairo: %sn", cairo_status_to_string(status));
break;
case FORMAT_CAIRO: