GNOME Print Reference Manual |
---|
enum GnomePrintReturnCode; struct GnomePrintContext; GnomePrintContext* gnome_print_context_new (GnomePrintConfig *config); gint gnome_print_context_close (GnomePrintContext *pc); gint gnome_print_newpath (GnomePrintContext *pc); gint gnome_print_moveto (GnomePrintContext *pc, gdouble x, gdouble y); gint gnome_print_lineto (GnomePrintContext *pc, gdouble x, gdouble y); gint gnome_print_curveto (GnomePrintContext *pc, gdouble x1, gdouble y1, gdouble x2, gdouble y2, gdouble x3, gdouble y3); gint gnome_print_closepath (GnomePrintContext *pc); gint gnome_print_strokepath (GnomePrintContext *pc); gint gnome_print_bpath (GnomePrintContext *pc, const ArtBpath *bpath, gboolean append); gint gnome_print_vpath (GnomePrintContext *pc, const ArtVpath *vpath, gboolean append); gint gnome_print_arcto (GnomePrintContext *pc, gdouble x, gdouble y, gdouble radius, gdouble angle1, gdouble angle2, gint direction); gint gnome_print_setrgbcolor (GnomePrintContext *pc, gdouble r, gdouble g, gdouble b); gint gnome_print_setopacity (GnomePrintContext *pc, gdouble opacity); gint gnome_print_setlinewidth (GnomePrintContext *pc, gdouble width); gint gnome_print_setmiterlimit (GnomePrintContext *pc, gdouble limit); gint gnome_print_setlinejoin (GnomePrintContext *pc, gint jointype); gint gnome_print_setlinecap (GnomePrintContext *pc, gint captype); gint gnome_print_setdash (GnomePrintContext *pc, gint n_values, const gdouble *values, gdouble offset); gint gnome_print_setfont (GnomePrintContext *pc, const GnomeFont *font); gint gnome_print_clip (GnomePrintContext *pc); gint gnome_print_eoclip (GnomePrintContext *pc); gint gnome_print_concat (GnomePrintContext *pc, const gdouble *matrix); gint gnome_print_scale (GnomePrintContext *pc, gdouble sx, gdouble sy); gint gnome_print_rotate (GnomePrintContext *pc, gdouble theta); gint gnome_print_translate (GnomePrintContext *pc, gdouble x, gdouble y); gint gnome_print_gsave (GnomePrintContext *pc); gint gnome_print_grestore (GnomePrintContext *pc); gint gnome_print_fill (GnomePrintContext *pc); gint gnome_print_eofill (GnomePrintContext *pc); gint gnome_print_stroke (GnomePrintContext *pc); gint gnome_print_show (GnomePrintContext *pc, const guchar *text); gint gnome_print_show_sized (GnomePrintContext *pc, const guchar *text, gint bytes); gint gnome_print_glyphlist (GnomePrintContext *pc, GnomeGlyphList *glyphlist); gint gnome_print_grayimage (GnomePrintContext *pc, const guchar *data, gint width, gint height, gint rowstride); gint gnome_print_rgbimage (GnomePrintContext *pc, const guchar *data, gint width, gint height, gint rowstride); gint gnome_print_rgbaimage (GnomePrintContext *pc, const guchar *data, gint width, gint height, gint rowstride); gint gnome_print_beginpage (GnomePrintContext *pc, const guchar *name); gint gnome_print_showpage (GnomePrintContext *pc); gint gnome_print_line_stroked (GnomePrintContext *pc, gdouble x0, gdouble y0, gdouble x1, gdouble y1); gint gnome_print_rect_stroked (GnomePrintContext *pc, gdouble x, gdouble y, gdouble width, gdouble height); gint gnome_print_rect_filled (GnomePrintContext *pc, gdouble x, gdouble y, gdouble width, gdouble height);
typedef enum { GNOME_PRINT_OK = 0, GNOME_PRINT_ERROR_UNKNOWN = -1, GNOME_PRINT_ERROR_BADVALUE = -2, GNOME_PRINT_ERROR_NOCURRENTPOINT = -3, GNOME_PRINT_ERROR_NOCURRENTPATH = -4, GNOME_PRINT_ERROR_TEXTCORRUPT = -5, GNOME_PRINT_ERROR_BADCONTEXT = -6, GNOME_PRINT_ERROR_NOPAGE = -7, GNOME_PRINT_ERROR_NOMATCH = -8 } GnomePrintReturnCode;
GnomePrintContext* gnome_print_context_new (GnomePrintConfig *config);
Create new printing context from config. You have to have set all the options/settings beforehand, as changing the config of an existing context has undefined results.
Also, if creating the context by hand, it completely ignores layout and orientation value. If you need those, use GnomePrintJob. The later also can create output context for you, so in most cases you may want to ignore gnome_print_context_new at all.
config : | GnomePrintConfig object to query print settings from |
Returns : | The new GnomePrintContext or NULL on error |
gint gnome_print_context_close (GnomePrintContext *pc);
Informs given GnomePrintContext that application has finished print job. From that point on, pc has to be considered illegal pointer, and any further printing operation with it may kill application. Some printing contexts may not start printing before context is closed.
pc : | |
Returns : | |
gint gnome_print_newpath (GnomePrintContext *pc);
Resets currentpath to empty path. As currentpoint is defined as the last point of open path segment, is also erases currentpoint.
pc : | |
Returns : | |
gint gnome_print_moveto (GnomePrintContext *pc, gdouble x, gdouble y);
Starts new subpath in currentpath with coordinates x,y. Moves currentpoint to x,y.
pc : | |
x : | X position in user coordinates |
y : | Y position in user coordinates |
Returns : | |
gint gnome_print_lineto (GnomePrintContext *pc, gdouble x, gdouble y);
Adds new straight line segment from currentpoint to x,y to currentpath.
Moves currentpoint to x,y.
If currentpoint is not defined, returns
pc : | |
x : | X position in user coordinates |
y : | Y position in user coordinates |
Returns : | |
gint gnome_print_curveto (GnomePrintContext *pc, gdouble x1, gdouble y1, gdouble x2, gdouble y2, gdouble x3, gdouble y3);
Adds new cubig bezier segment with control points x1,y1 and
x2,y2 and endpoint x3,y3 to currentpath.
Moves currentpoint to x3,y3.
If currentpoint is not defined, returns
pc : | |
x1 : | X position of first control point in user coordinates |
y1 : | Y position of first control point in user coordinates |
x2 : | X position of second control point in user coordinates |
y2 : | Y position of second control point in user coordinates |
x3 : | X position of endpoint in user coordinates |
y3 : | Y position of endpoint in user coordinates |
Returns : | |
gint gnome_print_closepath (GnomePrintContext *pc);
Closes the last segment of currentpath, optionally drawing straight
line segment from its endpoint to starting point.
Erases currentpoint.
If currentpath is empty, returns
pc : | |
Returns : | |
gint gnome_print_strokepath (GnomePrintContext *pc);
Converts currentpath to new path, that is identical to area painted
by gnome_print_stroke function, using currentpath. I.e. strokepath
followed by fill giver result identical to stroke.
If currentpath is empty, returns
pc : | |
Returns : | |
gint gnome_print_bpath (GnomePrintContext *pc, const ArtBpath *bpath, gboolean append);
Adds all bpath segments up to
pc : | |
bpath : | Array of |
append : | Whether to append to currentpath |
Returns : | |
gint gnome_print_vpath (GnomePrintContext *pc, const ArtVpath *vpath, gboolean append);
Adds all vpath line segments up to
pc : | |
vpath : | Array of |
append : | Whether to append to currentpath |
Returns : | |
gint gnome_print_arcto (GnomePrintContext *pc, gdouble x, gdouble y, gdouble radius, gdouble angle1, gdouble angle2, gint direction);
Adds an arc with control points x and y with a radius radius and from angle1 to andgle2 in degrees. direction 1 is clockwise 0 counterclockwise
pc : | A |
x : | X position of control point in user coordinates |
y : | Y position of control point in user coordinates |
radius : | the radius of the arc |
angle1 : | start angle in degrees |
angle2 : | end angle in degrees |
direction : | direction of movement, 0 counterclockwise 1 clockwise |
Returns : | GNOME_PRINT_OK or postive value on success, a negative value otherwise |
gint gnome_print_setrgbcolor (GnomePrintContext *pc, gdouble r, gdouble g, gdouble b);
Sets color in graphic state to RGB triplet. This does not imply anything about which colorspace is used internally. Channel values are clamped to 0.0 - 1.0 region, 0.0 meaning minimum.
pc : | |
r : | Red channel value |
g : | Green channel value |
b : | Blue channel value |
Returns : | |
gint gnome_print_setopacity (GnomePrintContext *pc, gdouble opacity);
Sets painting opacity in graphic state to given value. Value is clamped to 0.0 - 1.0 region, 0.0 meaning full transparency and 1.0 completely opaque paint.
pc : | |
opacity : | Opacity value |
Returns : | |
gint gnome_print_setlinewidth (GnomePrintContext *pc, gdouble width);
Sets line width in graphic state to given value. Value is given in user coordinates, so effective line width depends on CTM at the moment of gnome_print_stroke or gnome_print_strokepath. Line width is always uniform in all directions, regardless of stretch factor of CTM. Default line width is 1.0 in user coordinates.
pc : | |
width : | Line width in user coordinates |
Returns : | |
gint gnome_print_setmiterlimit (GnomePrintContext *pc, gdouble limit);
Sets minimum angle between two lines, in which case miter join is used. For smaller angles, join is beveled. Default miter limit is 4 degrees.
pc : | |
limit : | Miter limit in degrees |
Returns : | |
gint gnome_print_setlinejoin (GnomePrintContext *pc, gint jointype);
Sets join type for non-colinear line segments. 0 - miter 1 - round 2 - bevel Default join type is miter.
pc : | |
jointype : | Integer indicating join type |
Returns : | |
gint gnome_print_setlinecap (GnomePrintContext *pc, gint captype);
Sets cap type for line endpoints. 0 - butt 1 - round 2 - square Default cap type is butt.
pc : | |
captype : | Integer indicating cap type |
Returns : | |
gint gnome_print_setdash (GnomePrintContext *pc, gint n_values, const gdouble *values, gdouble offset);
Sets line dashing to given pattern. If n_dash is odd, the result is, as if actual number of segments is 2 times bigger, and 2 copies of dash arrays concatenated. If n_values is 0, line is set solid. Dash segment lengths are given in user coordinates, so the actual dash lengths depend on CTM at the time of gnome_print_stroke or gnome_print_strokepath. Dashing is always uniform in all directions, regardless of the stretching factor of CTM. Default is solid line.
pc : | |
n_values : | Number of dash segment lengths |
values : | Array of dash segment lengths |
offset : | Line starting offset in dash |
Returns : | |
gint gnome_print_setfont (GnomePrintContext *pc, const GnomeFont *font);
Sets font in graphic state. Font is referenced by gnome print, so caller may discard it immediately afterwards. Default font is system dependent.
pc : | |
font : | GnomeFont to use for text |
Returns : | |
gint gnome_print_clip (GnomePrintContext *pc);
Defines drawing region as inside area of currentpath. If path is
self-intersecting or consists of several overlapping subpaths,
nonzero rule is used to define the inside orea of path.
All open subpaths of currentpath are closed.
If currentpath is empty,
pc : | |
Returns : | |
gint gnome_print_eoclip (GnomePrintContext *pc);
Defines drawing region as inside area of currentpath. If path is
self-intersecting or consists of several overlapping subpaths,
even-odd rule is used to define the inside area of path.
All open subpaths of currentpath are closed.
If currentpath is empty,
pc : | |
Returns : | |
gint gnome_print_concat (GnomePrintContext *pc, const gdouble *matrix);
Appends matrix to current transformation matrix (CTM). The resulting transformation from user coordinates to page coordinates is, as if coordinates would first be transformed by matrix, and the results by CTM. Matrix is given in column order, i.e. X' = X * m[0] + Y * m[2] + m[4] Y' = X * m[1] + Y * m[3] + m[5]
pc : | |
matrix : | 3x2 affine transformation matrix |
Returns : | |
gint gnome_print_scale (GnomePrintContext *pc, gdouble sx, gdouble sy);
Scales user coordinate system by given X and Y values.
pc : | |
sx : | X scale |
sy : | Y scale |
Returns : | |
gint gnome_print_rotate (GnomePrintContext *pc, gdouble theta);
Rotates user coordinate system theta degrees counterclockwise.
pc : | |
theta : | Angle in degrees |
Returns : | |
gint gnome_print_translate (GnomePrintContext *pc, gdouble x, gdouble y);
Move the starting point of user coordinate system to given point.
pc : | |
x : | New starting X |
y : | New starting Y |
Returns : | |
gint gnome_print_gsave (GnomePrintContext *pc);
Saves current graphic state (transformation, color, line properties, font) into stack (push). Values itself remain unchanged. You can later restore saved values, using gnome_print_grestore, but not over page boundaries. Graphic state stack has to be cleared for each gnome_print_showpage, i.e. the number of gnome_print_gsave has to match the number of gnome_print_grestore for each page.
pc : | |
Returns : | |
gint gnome_print_grestore (GnomePrintContext *pc);
Retrieves last saved graphic state from stack (pop). Stack has to be at least the size of one.
pc : | |
Returns : | |
gint gnome_print_fill (GnomePrintContext *pc);
Fills the inside area of currentpath, using current graphic state.
If path is self-intersecting or consists of several overlapping subpaths,
nonzero rule is used to define the inside area of path.
All open subpaths of currentpath are closed.
If currentpath is empty,
pc : | |
Returns : | |
gint gnome_print_eofill (GnomePrintContext *pc);
Fills the inside area of currentpath, using current graphic state.
If path is self-intersecting or consists of several overlapping subpaths,
even-odd rule is used to define the inside area of path.
All open subpaths of currentpath are closed.
If currentpath is empty,
pc : | |
Returns : | |
gint gnome_print_stroke (GnomePrintContext *pc);
Strokes currentpath, i.e. draws line along it, with style, defined
by current graphic state values.
If currentpath is empty,
pc : | |
Returns : | |
gint gnome_print_show (GnomePrintContext *pc, const guchar *text);
Draws UTF-8 text at currentpoint, using current font from graphic
state.
Input text is validated, and
pc : | |
text : | Null-terminated UTF-8 string |
Returns : | |
gint gnome_print_show_sized (GnomePrintContext *pc, const guchar *text, gint bytes);
Draws UTF-8 text at currentpoint, using current font from graphic
state.
Input text is validated, and
pc : | |
text : | UTF-8 text string |
bytes : | Number of bytes to use from string |
Returns : | |
gint gnome_print_glyphlist (GnomePrintContext *pc, GnomeGlyphList *glyphlist);
Draws text, using GnomeGlyphList rich text format. Glyphlist is rendered in user coordinates, starting from currentpoint. Both currentpath and currentpoint are erased.
pc : | |
glyphlist : | GnomeGlyphList text object |
Returns : | |
gint gnome_print_grayimage (GnomePrintContext *pc, const guchar *data, gint width, gint height, gint rowstride);
Draws grayscale image into unit square (0,0 - 1,1) in current coordinate system. Image buffer has to be 1 byte per pixel, with value 255 marking white and 0 black.
pc : | |
data : | Pointer to image pixel buffer |
width : | Image buffer width |
height : | Image buffer height |
rowstride : | Image buffer rowstride |
Returns : | |
gint gnome_print_rgbimage (GnomePrintContext *pc, const guchar *data, gint width, gint height, gint rowstride);
Draws RGB color image into unit square (0,0 - 1,1) in current coordinate system. Image buffer has to be 3 bytes per pixel, order RGB, with value 255 marking maximum and 0 minimum value.
pc : | |
data : | Pointer to image pixel buffer |
width : | Image buffer width |
height : | Image buffer height |
rowstride : | Image buffer rowstride |
Returns : | |
gint gnome_print_rgbaimage (GnomePrintContext *pc, const guchar *data, gint width, gint height, gint rowstride);
Draws RGB color image with transparency channel image into unit square (0,0 - 1,1) in current coordinate system. Image buffer has to be 4 bytes per pixel, order RGBA, with value 255 marking maximum and 0 minimum value. Alpha value 255 means full opacity, 0 full transparency.
pc : | |
data : | Pointer to image pixel buffer |
width : | Image buffer width |
height : | Image buffer height |
rowstride : | Image buffer rowstride |
Returns : | |
gint gnome_print_beginpage (GnomePrintContext *pc, const guchar *name);
Starts new output page with name. Naming is used for interactive
contexts like
pc : | |
name : | Name of the page, NULL if you just want to use the page number of the page |
Returns : | |
gint gnome_print_showpage (GnomePrintContext *pc);
Finishes rendering of current page, and marks it as shown. All subsequent
drawing methods will fail, until new page is started with
pc : | |
Returns : | |
gint gnome_print_line_stroked (GnomePrintContext *pc, gdouble x0, gdouble y0, gdouble x1, gdouble y1);
A convenience function to draw a line. Uses gnome_print_stroke to do the actual work.
pc : | |
x0 : | X position of start point in user coordinates |
y0 : | Y position of start point in user coordinates |
x1 : | X position of end point in user coordinates |
y1 : | Y position of end point in user coordinates |
Returns : | |
gint gnome_print_rect_stroked (GnomePrintContext *pc, gdouble x, gdouble y, gdouble width, gdouble height);
A convenience function to draw a rectangle. Uses gnome_print_stroke to do the actual work.
pc : | |
x : | X position of origin of rectangle in user coordinates |
y : | Y position of origin of rectangle in user coordinates |
width : | Width of the rectangle |
height : | Height of the rectange |
Returns : | |
gint gnome_print_rect_filled (GnomePrintContext *pc, gdouble x, gdouble y, gdouble width, gdouble height);
A convenience function to draw a filled rectangle. Uses gnome_print_stroke to do the actual work.
pc : | |
x : | X position of origin of rectangle in user coordinates |
y : | Y position of origin of rectangle in user coordinates |
width : | Width of the rectangle |
height : | Height of the rectange |
Returns : | |
<<< gnome-print-paper | gnome-print-unit >>> |