### Clone Cairo Website Repository Source: https://www.cairographics.org/documentation Use this command to get the source code for the Cairo website. Changes are submitted via patches to cairo@cairographics.org. ```bash git clone git://cairographics.org/git/cairo-www ``` -------------------------------- ### Create Portrait and Landscape PostScript Pages Source: https://www.cairographics.org/documentation/using_the_postscript_surface Generates a PostScript file with one portrait and one landscape page. For landscape, the drawing context is rotated and translated, and a DSC comment is added. ```c #include #include #define PAGE_WIDTH 595 #define PAGE_HEIGHT 842 #define BORDER 50 void draw (cairo_t *cr, const char *text, int width, int height) { char buf[100]; cairo_rectangle (cr, BORDER, BORDER, width - 2*BORDER, height - 2*BORDER); cairo_set_line_width (cr, 2); cairo_stroke (cr); cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size (cr, 60); cairo_move_to (cr, 200, height/3); cairo_show_text (cr, text); sprintf (buf, "Width: %d points Height: %d points", width, height); cairo_set_font_size (cr, 18); cairo_move_to (cr, 120, height*2/3); cairo_show_text (cr, buf); } int main() { cairo_surface_t *surface; cairo_t *cr; cairo_matrix_t matrix; surface = cairo_ps_surface_create ("output.ps", PAGE_WIDTH, PAGE_HEIGHT); cr = cairo_create (surface); /* Print portrait page */ cairo_ps_surface_dsc_begin_page_setup (surface); cairo_ps_surface_dsc_comment (surface, "%%PageOrientation: Portrait"); draw (cr, "Portrait", PAGE_WIDTH, PAGE_HEIGHT); cairo_surface_show_page (surface); /* Print landscape page */ cairo_ps_surface_dsc_begin_page_setup (surface); cairo_ps_surface_dsc_comment (surface, "%%PageOrientation: Landscape"); /* Move the origin to landscape origin and rotate counterclockwise * 90 degrees. * * This is equivilent to: * cairo_translate (cr, 0, PAGE_HEIGHT); * cairo_rotate (cr, -M_PI/2); */ cairo_translate (cr, 0, PAGE_HEIGHT); cairo_matrix_init (&matrix, 0, -1, 1, 0, 0, 0); cairo_transform (cr, &matrix); draw (cr, "Landscape", PAGE_HEIGHT, PAGE_WIDTH); cairo_surface_show_page (surface); cairo_destroy (cr); cairo_surface_finish (surface); cairo_surface_destroy (surface); return 0; } ``` -------------------------------- ### Create Encapsulated PostScript (EPS) Surface Source: https://www.cairographics.org/documentation/using_the_postscript_surface Creates an Encapsulated PostScript (EPS) surface with specified dimensions. EPS files are suitable for importing as diagrams into other applications and must contain only one page. ```python surface = cairo_ps_surface_create (filename, 400, 200) cairo_ps_surface_set_eps (surface, TRUE); ``` -------------------------------- ### Identify Fallback Images in PostScript Output Source: https://www.cairographics.org/documentation/using_the_postscript_surface Use grep to find comments indicating fallback images, their dimensions, resolution, and size in a PostScript file. These comments help diagnose large file sizes and slow printing. ```bash > grep 'Fallback' output.ps output.ps:% Fallback Image: x=100, y=100, w=299, h=50 res=300dpi size=783750 output.ps:% Fallback Image: x=100, y=150, w=350, h=250 res=300dpi size=4560834 output.ps:% Fallback Image: x=150, y=400, w=299, h=50 res=300dpi size=783750 ``` -------------------------------- ### Set Coordinate Scale for Millimeters Source: https://www.cairographics.org/documentation/using_the_postscript_surface Scales the user space coordinate system to work in millimeters. This is useful for precise layout when the output unit is points (1/72 inch). ```c cairo_scale (cr, 72/25.4, 72/25.4); ``` -------------------------------- ### Set Coordinate Scale for Inches Source: https://www.cairographics.org/documentation/using_the_postscript_surface Scales the user space coordinate system to work in inches. This is useful for precise layout when the output unit is points (1/72 inch). ```c cairo_scale (cr, 72, 72); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.