gnome-print

gnome-print

Functions

Types and Values

Description

Functions

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.

Parameters

config

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.

Parameters

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.

Parameters

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 .

Parameters

pc

A GnomePrintContext

 

x

X position in user coordinates

 

y

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.

Parameters

pc

A GnomePrintContext

 

x

X position in user coordinates

 

y

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.

Parameters

pc

A GnomePrintContext

 

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

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.

Parameters

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.

Parameters

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.

Parameters

pc

A GnomePrintContext

 

bpath

Array of ArtBpath segments

 

append

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.

Parameters

pc

A GnomePrintContext

 

vpath

Array of ArtVpath segments

 

append

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

Parameters

pc

A GnomePrintContextx

 

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


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.

Parameters

pc

A GnomePrintContext

 

r

Red channel value

 

g

Green channel value

 

b

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.

Parameters

pc

A GnomePrintContext

 

opacity

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.

Parameters

pc

A GnomePrintContext

 

width

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.

Parameters

pc

A GnomePrintContext

 

limit

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.

Parameters

pc

A GnomePrintContext

 

jointype

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.

Parameters

pc

A GnomePrintContext

 

captype

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.

Parameters

pc

A GnomePrintContext

 

n_values

Number of dash segment lengths

 

values

Array of dash segment lengths

 

offset

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.

Parameters

pc

A GnomePrintContext

 

font

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.

Parameters

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.

Parameters

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]

Parameters

pc

A GnomePrintContext

 

matrix

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.

Parameters

pc

A GnomePrintContext

 

sx

X scale

 

sy

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.

Parameters

pc

A GnomePrintContext

 

theta

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.

Parameters

pc

A GnomePrintContext

 

x

New starting X

 

y

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.

Parameters

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.

Parameters

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.

Parameters

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.

Parameters

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.

Parameters

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.

Parameters

pc

A GnomePrintContext

 

text

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.

Parameters

pc

A GnomePrintContext

 

text

UTF-8 text string

 

bytes

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.

Parameters

pc

A GnomePrintContext

 

glyphlist

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.

Parameters

pc

A GnomePrintContext

 

data

Pointer to image pixel buffer

 

width

Image buffer width

 

height

Image buffer height

 

rowstride

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.

Parameters

pc

A GnomePrintContext

 

data

Pointer to image pixel buffer

 

width

Image buffer width

 

height

Image buffer height

 

rowstride

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.

Parameters

pc

A GnomePrintContext

 

data

Pointer to image pixel buffer

 

width

Image buffer width

 

height

Image buffer height

 

rowstride

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.

Parameters

pc

A GnomePrintContext

 

name

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.

Parameters

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.

Parameters

pc

A GnomePrintContext

 

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

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.

Parameters

pc

A GnomePrintContext

 

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_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.

Parameters

pc

A GnomePrintContext

 

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_OK or positive value on success, negative error code on failure.

Types and Values

enum GnomePrintReturnCode

Members

GNOME_PRINT_OK

   

GNOME_PRINT_ERROR_UNKNOWN

   

GNOME_PRINT_ERROR_BADVALUE

   

GNOME_PRINT_ERROR_NOCURRENTPOINT

   

GNOME_PRINT_ERROR_NOCURRENTPATH

   

GNOME_PRINT_ERROR_TEXTCORRUPT

   

GNOME_PRINT_ERROR_BADCONTEXT

   

GNOME_PRINT_ERROR_NOPAGE

   

GNOME_PRINT_ERROR_NOMATCH

   

GnomePrintContext

typedef struct _GnomePrintContext GnomePrintContext;