<?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" id="cairo-PostScript-Surfaces.top_of_page">PostScript Surfaces</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>
  CAIRO Library
</refmiscinfo>
</refmeta>
<refnamediv>
<refname>PostScript Surfaces</refname>
<refpurpose>Rendering PostScript documents</refpurpose>
</refnamediv>

<refsynopsisdiv id="cairo-PostScript-Surfaces.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>#define             <link linkend="CAIRO-HAS-PS-SURFACE:CAPS">CAIRO_HAS_PS_SURFACE</link>
<link linkend="cairo-surface-t"><returnvalue>cairo_surface_t</returnvalue></link> *   <link linkend="cairo-ps-surface-create">cairo_ps_surface_create</link>             (<parameter>const <link linkend="char"><type>char</type></link> *filename</parameter>,
                                                         <parameter><link linkend="double"><type>double</type></link> width_in_points</parameter>,
                                                         <parameter><link linkend="double"><type>double</type></link> height_in_points</parameter>);
<link linkend="cairo-surface-t"><returnvalue>cairo_surface_t</returnvalue></link> *   <link linkend="cairo-ps-surface-create-for-stream">cairo_ps_surface_create_for_stream</link>  (<parameter><link linkend="cairo-write-func-t"><type>cairo_write_func_t</type></link> write_func</parameter>,
                                                         <parameter><link linkend="void"><type>void</type></link> *closure</parameter>,
                                                         <parameter><link linkend="double"><type>double</type></link> width_in_points</parameter>,
                                                         <parameter><link linkend="double"><type>double</type></link> height_in_points</parameter>);
<link linkend="void"><returnvalue>void</returnvalue></link>                <link linkend="cairo-ps-surface-restrict-to-level">cairo_ps_surface_restrict_to_level</link>  (<parameter><link linkend="cairo-surface-t"><type>cairo_surface_t</type></link> *surface</parameter>,
                                                         <parameter><link linkend="cairo-ps-level-t"><type>cairo_ps_level_t</type></link> level</parameter>);
enum                <link linkend="cairo-ps-level-t">cairo_ps_level_t</link>;
<link linkend="void"><returnvalue>void</returnvalue></link>                <link linkend="cairo-ps-get-levels">cairo_ps_get_levels</link>                 (<parameter><link linkend="cairo-ps-level-t"><type>cairo_ps_level_t</type></link> const **levels</parameter>,
                                                         <parameter><link linkend="int"><type>int</type></link> *num_levels</parameter>);
const <link linkend="char"><returnvalue>char</returnvalue></link> *        <link linkend="cairo-ps-level-to-string">cairo_ps_level_to_string</link>            (<parameter><link linkend="cairo-ps-level-t"><type>cairo_ps_level_t</type></link> level</parameter>);
<link linkend="void"><returnvalue>void</returnvalue></link>                <link linkend="cairo-ps-surface-set-eps">cairo_ps_surface_set_eps</link>            (<parameter><link linkend="cairo-surface-t"><type>cairo_surface_t</type></link> *surface</parameter>,
                                                         <parameter><link linkend="cairo-bool-t"><type>cairo_bool_t</type></link> eps</parameter>);
<link linkend="cairo-bool-t"><returnvalue>cairo_bool_t</returnvalue></link>        <link linkend="cairo-ps-surface-get-eps">cairo_ps_surface_get_eps</link>            (<parameter><link linkend="cairo-surface-t"><type>cairo_surface_t</type></link> *surface</parameter>);
<link linkend="void"><returnvalue>void</returnvalue></link>                <link linkend="cairo-ps-surface-set-size">cairo_ps_surface_set_size</link>           (<parameter><link linkend="cairo-surface-t"><type>cairo_surface_t</type></link> *surface</parameter>,
                                                         <parameter><link linkend="double"><type>double</type></link> width_in_points</parameter>,
                                                         <parameter><link linkend="double"><type>double</type></link> height_in_points</parameter>);
<link linkend="void"><returnvalue>void</returnvalue></link>                <link linkend="cairo-ps-surface-dsc-begin-setup">cairo_ps_surface_dsc_begin_setup</link>    (<parameter><link linkend="cairo-surface-t"><type>cairo_surface_t</type></link> *surface</parameter>);
<link linkend="void"><returnvalue>void</returnvalue></link>                <link linkend="cairo-ps-surface-dsc-begin-page-setup">cairo_ps_surface_dsc_begin_page_setup</link>
                                                        (<parameter><link linkend="cairo-surface-t"><type>cairo_surface_t</type></link> *surface</parameter>);
<link linkend="void"><returnvalue>void</returnvalue></link>                <link linkend="cairo-ps-surface-dsc-comment">cairo_ps_surface_dsc_comment</link>        (<parameter><link linkend="cairo-surface-t"><type>cairo_surface_t</type></link> *surface</parameter>,
                                                         <parameter>const <link linkend="char"><type>char</type></link> *comment</parameter>);
</synopsis>
</refsynopsisdiv>

<refsect1 id="cairo-PostScript-Surfaces.description" role="desc">
<title role="desc.title">Description</title>
<para>
The PostScript surface is used to render cairo graphics to Adobe
PostScript files and is a multi-page vector surface backend.
</para>
</refsect1>
<refsect1 id="cairo-PostScript-Surfaces.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="CAIRO-HAS-PS-SURFACE:CAPS" role="macro">
<title>CAIRO_HAS_PS_SURFACE</title>
<indexterm zone="CAIRO-HAS-PS-SURFACE:CAPS"><primary sortas="HAS_PS_SURFACE">CAIRO_HAS_PS_SURFACE</primary></indexterm>
<programlisting>#define CAIRO_HAS_PS_SURFACE 1
</programlisting>
<para>
Defined if the PostScript surface backend is available.
This macro can be used to conditionally compile backend-specific code.
</para></refsect2>
<refsect2 id="cairo-ps-surface-create" role="function" condition="since:1.2">
<title>cairo_ps_surface_create ()</title>
<indexterm zone="cairo-ps-surface-create" role="1.2"><primary sortas="ps_surface_create">cairo_ps_surface_create</primary></indexterm>
<programlisting><link linkend="cairo-surface-t"><returnvalue>cairo_surface_t</returnvalue></link> *   cairo_ps_surface_create             (<parameter>const <link linkend="char"><type>char</type></link> *filename</parameter>,
                                                         <parameter><link linkend="double"><type>double</type></link> width_in_points</parameter>,
                                                         <parameter><link linkend="double"><type>double</type></link> height_in_points</parameter>);</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><variablelist role="params">
<varlistentry><term><parameter>filename</parameter>&#160;:</term>
<listitem><simpara>a filename for the PS output (must be writable), <link linkend="NULL:CAPS"><literal>NULL</literal></link> may be
           used to specify no output. This will generate a PS surface that
           may be queried and used as a source, without generating a
           temporary file.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>width_in_points</parameter>&#160;:</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>&#160;:</term>
<listitem><simpara>height of the surface, in points (1 point == 1/72.0 inch)
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a pointer to the newly created surface. The caller
owns the surface and should call <link linkend="cairo-surface-destroy"><function>cairo_surface_destroy()</function></link> 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 role="since">Since 1.2</para></refsect2>
<refsect2 id="cairo-ps-surface-create-for-stream" role="function" condition="since:1.2">
<title>cairo_ps_surface_create_for_stream ()</title>
<indexterm zone="cairo-ps-surface-create-for-stream" role="1.2"><primary sortas="ps_surface_create_for_stream">cairo_ps_surface_create_for_stream</primary></indexterm>
<programlisting><link linkend="cairo-surface-t"><returnvalue>cairo_surface_t</returnvalue></link> *   cairo_ps_surface_create_for_stream  (<parameter><link linkend="cairo-write-func-t"><type>cairo_write_func_t</type></link> write_func</parameter>,
                                                         <parameter><link linkend="void"><type>void</type></link> *closure</parameter>,
                                                         <parameter><link linkend="double"><type>double</type></link> width_in_points</parameter>,
                                                         <parameter><link linkend="double"><type>double</type></link> height_in_points</parameter>);</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><variablelist role="params">
<varlistentry><term><parameter>write_func</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="cairo-write-func-t"><type>cairo_write_func_t</type></link> to accept the output data, may be <link linkend="NULL:CAPS"><literal>NULL</literal></link>
             to indicate a no-op <parameter>write_func</parameter>. With a no-op <parameter>write_func</parameter>,
             the surface may be queried or used as a source without
             generating any temporary files.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>closure</parameter>&#160;:</term>
<listitem><simpara>the closure argument for <parameter>write_func</parameter>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>width_in_points</parameter>&#160;:</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>&#160;:</term>
<listitem><simpara>height of the surface, in points (1 point == 1/72.0 inch)
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a pointer to the newly created surface. The caller
owns the surface and should call <link linkend="cairo-surface-destroy"><function>cairo_surface_destroy()</function></link> 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 role="since">Since 1.2</para></refsect2>
<refsect2 id="cairo-ps-surface-restrict-to-level" role="function" condition="since:1.6">
<title>cairo_ps_surface_restrict_to_level ()</title>
<indexterm zone="cairo-ps-surface-restrict-to-level" role="1.6"><primary sortas="ps_surface_restrict_to_level">cairo_ps_surface_restrict_to_level</primary></indexterm>
<programlisting><link linkend="void"><returnvalue>void</returnvalue></link>                cairo_ps_surface_restrict_to_level  (<parameter><link linkend="cairo-surface-t"><type>cairo_surface_t</type></link> *surface</parameter>,
                                                         <parameter><link linkend="cairo-ps-level-t"><type>cairo_ps_level_t</type></link> level</parameter>);</programlisting>
<para>
Restricts the generated PostSript file to <parameter>level</parameter>. See
<link linkend="cairo-ps-get-levels"><function>cairo_ps_get_levels()</function></link> for a list of available level values that
can be used here.
</para>
<para>
This function should only be called before any drawing operations
have been performed on the given surface. The simplest way to do
this is to call this function immediately after creating the
surface.
</para><variablelist role="params">
<varlistentry><term><parameter>surface</parameter>&#160;:</term>
<listitem><simpara>a PostScript <link linkend="cairo-surface-t"><type>cairo_surface_t</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>level</parameter>&#160;:</term>
<listitem><simpara>PostScript level
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.6</para></refsect2>
<refsect2 id="cairo-ps-level-t" role="enum">
<title>enum cairo_ps_level_t</title>
<indexterm zone="cairo-ps-level-t"><primary sortas="ps_level_t">cairo_ps_level_t</primary></indexterm>
<programlisting>typedef enum _cairo_ps_level {
    CAIRO_PS_LEVEL_2,
    CAIRO_PS_LEVEL_3
} cairo_ps_level_t;
</programlisting>
<para>
<link linkend="cairo-ps-level-t"><type>cairo_ps_level_t</type></link> is used to describe the language level of the
PostScript Language Reference that a generated PostScript file will
conform to.
</para><variablelist role="enum">
<varlistentry id="CAIRO-PS-LEVEL-2:CAPS" role="constant">
<term><literal>CAIRO_PS_LEVEL_2</literal></term>
<listitem><simpara>The language level 2 of the PostScript specification.
</simpara></listitem>
</varlistentry>
<varlistentry id="CAIRO-PS-LEVEL-3:CAPS" role="constant">
<term><literal>CAIRO_PS_LEVEL_3</literal></term>
<listitem><simpara>The language level 3 of the PostScript specification.
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="cairo-ps-get-levels" role="function" condition="since:1.6">
<title>cairo_ps_get_levels ()</title>
<indexterm zone="cairo-ps-get-levels" role="1.6"><primary sortas="ps_get_levels">cairo_ps_get_levels</primary></indexterm>
<programlisting><link linkend="void"><returnvalue>void</returnvalue></link>                cairo_ps_get_levels                 (<parameter><link linkend="cairo-ps-level-t"><type>cairo_ps_level_t</type></link> const **levels</parameter>,
                                                         <parameter><link linkend="int"><type>int</type></link> *num_levels</parameter>);</programlisting>
<para>
Used to retrieve the list of supported levels. See
<link linkend="cairo-ps-surface-restrict-to-level"><function>cairo_ps_surface_restrict_to_level()</function></link>.
</para><variablelist role="params">
<varlistentry><term><parameter>levels</parameter>&#160;:</term>
<listitem><simpara>supported level list
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>num_levels</parameter>&#160;:</term>
<listitem><simpara>list length
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.6</para></refsect2>
<refsect2 id="cairo-ps-level-to-string" role="function" condition="since:1.6">
<title>cairo_ps_level_to_string ()</title>
<indexterm zone="cairo-ps-level-to-string" role="1.6"><primary sortas="ps_level_to_string">cairo_ps_level_to_string</primary></indexterm>
<programlisting>const <link linkend="char"><returnvalue>char</returnvalue></link> *        cairo_ps_level_to_string            (<parameter><link linkend="cairo-ps-level-t"><type>cairo_ps_level_t</type></link> level</parameter>);</programlisting>
<para>
Get the string representation of the given <parameter>level</parameter> id. This function
will return <link linkend="NULL:CAPS"><literal>NULL</literal></link> if <parameter>level</parameter> id isn't valid. See <link linkend="cairo-ps-get-levels"><function>cairo_ps_get_levels()</function></link>
for a way to get the list of valid level ids.
</para><variablelist role="params">
<varlistentry><term><parameter>level</parameter>&#160;:</term>
<listitem><simpara>a level id
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the string associated to given level.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.6</para></refsect2>
<refsect2 id="cairo-ps-surface-set-eps" role="function" condition="since:1.6">
<title>cairo_ps_surface_set_eps ()</title>
<indexterm zone="cairo-ps-surface-set-eps" role="1.6"><primary sortas="ps_surface_set_eps">cairo_ps_surface_set_eps</primary></indexterm>
<programlisting><link linkend="void"><returnvalue>void</returnvalue></link>                cairo_ps_surface_set_eps            (<parameter><link linkend="cairo-surface-t"><type>cairo_surface_t</type></link> *surface</parameter>,
                                                         <parameter><link linkend="cairo-bool-t"><type>cairo_bool_t</type></link> eps</parameter>);</programlisting>
<para>
If <parameter>eps</parameter> is <link linkend="TRUE:CAPS"><literal>TRUE</literal></link>, the PostScript surface will output Encapsulated
PostScript.
</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. An Encapsulated PostScript file should never contain more
than one page.
</para><variablelist role="params">
<varlistentry><term><parameter>surface</parameter>&#160;:</term>
<listitem><simpara>a PostScript <link linkend="cairo-surface-t"><type>cairo_surface_t</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>eps</parameter>&#160;:</term>
<listitem><simpara><link linkend="TRUE:CAPS"><literal>TRUE</literal></link> to output EPS format PostScript
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.6</para></refsect2>
<refsect2 id="cairo-ps-surface-get-eps" role="function" condition="since:1.6">
<title>cairo_ps_surface_get_eps ()</title>
<indexterm zone="cairo-ps-surface-get-eps" role="1.6"><primary sortas="ps_surface_get_eps">cairo_ps_surface_get_eps</primary></indexterm>
<programlisting><link linkend="cairo-bool-t"><returnvalue>cairo_bool_t</returnvalue></link>        cairo_ps_surface_get_eps            (<parameter><link linkend="cairo-surface-t"><type>cairo_surface_t</type></link> *surface</parameter>);</programlisting>
<para>
Check whether the PostScript surface will output Encapsulated PostScript.
</para><variablelist role="params">
<varlistentry><term><parameter>surface</parameter>&#160;:</term>
<listitem><simpara>a PostScript <link linkend="cairo-surface-t"><type>cairo_surface_t</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if the surface will output Encapsulated PostScript.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.6</para></refsect2>
<refsect2 id="cairo-ps-surface-set-size" role="function" condition="since:1.2">
<title>cairo_ps_surface_set_size ()</title>
<indexterm zone="cairo-ps-surface-set-size" role="1.2"><primary sortas="ps_surface_set_size">cairo_ps_surface_set_size</primary></indexterm>
<programlisting><link linkend="void"><returnvalue>void</returnvalue></link>                cairo_ps_surface_set_size           (<parameter><link linkend="cairo-surface-t"><type>cairo_surface_t</type></link> *surface</parameter>,
                                                         <parameter><link linkend="double"><type>double</type></link> width_in_points</parameter>,
                                                         <parameter><link linkend="double"><type>double</type></link> height_in_points</parameter>);</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><variablelist role="params">
<varlistentry><term><parameter>surface</parameter>&#160;:</term>
<listitem><simpara>a PostScript <link linkend="cairo-surface-t"><type>cairo_surface_t</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>width_in_points</parameter>&#160;:</term>
<listitem><simpara>new surface width, in points (1 point == 1/72.0 inch)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>height_in_points</parameter>&#160;:</term>
<listitem><simpara>new surface height, in points (1 point == 1/72.0 inch)
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.2</para></refsect2>
<refsect2 id="cairo-ps-surface-dsc-begin-setup" role="function" condition="since:1.2">
<title>cairo_ps_surface_dsc_begin_setup ()</title>
<indexterm zone="cairo-ps-surface-dsc-begin-setup" role="1.2"><primary sortas="ps_surface_dsc_begin_setup">cairo_ps_surface_dsc_begin_setup</primary></indexterm>
<programlisting><link linkend="void"><returnvalue>void</returnvalue></link>                cairo_ps_surface_dsc_begin_setup    (<parameter><link linkend="cairo-surface-t"><type>cairo_surface_t</type></link> *surface</parameter>);</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><variablelist role="params">
<varlistentry><term><parameter>surface</parameter>&#160;:</term>
<listitem><simpara>a PostScript <link linkend="cairo-surface-t"><type>cairo_surface_t</type></link>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.2</para></refsect2>
<refsect2 id="cairo-ps-surface-dsc-begin-page-setup" role="function" condition="since:1.2">
<title>cairo_ps_surface_dsc_begin_page_setup ()</title>
<indexterm zone="cairo-ps-surface-dsc-begin-page-setup" role="1.2"><primary sortas="ps_surface_dsc_begin_page_setup">cairo_ps_surface_dsc_begin_page_setup</primary></indexterm>
<programlisting><link linkend="void"><returnvalue>void</returnvalue></link>                cairo_ps_surface_dsc_begin_page_setup
                                                        (<parameter><link linkend="cairo-surface-t"><type>cairo_surface_t</type></link> *surface</parameter>);</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><variablelist role="params">
<varlistentry><term><parameter>surface</parameter>&#160;:</term>
<listitem><simpara>a PostScript <link linkend="cairo-surface-t"><type>cairo_surface_t</type></link>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.2</para></refsect2>
<refsect2 id="cairo-ps-surface-dsc-comment" role="function" condition="since:1.2">
<title>cairo_ps_surface_dsc_comment ()</title>
<indexterm zone="cairo-ps-surface-dsc-comment" role="1.2"><primary sortas="ps_surface_dsc_comment">cairo_ps_surface_dsc_comment</primary></indexterm>
<programlisting><link linkend="void"><returnvalue>void</returnvalue></link>                cairo_ps_surface_dsc_comment        (<parameter><link linkend="cairo-surface-t"><type>cairo_surface_t</type></link> *surface</parameter>,
                                                         <parameter>const <link linkend="char"><type>char</type></link> *comment</parameter>);</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>
<link linkend="cairo-surface-t">cairo_surface_t</link> *surface = cairo_ps_surface_create (filename, width, height);
...
cairo_ps_surface_dsc_comment (surface, "%%Title: My excellent document");
cairo_ps_surface_dsc_comment (surface, "%%Copyright: Copyright (C) 2006 Cairo Lover")
...
cairo_ps_surface_dsc_begin_setup (surface);
cairo_ps_surface_dsc_comment (surface, "%%IncludeFeature: *MediaColor White");
...
cairo_ps_surface_dsc_begin_page_setup (surface);
cairo_ps_surface_dsc_comment (surface, "%%IncludeFeature: *PageSize A3");
cairo_ps_surface_dsc_comment (surface, "%%IncludeFeature: *InputSlot LargeCapacity");
cairo_ps_surface_dsc_comment (surface, "%%IncludeFeature: *MediaType Glossy");
cairo_ps_surface_dsc_comment (surface, "%%IncludeFeature: *MediaColor Blue");
... draw to first page here ..
cairo_show_page (cr);
...
cairo_ps_surface_dsc_comment (surface, "%%IncludeFeature: *PageSize A5");
...
</programlisting></informalexample>
</para><variablelist role="params">
<varlistentry><term><parameter>surface</parameter>&#160;:</term>
<listitem><simpara>a PostScript <link linkend="cairo-surface-t"><type>cairo_surface_t</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>comment</parameter>&#160;:</term>
<listitem><simpara>a comment string to be emitted into the PostScript output
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.2</para></refsect2>

</refsect1>
<refsect1 id="cairo-PostScript-Surfaces.see-also">
<title>See Also</title>
<link linkend="cairo-surface-t"><type>cairo_surface_t</type></link>
</refsect1>

</refentry>
