| 1 |
|
| 2 |
@c %start of fragment |
| 3 |
|
| 4 |
@deffn Function cairo-ps-surface-create (@var{width-in-points}@tie{}@code{<double>}) (@var{height-in-points}@tie{}@code{<double>}) (@var{filename}@tie{}@code{<char>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-surface-t >}) |
| 5 |
Creates a PostScript surface of the specified size in points to be |
| 6 |
written to @var{filename}. See @code{cairo-ps-surface-create-for-stream} |
| 7 |
for a more flexible mechanism for handling the PostScript output than |
| 8 |
simply writing it to a named file. |
| 9 |
|
| 10 |
Note that the size of individual pages of the PostScript output can |
| 11 |
vary. See @code{cairo-ps-surface-set-size}. |
| 12 |
|
| 13 |
@table @var |
| 14 |
@item filename |
| 15 |
a filename for the PS output (must be writable), @samp{@code{#f}} may be |
| 16 |
used to specify no output. This will generate a PS surface that may be |
| 17 |
queried and used as a source, without generating a temporary file. |
| 18 |
|
| 19 |
@item width-in-points |
| 20 |
width of the surface, in points (1 point == 1/72.0 inch) |
| 21 |
|
| 22 |
@item height-in-points |
| 23 |
height of the surface, in points (1 point == 1/72.0 inch) |
| 24 |
|
| 25 |
@item ret |
| 26 |
a pointer to the newly created surface. The caller owns the surface and |
| 27 |
should call @code{cairo-surface-destroy} when done with it. This |
| 28 |
function always returns a valid pointer, but it will return a pointer to |
| 29 |
a "nil" surface if an error such as out of memory occurs. You can use |
| 30 |
@code{cairo-surface-status} to check for this. |
| 31 |
|
| 32 |
@end table |
| 33 |
|
| 34 |
Since 1.2 |
| 35 |
|
| 36 |
@end deffn |
| 37 |
|
| 38 |
@deffn Function cairo-ps-surface-restrict-to-level (@var{surface}@tie{}@code{<cairo-surface-t>}) (@var{level}@tie{}@code{<cairo-ps-level-t>}) |
| 39 |
Restricts the generated PostSript file to @var{level}. See |
| 40 |
@code{cairo-ps-get-levels} for a list of available level values that can |
| 41 |
be used here. |
| 42 |
|
| 43 |
This function should only be called before any drawing operations have |
| 44 |
been performed on the given surface. The simplest way to do this is to |
| 45 |
call this function immediately after creating the surface. |
| 46 |
|
| 47 |
@table @var |
| 48 |
@item surface |
| 49 |
a PostScript @code{<cairo-surface-t>} |
| 50 |
|
| 51 |
@item level |
| 52 |
PostScript level |
| 53 |
|
| 54 |
@end table |
| 55 |
|
| 56 |
Since 1.6 |
| 57 |
|
| 58 |
@end deffn |
| 59 |
|
| 60 |
@deffn Function cairo-ps-get-levels @result{}@tie{} (@var{levels}@tie{}@code{<cairo-ps-level-t const*>}) (@var{num-levels}@tie{}@code{<int>}) |
| 61 |
Used to retrieve the list of supported levels. See |
| 62 |
@code{cairo-ps-surface-restrict-to-level}. |
| 63 |
|
| 64 |
@table @var |
| 65 |
@item levels |
| 66 |
supported level list |
| 67 |
|
| 68 |
@item num-levels |
| 69 |
list length |
| 70 |
|
| 71 |
@end table |
| 72 |
|
| 73 |
Since 1.6 |
| 74 |
|
| 75 |
@end deffn |
| 76 |
|
| 77 |
@deffn Function cairo-ps-surface-set-eps (@var{surface}@tie{}@code{<cairo-surface-t>}) (@var{eps}@tie{}@code{<cairo-bool-t>}) |
| 78 |
If @var{eps} is @samp{@code{#t}}, the PostScript surface will output |
| 79 |
Encapsulated PostScript. |
| 80 |
|
| 81 |
This function should only be called before any drawing operations have |
| 82 |
been performed on the current page. The simplest way to do this is to |
| 83 |
call this function immediately after creating the surface. An |
| 84 |
Encapsulated PostScript file should never contain more than one page. |
| 85 |
|
| 86 |
@table @var |
| 87 |
@item surface |
| 88 |
a PostScript @code{<cairo-surface-t>} |
| 89 |
|
| 90 |
@item eps |
| 91 |
@samp{@code{#t}} to output EPS format PostScript |
| 92 |
|
| 93 |
@end table |
| 94 |
|
| 95 |
Since 1.6 |
| 96 |
|
| 97 |
@end deffn |
| 98 |
|
| 99 |
@deffn Function cairo-ps-surface-get-eps (@var{surface}@tie{}@code{<cairo-surface-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-bool-t>}) |
| 100 |
Check whether the PostScript surface will output Encapsulated |
| 101 |
PostScript. |
| 102 |
|
| 103 |
@table @var |
| 104 |
@item surface |
| 105 |
a PostScript @code{<cairo-surface-t>} |
| 106 |
|
| 107 |
@item ret |
| 108 |
@samp{@code{#t}} if the surface will output Encapsulated PostScript. |
| 109 |
|
| 110 |
@end table |
| 111 |
|
| 112 |
Since 1.6 |
| 113 |
|
| 114 |
@end deffn |
| 115 |
|
| 116 |
@deffn Function cairo-ps-surface-set-size (@var{surface}@tie{}@code{<cairo-surface-t>}) (@var{width-in-points}@tie{}@code{<double>}) (@var{height-in-points}@tie{}@code{<double>}) |
| 117 |
Changes the size of a PostScript surface for the current (and |
| 118 |
subsequent) pages. |
| 119 |
|
| 120 |
This function should only be called before any drawing operations have |
| 121 |
been performed on the current page. The simplest way to do this is to |
| 122 |
call this function immediately after creating the surface or immediately |
| 123 |
after completing a page with either @code{cairo-show-page} or |
| 124 |
@code{cairo-copy-page}. |
| 125 |
|
| 126 |
@table @var |
| 127 |
@item surface |
| 128 |
a PostScript @code{<cairo-surface-t>} |
| 129 |
|
| 130 |
@item width-in-points |
| 131 |
new surface width, in points (1 point == 1/72.0 inch) |
| 132 |
|
| 133 |
@item height-in-points |
| 134 |
new surface height, in points (1 point == 1/72.0 inch) |
| 135 |
|
| 136 |
@end table |
| 137 |
|
| 138 |
Since 1.2 |
| 139 |
|
| 140 |
@end deffn |
| 141 |
|
| 142 |
@deffn Function cairo-ps-surface-dsc-comment (@var{surface}@tie{}@code{<cairo-surface-t>}) (@var{comment}@tie{}@code{<char>}) |
| 143 |
Emit a comment into the PostScript output for the given surface. |
| 144 |
|
| 145 |
The comment is expected to conform to the PostScript Language Document |
| 146 |
Structuring Conventions (DSC). Please see that manual for details on the |
| 147 |
available comments and their meanings. In particular, the |
| 148 |
%@samp{IncludeFeature} comment allows a device-independent means of |
| 149 |
controlling printer device features. So the PostScript Printer |
| 150 |
Description Files Specification will also be a useful reference. |
| 151 |
|
| 152 |
The comment string must begin with a percent character (%) and the total |
| 153 |
length of the string (including any initial percent characters) must not |
| 154 |
exceed 255 characters. Violating either of these conditions will place |
| 155 |
@var{surface} into an error state. But beyond these two conditions, this |
| 156 |
function will not enforce conformance of the comment with any particular |
| 157 |
specification. |
| 158 |
|
| 159 |
The comment string should not have a trailing newline. |
| 160 |
|
| 161 |
The DSC specifies different sections in which particular comments can |
| 162 |
appear. This function provides for comments to be emitted within three |
| 163 |
sections: the header, the Setup section, and the PageSetup section. |
| 164 |
Comments appearing in the first two sections apply to the entire |
| 165 |
document while comments in the BeginPageSetup section apply only to a |
| 166 |
single page. |
| 167 |
|
| 168 |
For comments to appear in the header section, this function should be |
| 169 |
called after the surface is created, but before a call to |
| 170 |
@code{cairo-ps-surface-begin-setup}. |
| 171 |
|
| 172 |
For comments to appear in the Setup section, this function should be |
| 173 |
called after a call to @code{cairo-ps-surface-begin-setup} but before a |
| 174 |
call to @code{cairo-ps-surface-begin-page-setup}. |
| 175 |
|
| 176 |
For comments to appear in the PageSetup section, this function should be |
| 177 |
called after a call to @code{cairo-ps-surface-begin-page-setup}. |
| 178 |
|
| 179 |
Note that it is only necessary to call |
| 180 |
@code{cairo-ps-surface-begin-page-setup} for the first page of any |
| 181 |
surface. After a call to @code{cairo-show-page} or |
| 182 |
@code{cairo-copy-page} comments are unambiguously directed to the |
| 183 |
PageSetup section of the current page. But it doesn't hurt to call this |
| 184 |
function at the beginning of every page as that consistency may make the |
| 185 |
calling code simpler. |
| 186 |
|
| 187 |
As a final note, cairo automatically generates several comments on its |
| 188 |
own. As such, applications must not manually generate any of the |
| 189 |
following comments: |
| 190 |
|
| 191 |
Header section: %!PS-Adobe-3.0, %@samp{Creator}, %@samp{CreationDate}, |
| 192 |
%@samp{Pages}, %@samp{BoundingBox}, %@samp{DocumentData}, |
| 193 |
%@samp{LanguageLevel}, %@samp{EndComments}. |
| 194 |
|
| 195 |
Setup section: %@samp{BeginSetup}, %@samp{EndSetup} |
| 196 |
|
| 197 |
PageSetup section: %@samp{BeginPageSetup}, %@samp{PageBoundingBox}, |
| 198 |
%@samp{EndPageSetup}. |
| 199 |
|
| 200 |
Other sections: %@samp{BeginProlog}, %@samp{EndProlog}, %@samp{Page}, |
| 201 |
%@samp{Trailer}, %@samp{EOF} |
| 202 |
|
| 203 |
Here is an example sequence showing how this function might be used: |
| 204 |
|
| 205 |
@example |
| 206 |
cairo_surface_t *surface = cairo_ps_surface_create (filename, width, height); |
| 207 |
... |
| 208 |
cairo_ps_surface_dsc_comment (surface, "%%Title: My excellent document"); |
| 209 |
cairo_ps_surface_dsc_comment (surface, "%%Copyright: Copyright (C) 2006 Cairo Lover") |
| 210 |
... |
| 211 |
cairo_ps_surface_dsc_begin_setup (surface); |
| 212 |
cairo_ps_surface_dsc_comment (surface, "%%IncludeFeature: *MediaColor White"); |
| 213 |
... |
| 214 |
cairo_ps_surface_dsc_begin_page_setup (surface); |
| 215 |
cairo_ps_surface_dsc_comment (surface, "%%IncludeFeature: *PageSize A3"); |
| 216 |
cairo_ps_surface_dsc_comment (surface, "%%IncludeFeature: *InputSlot LargeCapacity"); |
| 217 |
cairo_ps_surface_dsc_comment (surface, "%%IncludeFeature: *MediaType Glossy"); |
| 218 |
cairo_ps_surface_dsc_comment (surface, "%%IncludeFeature: *MediaColor Blue"); |
| 219 |
... draw to first page here .. |
| 220 |
cairo_show_page (cr); |
| 221 |
... |
| 222 |
cairo_ps_surface_dsc_comment (surface, "%%IncludeFeature: *PageSize A5"); |
| 223 |
... |
| 224 |
@end example |
| 225 |
|
| 226 |
@table @var |
| 227 |
@item surface |
| 228 |
a PostScript @code{<cairo-surface-t>} |
| 229 |
|
| 230 |
@item comment |
| 231 |
a comment string to be emitted into the PostScript output |
| 232 |
|
| 233 |
@end table |
| 234 |
|
| 235 |
Since 1.2 |
| 236 |
|
| 237 |
@end deffn |
| 238 |
|
| 239 |
|
| 240 |
@c %end of fragment |