File: chapter-printing.html

package info (click to toggle)
gtkmm-documentation 4.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 25,772 kB
  • sloc: cpp: 15,541; javascript: 1,208; makefile: 1,080; python: 401; xml: 106; perl: 67; sh: 8
file content (199 lines) | stat: -rw-r--r-- 7,527 bytes parent folder | download
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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="highlight.min.css">
<script src="highlight.min.js"></script><script>
      hljs.configure({languages: ['cpp']});
      hljs.highlightAll();
    </script><title>Chapter 21. Printing</title>
<link rel="stylesheet" type="text/css" href="style.css">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="Programming with gtkmm 4">
<link rel="up" href="index.html" title="Programming with gtkmm 4">
<link rel="prev" href="sec-clipboard-examples.html" title="Examples">
<link rel="next" href="sec-page-setup.html" title="Page setup">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">Chapter 21. Printing</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="sec-clipboard-examples.html"><img src="icons/prev.png" alt="Prev"></a> </td>
<th width="60%" align="center"> </th>
<td width="20%" align="right"> <a accesskey="n" href="sec-page-setup.html"><img src="icons/next.png" alt="Next"></a>
</td>
</tr>
</table>
<hr>
</div>
<div class="chapter">
<div class="titlepage"><div><div><h1 class="title">
<a name="chapter-printing"></a>Chapter 21. Printing</h1></div></div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<ul class="toc">
<li><span class="section"><a href="chapter-printing.html#sec-printoperation">PrintOperation</a></span></li>
<li><span class="section"><a href="sec-page-setup.html">Page setup</a></span></li>
<li><span class="section"><a href="sec-printing-rendering-text.html">Rendering text</a></span></li>
<li><span class="section"><a href="sec-async-printing-ops.html">Asynchronous operations</a></span></li>
<li><span class="section"><a href="sec-printing-export-to-pdf.html">Export to PDF</a></span></li>
<li><span class="section"><a href="sec-extending-print-dialog.html">Extending the print dialog</a></span></li>
<li><span class="section"><a href="sec-printing-preview.html">Preview</a></span></li>
<li><span class="section"><a href="sec-printing-printdialog.html">PrintDialog</a></span></li>
<li><span class="section"><a href="sec-printing-examples.html">Examples</a></span></li>
</ul>
</div>


<p>
At the application development level, <span class="application">gtkmm</span>'s printing API
provides dialogs that are consistent across applications and allows use of Cairo's common drawing API, with Pango-driven text rendering. In the implementation of this common API, platform-specific backends and printer-specific drivers are used.
</p>

<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="sec-printoperation"></a>PrintOperation</h2></div></div></div>


<p>
The primary object is <code class="classname">Gtk::PrintOperation</code>, allocated
for each print operation. To handle page drawing connect to its signals,
or inherit from it and override the default virtual signal handlers.
<code class="classname">PrintOperation</code> automatically handles all the settings
affecting the print loop.
</p>

<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="sec-printoperation-signals"></a>Signals</h3></div></div></div>


<p>
The <code class="methodname">PrintOperation::run()</code> method starts the print loop,
during which various signals are emitted:

</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
    <p>
      <code class="literal">begin_print</code>:
      You must handle this signal, because this is where you
      create and set up a <code class="classname">Pango::Layout</code> using the
      provided <code class="classname">Gtk::PrintContext</code>, and break up your
      printing output into pages.
    </p>
  </li>
<li class="listitem">
    <p>
      <code class="literal">paginate</code>: Pagination is potentially slow so if you
      need to monitor it you can call the
      <code class="methodname">PrintOperation::set_show_progress()</code> method and
      handle this signal.
    </p>
  </li>
<li class="listitem">
    <p>
      For each page that needs to be rendered, the following signals
      are emitted:
      </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
          <p>
            <code class="literal">request_page_setup</code>: Provides a
            <code class="classname">PrintContext</code>, page number and
            <code class="classname">Gtk::PageSetup</code>. Handle this signal if you
            need to modify page setup on a per-page basis.
          </p>
        </li>
<li class="listitem">
          <p>
            <code class="literal">draw_page</code>: You must handle this signal, which provides a
            <code class="classname">PrintContext</code> and a page number.
            The <code class="classname">PrintContext</code> should be used
            to create a <code class="classname">Cairo::Context</code> into which
            the provided page should be drawn. To render text, iterate over
            the <code class="classname">Pango::Layout</code> you created in the
            <code class="literal">begin_print</code> handler.
          </p>
        </li>
</ul></div>
<p>
    </p>
  </li>
<li class="listitem">
    <p>
      <code class="literal">end_print</code>: A handler for it is a safe place to free
      any resources related to a <code class="classname">PrintOperation</code>.
      If you have your custom class that inherits from
      <code class="classname">PrintOperation</code>, it is naturally simpler to do it
      in the destructor.
    </p>
  </li>
<li class="listitem">
    <p>
      <code class="literal">done</code>: This signal is emitted when printing is finished, meaning when the
      print data is spooled. Note that the provided
      <code class="literal">Gtk::PrintOperation::Result</code> may indicate that
      an error occurred. In any case you probably want to notify the user
      about the final status.
    </p>
  </li>
<li class="listitem">
    <p>
      <code class="literal">status_changed</code>: Emitted whenever a print job's
      status changes, until it is finished. Call the
      <code class="methodname">PrintOperation::set_track_print_status()</code> method to
      monitor the job status after spooling. To see the status, use
      <code class="methodname">get_status()</code> or
      <code class="methodname">get_status_string()</code>.
    </p>
  </li>
</ul></div>
<p>

</p>

<p>
<a class="ulink" href="https://gnome.pages.gitlab.gnome.org/gtkmm/classGtk_1_1PrintOperation.html" target="_top">Reference</a>
</p>

</div>

</div>
















</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="sec-clipboard-examples.html"><img src="icons/prev.png" alt="Prev"></a> </td>
<td width="20%" align="center"> </td>
<td width="40%" align="right"> <a accesskey="n" href="sec-page-setup.html"><img src="icons/next.png" alt="Next"></a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Examples </td>
<td width="20%" align="center"><a accesskey="h" href="index.html"><img src="icons/home.png" alt="Home"></a></td>
<td width="40%" align="right" valign="top"> Page setup</td>
</tr>
</table>
</div>
</body>
</html>