## PDF Surfaces

PDF Surfaces — Rendering PDF documents

## Synopsis

    #define             CAIRO_HAS_PDF_SURFACE
    cairo_surface_t*    cairo_pdf_surface_create            (const char *filename,
                                                             double width_in_points,
                                                             double height_in_points);
    cairo_surface_t*    cairo_pdf_surface_create_for_stream (cairo_write_func_t write_func,
                                                             void *closure,
                                                             double width_in_points,
                                                             double height_in_points);
    void                cairo_pdf_surface_set_size          (cairo_surface_t *surface,
                                                             double width_in_points,
                                                             double height_in_points);

## Description

The PDF surface is used to render cairo graphics to Adobe PDF files and is a multi-page vector surface backend.

## Details

### CAIRO_HAS_PDF_SURFACE

    #define CAIRO_HAS_PDF_SURFACE 1

Defined if the PDF surface backend is available. This macro can be used to conditionally compile backend-specific code.

### cairo_pdf_surface_create ()

    cairo_surface_t*    cairo_pdf_surface_create            (const char *filename,
                                                             double width_in_points,
                                                             double height_in_points);

Creates a PDF surface of the specified size in points to be written to `filename`.

`filename` : | a filename for the PDF output (must be writable)
`width_in_points` : | width of the surface, in points (1 point == 1/72.0 inch)
`height_in_points` : | height of the surface, in points (1 point == 1/72.0 inch)
Returns : | a pointer to the newly created surface. The caller owns the surface and should call `cairo_surface_destroy()` when done with it. This function always returns a valid pointer, but it will return a pointer to a "nil" surface if an error such as out of memory occurs. You can use `cairo_surface_status()` to check for this.

Since 1.2

### cairo_pdf_surface_create_for_stream ()

    cairo_surface_t*    cairo_pdf_surface_create_for_stream (cairo_write_func_t write_func,
                                                             void *closure,
                                                             double width_in_points,
                                                             double height_in_points);

Creates a PDF surface of the specified size in points to be written incrementally to the stream represented by `write_func` and `closure`.

`write_func` : | a cairo_write_func_t to accept the output data
`closure` : | the closure argument for `write_func`
`width_in_points` : | width of the surface, in points (1 point == 1/72.0 inch)
`height_in_points` : | height of the surface, in points (1 point == 1/72.0 inch)
Returns : | a pointer to the newly created surface. The caller owns the surface and should call `cairo_surface_destroy()` when done with it. This function always returns a valid pointer, but it will return a pointer to a "nil" surface if an error such as out of memory occurs. You can use `cairo_surface_status()` to check for this.

Since 1.2

### cairo_pdf_surface_set_size ()

    void                cairo_pdf_surface_set_size          (cairo_surface_t *surface,
                                                             double width_in_points,
                                                             double height_in_points);

Changes the size of a PDF surface for the current (and subsequent) pages.

This function should only be called before any drawing operations have been performed on the current page. The simplest way to do this is to call this function immediately after creating the surface or immediately after completing a page with either `cairo_show_page()` or `cairo_copy_page()`.

`surface` : | a PDF cairo_surface_t
`width_in_points` : | new surface width, in points (1 point == 1/72.0 inch)
`height_in_points` : | new surface height, in points (1 point == 1/72.0 inch)

Since 1.2

## See Also

- cairo_surface_t