[cairo] Cairo PDF output doesn't render in Acrobat

Adrian Johnson ajohnson at redneon.com
Fri Apr 25 04:18:26 PDT 2008

Nick De Roeck wrote:
> Hi,
> First of all my sincere admiration for all your nice work with Cairo.
> This library is fantastic!
> I've got an issue with the PDF output of Cairo 1.6.4. If you run the
> code below you'll end up with a PDF file (in attachment) which doesn't
> render in Acrobat (8.1.2), with the error: 'a drawing error occured'.
> I've tested this file also with OSX 1.5.2 Preview.app, which displays
> the file just fine.

>  // multi-step radial gradient
> cairo_pattern_t
> *lPattern=cairo_pattern_create_radial(52.5937,46.3297,0,52.5937,46.3297,53.3345);
> cairo_pattern_add_color_stop_rgba(lPattern,0,1,1,0,1);
> cairo_pattern_add_color_stop_rgba(lPattern,0.522222,1,0.8,0,1);
> cairo_pattern_add_color_stop_rgba(lPattern,0.988889,1,0.6,0,1);

The problem here is the last stop is not 1.0. PDF requires the first and 
last stop to be the same as the first and last values of the gradient 
function domain which in cairo generated PDFs is 0.0 and 1.0.

The cairo PDF linear gradient code will, when the first and last stops 
are not 0.0 and 1.0, move the end points of the gradient line to the end 
stops so the generated PDF gradients always have stops at 0 and 1.

The cairo PDF radial gradient code does not do this. This is a bug. 
Until this is fixed I suggest ensuring you always have stops at 0.0 and 1.0.

More information about the cairo mailing list