cairo::pdf_surface
The PDF surface is used to render cairo graphics to Adobe PDF files and is a multi-page vector surface backend.
Index
Functions
fn add_outline(surface: *cairo::surface_t, parent_id: int, utf8: str, link_attribs: str, flags: cairo::pdf_outline_flags_t) int;
fn create(filename: str, width_in_points: f64, height_in_points: f64) (*cairo::surface_t | cairo::error);
fn set_metadata(surface: *cairo::surface_t, metadata: cairo::pdf_metadata_t, utf8: str) void;
fn set_page_label(surface: *cairo::surface_t, label: str) void;
fn set_size(surface: *cairo::surface_t, width_in_points: f64, height_in_points: f64) void;
fn set_thumbnail_size(surface: *cairo::surface_t, width: int, height: int) void;
Functions
fn add_outline
fn add_outline(surface: *cairo::surface_t, parent_id: int, utf8: str, link_attribs: str, flags: cairo::pdf_outline_flags_t) int;
Adds an item to the document outline hierarchy with the name utf8 that links to the location specified by link_attribs. Link attributes have the same keys and values as the [Link Tag], excluding the "rect" attribute. The item will be a child of the item with id parent_id. Use cairo::PDF_OUTLINE_ROOT as the parent id of top level items.
Parameters
- surface: a PDF cairo::surface_t
- parent_id: the id of the parent item or cairo::PDF_OUTLINE_ROOT if this is a top level item.
- utf8: the name of the outline
- link_attribs: the link attributes specifying where this outline links to
- flags: outline item flags
Returns the id for the added item.
fn create
fn create(filename: str, width_in_points: f64, height_in_points: f64) (*cairo::surface_t | cairo::error);
Creates a PDF surface of the specified size in points to be written to filename.
Parameters
- filename: a filename for the PDF output
- 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 the newly created surface. The caller owns the surface and should call cairo::surface::destroy when done with it. If an error such as out of memory occurs, cairo::error is returned instead.
fn set_metadata(surface: *cairo::surface_t, metadata: cairo::pdf_metadata_t, utf8: str) void;
Set document metadata. The cairo::pdf_metadata_t::CREATE_DATE and cairo::pdf_metadata_t::MOD_DATE values must be in ISO-8601 format: YYYY-MM-DDThh:mm:ss.
An optional timezone of the form "[+/-]hh:mm" or "Z" for UTC time can be appended. All other metadata values can be any UTF-8 string.
For example:
cairo::pdf_surface::set_metadata(surface, cairo::pdf_metadata_t::TITLE, "My Document"); cairo::pdf_surface::set_metadata(surface, cairo::pdf_metadata_t::CREATE_DATE, "2015-12-31T23:59+02:00");
Parameters
- surface: a PDF cairo::surface_t
- metadata: The metadata item to set.
- utf8: metadata value
fn set_page_label
fn set_page_label(surface: *cairo::surface_t, label: str) void;
Set page label for the current page.
fn set_size
fn set_size(surface: *cairo::surface_t, width_in_points: f64, height_in_points: f64) void;
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.
Parameters
- 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)
fn set_thumbnail_size
fn set_thumbnail_size(surface: *cairo::surface_t, width: int, height: int) void;
Set the thumbnail image size for the current and all subsequent pages. Setting a width or height of 0 disables thumbnails for the current and subsequent pages.