[cairo] Bounding bos from ps to pdf

Andrea Canciani ranma42 at gmail.com
Tue Aug 17 07:48:34 PDT 2010


On Tue, Aug 17, 2010 at 4:07 PM, omar <opustenom at hotmail.com> wrote:
> To whom it may concern,
>
> I have a problem using cairo for displaying connections between a number of
> coordinates. The
> generated file should be of PDF format.
> Namely, I'm trying to translate the content of a specific .ps file, having a
> bounding box specification.
> This would be a typical .ps file:
> %
> %%BoundingBox: -54.842 -5.44374 -34.9815 10.3711
> newpath
> -52.8476 -4.20964 moveto
> -53.9752 -3.93121 lineto
> -53.2801 -3.06407 moveto
> -53.9752 -3.93121 lineto
> -54.842 -4.58826 moveto
> -53.9752 -3.93121 lineto
> ...........
> I understand how to draw a line between 2 coordinates, but I'm not sure how to
> specify the bounding box for
> PDF format.
> Clearly, the drawing should fit within the specified bounding box (which
> specifies min and max coordinates
> from the drawing).

You can set the size of a PDF surface (width and height) with
cairo_pdf_surface_set_size.

To offset the top left corner you can use cairo_translate or
cairo_surface_set_device_offset.


More information about the cairo mailing list