GNOME Print Reference Manual | ||||
---|---|---|---|---|
Top | Description |
Synopsis
enum GnomePrintReturnCode; 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
);
Details
enum GnomePrintReturnCode
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;
gnome_print_context_new ()
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.
|
GnomePrintConfig object to query print settings from |
Returns : |
The new GnomePrintContext or NULL on error |
gnome_print_context_close ()
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.
|
A GnomePrintContext |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_newpath ()
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.
|
A GnomePrintContext |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_moveto ()
gint gnome_print_moveto (GnomePrintContext *pc
,gdouble x
,gdouble y
);
Starts new subpath in currentpath with coordinates x
,y
.
Moves currentpoint to x
,y
.
|
A GnomePrintContext |
|
X position in user coordinates |
|
Y position in user coordinates |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_lineto ()
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 GNOME_PRINT_ERROR_NOCURRENTPOINT.
|
A GnomePrintContext |
|
X position in user coordinates |
|
Y position in user coordinates |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_curveto ()
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 GNOME_PRINT_ERROR_NOCURRENTPOINT.
|
A GnomePrintContext |
|
X position of first control point in user coordinates |
|
Y position of first control point in user coordinates |
|
X position of second control point in user coordinates |
|
Y position of second control point in user coordinates |
|
X position of endpoint in user coordinates |
|
Y position of endpoint in user coordinates |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_closepath ()
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 GNOME_PRINT_ERROR_NOCURRENTPATH.
|
A GnomePrintContext |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_strokepath ()
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 GNOME_PRINT_ERROR_NOCURRENTPATH. Stroked path is always closed, so currentpoint is erased.
|
A GnomePrintContext |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_bpath ()
gint gnome_print_bpath (GnomePrintContext *pc
,const ArtBpath *bpath
,gboolean append
);
Adds all bpath
segments up to ART_END to currentpath. If append
is false, currentpath is cleared first, otherwise segments are
appended to existing path.
This is identical to adding all segments by hand, so the final state
of currentpoint depends on segments processed.
|
A GnomePrintContext |
|
Array of ArtBpath segments |
|
Whether to append to currentpath |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_vpath ()
gint gnome_print_vpath (GnomePrintContext *pc
,const ArtVpath *vpath
,gboolean append
);
Adds all vpath
line segments up to ART_END to currentpath. If append
is false, currentpath is cleared first, otherwise segments are
appended to existing path.
This is identical to adding all segments by hand, so the final state
of currentpoint depends on segments processed.
|
A GnomePrintContext |
|
Array of ArtVpath segments |
|
Whether to append to currentpath |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_arcto ()
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
|
A GnomePrintContextx |
|
X position of control point in user coordinates |
|
Y position of control point in user coordinates |
|
the radius of the arc |
|
start angle in degrees |
|
end angle in degrees |
|
direction of movement, 0 counterclockwise 1 clockwise |
Returns : |
GNOME_PRINT_OK or postive value on success, a negative value otherwise |
gnome_print_setrgbcolor ()
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.
|
A GnomePrintContext |
|
Red channel value |
|
Green channel value |
|
Blue channel value |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_setopacity ()
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.
|
A GnomePrintContext |
|
Opacity value |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_setlinewidth ()
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.
|
A GnomePrintContext |
|
Line width in user coordinates |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_setmiterlimit ()
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.
|
A GnomePrintContext |
|
Miter limit in degrees |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_setlinejoin ()
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.
|
A GnomePrintContext |
|
Integer indicating join type |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_setlinecap ()
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.
|
A GnomePrintContext |
|
Integer indicating cap type |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_setdash ()
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.
|
A GnomePrintContext |
|
Number of dash segment lengths |
|
Array of dash segment lengths |
|
Line starting offset in dash |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_setfont ()
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.
|
A GnomePrintContext |
|
GnomeFont to use for text |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_clip ()
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, GNOME_PRINT_ERROR_NOCURRENTPATH is returned. Currentpath is emptied by this function.
|
A GnomePrintContext |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_eoclip ()
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, GNOME_PRINT_ERROR_NOCURRENTPATH is returned. Currentpath is emptied by this function.
|
A GnomePrintContext |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_concat ()
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]
|
A GnomePrintContext |
|
3x2 affine transformation matrix |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_scale ()
gint gnome_print_scale (GnomePrintContext *pc
,gdouble sx
,gdouble sy
);
Scales user coordinate system by given X and Y values.
|
A GnomePrintContext |
|
X scale |
|
Y scale |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_rotate ()
gint gnome_print_rotate (GnomePrintContext *pc
,gdouble theta
);
Rotates user coordinate system theta degrees counterclockwise.
|
A GnomePrintContext |
|
Angle in degrees |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_translate ()
gint gnome_print_translate (GnomePrintContext *pc
,gdouble x
,gdouble y
);
Move the starting point of user coordinate system to given point.
|
A GnomePrintContext |
|
New starting X |
|
New starting Y |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_gsave ()
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.
|
A GnomePrintContext |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_grestore ()
gint gnome_print_grestore (GnomePrintContext *pc
);
Retrieves last saved graphic state from stack (pop). Stack has to be at least the size of one.
|
A GnomePrintContext |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_fill ()
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, GNOME_PRINT_ERROR_NOCURRENTPATH is returned. Currentpath is emptied by this function.
|
A GnomePrintContext |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_eofill ()
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, GNOME_PRINT_ERROR_NOCURRENTPATH is returned. Currentpath is emptied by this function.
|
A GnomePrintContext |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_stroke ()
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, GNOME_PRINT_ERROR_NOCURRENTPATH is returned. Currentpath is emptied by this function.
|
A GnomePrintContext |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_show ()
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 GNOME_PRINT_ERROR_BADVALUE returned, if it is not valid UTF-8. Both currentpath and currentpoint are erased.
|
A GnomePrintContext |
|
Null-terminated UTF-8 string |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_show_sized ()
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 GNOME_PRINT_ERROR_BADVALUE returned, if it is not valid UTF-8. Both currentpath and currentpoint are erased.
|
A GnomePrintContext |
|
UTF-8 text string |
|
Number of bytes to use from string |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_glyphlist ()
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.
|
A GnomePrintContext |
|
GnomeGlyphList text object |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_grayimage ()
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.
|
A GnomePrintContext |
|
Pointer to image pixel buffer |
|
Image buffer width |
|
Image buffer height |
|
Image buffer rowstride |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_rgbimage ()
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.
|
A GnomePrintContext |
|
Pointer to image pixel buffer |
|
Image buffer width |
|
Image buffer height |
|
Image buffer rowstride |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_rgbaimage ()
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.
|
A GnomePrintContext |
|
Pointer to image pixel buffer |
|
Image buffer width |
|
Image buffer height |
|
Image buffer rowstride |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_beginpage ()
gint gnome_print_beginpage (GnomePrintContext *pc
,const guchar *name
);
Starts new output page with name
. Naming is used for interactive
contexts like GnomePrintPreview and Document Structuring Convention
conformant PostScript output.
This function has to be called before any drawing methods and immediately
after each gnome_print_showpage albeit the last one. It also resets
graphic state values (transformation, color, line properties, font),
so one has to define these again at the beginning of each page.
|
A GnomePrintContext |
|
Name of the page, NULL if you just want to use the page number of the page |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_showpage ()
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 gnome_print_newpage. Printing contexts may process drawing methods differently - some do rendering immediately (like GnomePrintPreview), some accumulate all operators to internal stack, and only after gnome_print_showpage is any output produced.
|
A GnomePrintContext |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_line_stroked ()
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.
|
A GnomePrintContext |
|
X position of start point in user coordinates |
|
Y position of start point in user coordinates |
|
X position of end point in user coordinates |
|
Y position of end point in user coordinates |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_rect_stroked ()
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.
|
A GnomePrintContext |
|
X position of origin of rectangle in user coordinates |
|
Y position of origin of rectangle in user coordinates |
|
Width of the rectangle |
|
Height of the rectange |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |
gnome_print_rect_filled ()
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.
|
A GnomePrintContext |
|
X position of origin of rectangle in user coordinates |
|
Y position of origin of rectangle in user coordinates |
|
Width of the rectangle |
|
Height of the rectange |
Returns : |
GNOME_PRINT_OK or positive value on success, negative error code on failure. |