summaryrefslogtreecommitdiff
path: root/doc/public/xml/cairo-ps.xml
blob: bdaaa6046a587ea0a4d4ef90cb3f3cdbdfb75c31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<?xml version='1.0' encoding='UTF-8'?> 
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
                "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
<!ENTITY version SYSTEM "version.xml">
]>
<refentry id="cairo-PostScript-Surfaces">
<refmeta>
<refentrytitle role="top_of_page">PostScript Surfaces</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>CAIRO Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>PostScript Surfaces</refname>
<refpurpose>Rendering PostScript documents</refpurpose>
<!--[<xref linkend="desc" endterm="desc.title"/>]-->
</refnamediv>

<refsynopsisdiv role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>



<link linkend="cairo-surface-t">cairo_surface_t</link>* <link linkend="cairo-ps-surface-create">cairo_ps_surface_create</link>    (const <link linkend="char">char</link> *filename,
                                             <link linkend="double">double</link> width_in_points,
                                             <link linkend="double">double</link> height_in_points);
<link linkend="cairo-surface-t">cairo_surface_t</link>* <link linkend="cairo-ps-surface-create-for-stream">cairo_ps_surface_create_for_stream</link>
                                            (<link linkend="cairo-write-func-t">cairo_write_func_t</link> write_func,
                                             <link linkend="void">void</link> *closure,
                                             <link linkend="double">double</link> width_in_points,
                                             <link linkend="double">double</link> height_in_points);
<link linkend="void">void</link>        <link linkend="cairo-ps-surface-set-size">cairo_ps_surface_set_size</link>       (<link linkend="cairo-surface-t">cairo_surface_t</link> *surface,
                                             <link linkend="double">double</link> width_in_points,
                                             <link linkend="double">double</link> height_in_points);
<link linkend="void">void</link>        <link linkend="cairo-ps-surface-dsc-begin-setup">cairo_ps_surface_dsc_begin_setup</link>
                                            (<link linkend="cairo-surface-t">cairo_surface_t</link> *surface);
<link linkend="void">void</link>        <link linkend="cairo-ps-surface-dsc-begin-page-setup">cairo_ps_surface_dsc_begin_page_setup</link>
                                            (<link linkend="cairo-surface-t">cairo_surface_t</link> *surface);
<link linkend="void">void</link>        <link linkend="cairo-ps-surface-dsc-comment">cairo_ps_surface_dsc_comment</link>    (<link linkend="cairo-surface-t">cairo_surface_t</link> *surface,
                                             const <link linkend="char">char</link> *comment);
</synopsis>
</refsynopsisdiv>









<refsect1 role="desc">
<title role="desc.title">Description</title>
<para>

</para>
</refsect1>

<refsect1 role="details">
<title role="details.title">Details</title>
<refsect2>
<title><anchor id="cairo-ps-surface-create" role="function" condition="since:1.2"/>cairo_ps_surface_create ()</title>
<indexterm role="1.2"><primary>cairo_ps_surface_create</primary></indexterm><programlisting><link linkend="cairo-surface-t">cairo_surface_t</link>* cairo_ps_surface_create    (const <link linkend="char">char</link> *filename,
                                             <link linkend="double">double</link> width_in_points,
                                             <link linkend="double">double</link> height_in_points);</programlisting>
<para>
Creates a PostScript surface of the specified size in points to be
written to <parameter>filename</parameter>. See <link linkend="cairo-ps-surface-create-for-stream"><function>cairo_ps_surface_create_for_stream()</function></link> for
a more flexible mechanism for handling the PostScript output than
simply writing it to a named file.
</para>
<para>
Note that the size of individual pages of the PostScript output can
vary. See <link linkend="cairo-ps-surface-set-size"><function>cairo_ps_surface_set_size()</function></link>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>filename</parameter>&nbsp;:</term>
<listitem><simpara> a filename for the PS output (must be writable)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>width_in_points</parameter>&nbsp;:</term>
<listitem><simpara> width of the surface, in points (1 point == 1/72.0 inch)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>height_in_points</parameter>&nbsp;:</term>
<listitem><simpara> height of the surface, in points (1 point == 1/72.0 inch)
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a pointer to the newly created surface. The caller
owns the surface and should call cairo_surface_destroy when done
with it.

This function always returns a valid pointer, but it will return a
pointer to a "nil" surface if an error such as out of memory
occurs. You can use <link linkend="cairo-surface-status"><function>cairo_surface_status()</function></link> to check for this.

</simpara></listitem></varlistentry>
</variablelist><para>Since  1.2
</para></refsect2>
<refsect2>
<title><anchor id="cairo-ps-surface-create-for-stream" role="function" condition="since:1.2"/>cairo_ps_surface_create_for_stream ()</title>
<indexterm role="1.2"><primary>cairo_ps_surface_create_for_stream</primary></indexterm><programlisting><link linkend="cairo-surface-t">cairo_surface_t</link>* cairo_ps_surface_create_for_stream
                                            (<link linkend="cairo-write-func-t">cairo_write_func_t</link> write_func,
                                             <link linkend="void">void</link> *closure,
                                             <link linkend="double">double</link> width_in_points,
                                             <link linkend="double">double</link> height_in_points);</programlisting>
<para>
Creates a PostScript surface of the specified size in points to be
written incrementally to the stream represented by <parameter>write_func</parameter> and
<parameter>closure</parameter>. See <link linkend="cairo-ps-surface-create"><function>cairo_ps_surface_create()</function></link> for a more convenient way
to simply direct the PostScript output to a named file.
</para>
<para>
Note that the size of individual pages of the PostScript
output can vary. See <link linkend="cairo-ps-surface-set-size"><function>cairo_ps_surface_set_size()</function></link>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>write_func</parameter>&nbsp;:</term>
<listitem><simpara> a <link linkend="cairo-write-func-t"><type>cairo_write_func_t</type></link> to accept the output data
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>closure</parameter>&nbsp;:</term>
<listitem><simpara> the closure argument for <parameter>write_func</parameter>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>width_in_points</parameter>&nbsp;:</term>
<listitem><simpara> width of the surface, in points (1 point == 1/72.0 inch)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>height_in_points</parameter>&nbsp;:</term>
<listitem><simpara> height of the surface, in points (1 point == 1/72.0 inch)
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a pointer to the newly created surface. The caller
owns the surface and should call cairo_surface_destroy when done
with it.

This function always returns a valid pointer, but it will return a
pointer to a "nil" surface if an error such as out of memory
occurs. You can use <link linkend="cairo-surface-status"><function>cairo_surface_status()</function></link> to check for this.

</simpara></listitem></varlistentry>
</variablelist><para>Since  1.2
</para></refsect2>
<refsect2>
<title><anchor id="cairo-ps-surface-set-size" role="function" condition="since:1.2"/>cairo_ps_surface_set_size ()</title>
<indexterm role="1.2"><primary>cairo_ps_surface_set_size</primary></indexterm><programlisting><link linkend="void">void</link>        cairo_ps_surface_set_size       (<link linkend="cairo-surface-t">cairo_surface_t</link> *surface,
                                             <link linkend="double">double</link> width_in_points,
                                             <link linkend="double">double</link> height_in_points);</programlisting>
<para>
Changes the size of a PostScript surface for the current (and
subsequent) pages.
</para>
<para>
This function should only be called before any drawing operations
have been performed on the current page. The simplest way to do
this is to call this function immediately after creating the
surface or immediately after completing a page with either
<link linkend="cairo-show-page"><function>cairo_show_page()</function></link> or <link linkend="cairo-copy-page"><function>cairo_copy_page()</function></link>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>surface</parameter>&nbsp;:</term>
<listitem><simpara> a PostScript cairo_surface_t
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>width_in_points</parameter>&nbsp;:</term>
<listitem><simpara> new surface width, in points (1 point == 1/72.0 inch)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>height_in_points</parameter>&nbsp;:</term>
<listitem><simpara> new surface height, in points (1 point == 1/72.0 inch)
</simpara></listitem></varlistentry>
</variablelist><para>Since  1.2
</para></refsect2>
<refsect2>
<title><anchor id="cairo-ps-surface-dsc-begin-setup" role="function" condition="since:1.2"/>cairo_ps_surface_dsc_begin_setup ()</title>
<indexterm role="1.2"><primary>cairo_ps_surface_dsc_begin_setup</primary></indexterm><programlisting><link linkend="void">void</link>        cairo_ps_surface_dsc_begin_setup
                                            (<link linkend="cairo-surface-t">cairo_surface_t</link> *surface);</programlisting>
<para>
This function indicates that subsequent calls to
<link linkend="cairo-ps-surface-dsc-comment"><function>cairo_ps_surface_dsc_comment()</function></link> should direct comments to the Setup
section of the PostScript output.
</para>
<para>
This function should be called at most once per surface, and must
be called before any call to <link linkend="cairo-ps-surface-dsc-begin-page-setup"><function>cairo_ps_surface_dsc_begin_page_setup()</function></link>
and before any drawing is performed to the surface.
</para>
<para>
See <link linkend="cairo-ps-surface-dsc-comment"><function>cairo_ps_surface_dsc_comment()</function></link> for more details.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>surface</parameter>&nbsp;:</term>
<listitem><simpara> a PostScript cairo_surface_t
</simpara></listitem></varlistentry>
</variablelist><para>Since  1.2
</para></refsect2>
<refsect2>
<title><anchor id="cairo-ps-surface-dsc-begin-page-setup" role="function" condition="since:1.2"/>cairo_ps_surface_dsc_begin_page_setup ()</title>
<indexterm role="1.2"><primary>cairo_ps_surface_dsc_begin_page_setup</primary></indexterm><programlisting><link linkend="void">void</link>        cairo_ps_surface_dsc_begin_page_setup
                                            (<link linkend="cairo-surface-t">cairo_surface_t</link> *surface);</programlisting>
<para>
This function indicates that subsequent calls to
<link linkend="cairo-ps-surface-dsc-comment"><function>cairo_ps_surface_dsc_comment()</function></link> should direct comments to the
PageSetup section of the PostScript output.
</para>
<para>
This function call is only needed for the first page of a
surface. It should be called after any call to
<link linkend="cairo-ps-surface-dsc-begin-setup"><function>cairo_ps_surface_dsc_begin_setup()</function></link> and before any drawing is
performed to the surface.
</para>
<para>
See <link linkend="cairo-ps-surface-dsc-comment"><function>cairo_ps_surface_dsc_comment()</function></link> for more details.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>surface</parameter>&nbsp;:</term>
<listitem><simpara> a PostScript cairo_surface_t
</simpara></listitem></varlistentry>
</variablelist><para>Since  1.2
</para></refsect2>
<refsect2>
<title><anchor id="cairo-ps-surface-dsc-comment" role="function" condition="since:1.2"/>cairo_ps_surface_dsc_comment ()</title>
<indexterm role="1.2"><primary>cairo_ps_surface_dsc_comment</primary></indexterm><programlisting><link linkend="void">void</link>        cairo_ps_surface_dsc_comment    (<link linkend="cairo-surface-t">cairo_surface_t</link> *surface,
                                             const <link linkend="char">char</link> *comment);</programlisting>
<para>
Emit a comment into the PostScript output for the given surface.
</para>
<para>
The comment is expected to conform to the PostScript Language
Document Structuring Conventions (DSC). Please see that manual for
details on the available comments and their meanings. In
particular, the %<link linkend="IncludeFeature"><literal>IncludeFeature</literal></link> comment allows a
device-independent means of controlling printer device features. So
the PostScript Printer Description Files Specification will also be
a useful reference.
</para>
<para>
The comment string must begin with a percent character (%) and the
total length of the string (including any initial percent
characters) must not exceed 255 characters. Violating either of
these conditions will place <parameter>surface</parameter> into an error state. But
beyond these two conditions, this function will not enforce
conformance of the comment with any particular specification.
</para>
<para>
The comment string should not have a trailing newline.
</para>
<para>
The DSC specifies different sections in which particular comments
can appear. This function provides for comments to be emitted
within three sections: the header, the Setup section, and the
PageSetup section.  Comments appearing in the first two sections
apply to the entire document while comments in the BeginPageSetup
section apply only to a single page.
</para>
<para>
For comments to appear in the header section, this function should
be called after the surface is created, but before a call to
<link linkend="cairo-ps-surface-begin-setup"><function>cairo_ps_surface_begin_setup()</function></link>.
</para>
<para>
For comments to appear in the Setup section, this function should
be called after a call to <link linkend="cairo-ps-surface-begin-setup"><function>cairo_ps_surface_begin_setup()</function></link> but before
a call to <link linkend="cairo-ps-surface-begin-page-setup"><function>cairo_ps_surface_begin_page_setup()</function></link>.
</para>
<para>
For comments to appear in the PageSetup section, this function
should be called after a call to <link linkend="cairo-ps-surface-begin-page-setup"><function>cairo_ps_surface_begin_page_setup()</function></link>.
</para>
<para>
Note that it is only necessary to call <link linkend="cairo-ps-surface-begin-page-setup"><function>cairo_ps_surface_begin_page_setup()</function></link>
for the first page of any surface. After a call to
<link linkend="cairo-show-page"><function>cairo_show_page()</function></link> or <link linkend="cairo-copy-page"><function>cairo_copy_page()</function></link> comments are unambiguously
directed to the PageSetup section of the current page. But it
doesn't hurt to call this function at the beginning of every page
as that consistency may make the calling code simpler.
</para>
<para>
As a final note, cairo automatically generates several comments on
its own. As such, applications must not manually generate any of
the following comments:
</para>
<para>
Header section: %!PS-Adobe-3.0, %<link linkend="Creator"><literal>Creator</literal></link>, %<link linkend="CreationDate"><literal>CreationDate</literal></link>, %<link linkend="Pages"><literal>Pages</literal></link>,
%<link linkend="BoundingBox"><literal>BoundingBox</literal></link>, %<link linkend="DocumentData"><literal>DocumentData</literal></link>, %<link linkend="LanguageLevel"><literal>LanguageLevel</literal></link>, %<link linkend="EndComments"><literal>EndComments</literal></link>.
</para>
<para>
Setup section: %<link linkend="BeginSetup"><literal>BeginSetup</literal></link>, %<link linkend="EndSetup"><literal>EndSetup</literal></link>
</para>
<para>
PageSetup section: %<link linkend="BeginPageSetup"><literal>BeginPageSetup</literal></link>, %<link linkend="PageBoundingBox"><literal>PageBoundingBox</literal></link>,
%<link linkend="EndPageSetup"><literal>EndPageSetup</literal></link>.
</para>
<para>
Other sections: %<link linkend="BeginProlog"><literal>BeginProlog</literal></link>, %<link linkend="EndProlog"><literal>EndProlog</literal></link>, %<link linkend="Page"><literal>Page</literal></link>, %<link linkend="Trailer"><literal>Trailer</literal></link>, %<link linkend="EOF:CAPS"><literal>EOF</literal></link>
</para>
<para>
Here is an example sequence showing how this function might be used:
</para>
<para>
<informalexample><programlisting>
cairo_surface_t *surface = cairo_ps_surface_create (filename, width, height);
...
cairo_ps_surface_dsc_comment (surface, "%<link linkend="Title"><literal>Title</literal></link>: My excellent document");
cairo_ps_surface_dsc_comment (surface, "%<link linkend="Copyright"><literal>Copyright</literal></link>: Copyright (C) 2006 Cairo Lover")
...
cairo_ps_surface_dsc_begin_setup (surface);
cairo_ps_surface_dsc_comment (surface, "%<link linkend="IncludeFeature"><literal>IncludeFeature</literal></link>: *MediaColor White");
...
cairo_ps_surface_dsc_begin_page_setup (surface);
cairo_ps_surface_dsc_comment (surface, "%<link linkend="IncludeFeature"><literal>IncludeFeature</literal></link>: *PageSize A3");
cairo_ps_surface_dsc_comment (surface, "%<link linkend="IncludeFeature"><literal>IncludeFeature</literal></link>: *InputSlot LargeCapacity");
cairo_ps_surface_dsc_comment (surface, "%<link linkend="IncludeFeature"><literal>IncludeFeature</literal></link>: *MediaType Glossy");
cairo_ps_surface_dsc_comment (surface, "%<link linkend="IncludeFeature"><literal>IncludeFeature</literal></link>: *MediaColor Blue");
... draw to first page here ..
cairo_show_page (cr);
...
cairo_ps_surface_dsc_comment (surface, "%<link linkend="IncludeFeature"><literal>IncludeFeature</literal></link>: *PageSize A5");
...
</programlisting></informalexample></para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>surface</parameter>&nbsp;:</term>
<listitem><simpara> a PostScript cairo_surface_t
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>comment</parameter>&nbsp;:</term>
<listitem><simpara> a comment string to be emitted into the PostScript output
</simpara></listitem></varlistentry>
</variablelist><para>Since  1.2
</para></refsect2>

</refsect1>




</refentry>