summaryrefslogtreecommitdiff
blob: 69af73169567091e4169f5aa5382d1052af19564 (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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
<html lang="en">
    <head>
        <title>Ghostscript language bindings</title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
        <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,200i,300,300i,400,400i,600,600i,700,700i,900,900i" rel="stylesheet">
        <link rel="shortcut icon" href="../images/favicon.svg">
        <link href="css/default.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="js/default.js"></script>
    </head>

    <body>

        <header><h1></h1><div class="menu-icon" onclick="javascript:showMenu();"></div></header>

        <div id="burger-menu">
            <div class="navigation">
                <div class="title first">Introduction</div>
                <div class="link"><a href="index.html">About our APIs</a></div>
                <div class="link"><a href="demo-code.html">Demo code</a></div>

                <div class="title">C#</div>
                <div class="link"><a href="c-sharp-intro.html">Overview</a></div>
                <div class="link"><a href="c-sharp-ghost-api.html">GhostAPI</a></div>
                <div class="link selected"><a href="c-sharp-ghost-net.html">GhostNET</a></div>
                <div class="link"><a href="c-sharp-ghost-mono.html">GhostMono</a></div>

                <div class="title">Java</div>
                <div class="link"><a href="java-intro.html">Overview</a></div>
                <div class="link"><a href="java-gsjavajar.html">gsjava.jar</a></div>

                <div class="title">Python</div>
                <div class="link"><a href="python-intro.html">Overview</a></div>
                <div class="link"><a href="python-gsapi.html">gsapi.py</a></div>
            </div>
        </div>
        <div class="main">

            <div class="left">
                <div class="title first">Introduction</div>
                <div class="link"><a href="index.html">About our APIs</a></div>
                <div class="link"><a href="demo-code.html">Demo code</a></div>

                <div class="title">C#</div>
                <div class="link"><a href="c-sharp-intro.html">Overview</a></div>
                <div class="link"><a href="c-sharp-ghost-api.html">GhostAPI</a></div>
                <div class="link selected"><a href="c-sharp-ghost-net.html">GhostNET</a></div>
                <div class="link"><a href="c-sharp-ghost-mono.html">GhostMono</a></div>

                <div class="title">Java</div>
                <div class="link"><a href="java-intro.html">Overview</a></div>
                <div class="link"><a href="java-gsjavajar.html">gsjava.jar</a></div>

                <div class="title">Python</div>
                <div class="link"><a href="python-intro.html">Overview</a></div>
                <div class="link"><a href="python-gsapi.html">gsapi.py</a></div>
            </div>

            <div class="middle">

<!-- note: don't tab indent <article> as it has <pre> code which will have its layout adversly affected -->
<article class="markdown-body entry-content"><h1 id="ghostnet">GhostNET</h1>
<div class="banner">
    <div class="c-sharp-text"></div>
    <div class="vendor-logo c-sharp-logo"></div>
</div>


<h2 id="about">About</h2>
<p><code>GhostNET</code> is the <code>C#</code> interface into the <code>GhostAPI</code> library developed for Windows systems.</p>
<h2 id="enums">Enums</h2>
<h3 id="tasks">Tasks</h3>
<p>The Ghostscript task type <code>enum</code> is used to inform <code>GhostAPI</code> of the type of operation which is being requested.</p>
<table>
<thead>
<tr>
<th>Task</th>
<th>Description</th>
</tr>
</thead>
<tbody><tr>
<td>PS_DISTILL</td>
<td>Task associated with converting a PostScript stream to a PDF document</td>
</tr>
<tr>
<td>CREATE_XPS</td>
<td>Task associated with outputting  a copy of a document to XPS</td>
</tr>
<tr>
<td>SAVE_RESULT</td>
<td>Task associated with saving documents</td>
</tr>
<tr>
<td>GET_PAGE_COUNT</td>
<td>Task associated with getting the page count of a document</td>
</tr>
<tr>
<td>GENERIC</td>
<td>Generic task identifier</td>
</tr>
<tr>
<td>DISPLAY_DEV_THUMBS</td>
<td>Display Device task associated with rendering thumbnails</td>
</tr>
<tr>
<td>DISPLAY_DEV_NON_PDF</td>
<td>Display Device task associated with non-PDF or non-XPS rendering <sup><a href="#1-ghostscript-page-description-languages">1</a></sup></td>
</tr>
<tr>
<td>DISPLAY_DEV_PDF</td>
<td>Display Device task associated with PDF &amp; XPS rendering <sup><a href="#1-ghostscript-page-description-languages">1</a></sup></td>
</tr>
<tr>
<td>DISPLAY_DEV_RUN_FILE</td>
<td>Display Device task associated with running files</td>
</tr>
</tbody></table>
<p>Task types are defined as <code>GS_Task_t</code>.</p>
<div class="tag enumDefinition csharp"></div>

<pre><code class="language-c">public enum GS_Task_t
{
    PS_DISTILL,
    CREATE_XPS,
    SAVE_RESULT,
    GET_PAGE_COUNT,
    GENERIC,
    DISPLAY_DEV_THUMBS,
    DISPLAY_DEV_NON_PDF,
    DISPLAY_DEV_PDF,
    DISPLAY_DEV_RUN_FILE
}</code></pre>
<h3 id="results">Results</h3>
<p>Result types are defined as <code>GS_Result_t</code>.</p>
<div class="tag enumDefinition csharp"></div>

<pre><code class="language-c">public enum GS_Result_t
{
    gsOK,
    gsFAILED,
    gsCANCELLED
}</code></pre>
<h3 id="status">Status</h3>
<p>Status is defined as <code>gsStatus</code>.</p>
<div class="tag enumDefinition csharp"></div>

<pre><code class="language-c">public enum gsStatus
{
    GS_READY,
    GS_BUSY,
    GS_ERROR
};</code></pre>
<h2 id="the-parameter-struct">The Parameter Struct</h2>
<p>The parameter struct <code>gsParamState_t</code> allows for bundles of information to be processed by Ghostscript to complete overall requests.</p>
<div class="tag structDefinition csharp"></div>

<pre><code class="language-c">public struct gsParamState_t
{
    public String outputfile;
    public String inputfile;
    public GS_Task_t task;
    public GS_Result_t result;
    public int num_pages;
    public List&lt;int&gt; pages;
    public int firstpage;
    public int lastpage;
    public int currpage;
    public List&lt;String&gt; args;
    public int return_code;
    public double zoom;
    public bool aa;
    public bool is_valid;
};</code></pre>
<h3 id="parameters-explained">Parameters explained</h3>
<p>Setting up your parameters (with any dedicated bespoke method(s) which your application requires) is needed when communicating directly with <code>GhostAPI</code>.</p>
<p>When requesting Ghostscript to process an operation an application developer should send a parameter payload which defines the details for the operation.</p>
<p>For example in <code>GhostNET</code> we can see the public method as follows:</p>
<div class="tag sampleCode csharp"></div>

<pre><code class="language-c">public gsStatus DistillPS(String fileName, int resolution)
{
    gsParamState_t gsparams = new gsParamState_t();
    gsparams.args = new List&lt;string&gt;();

    gsparams.inputfile = fileName;
    gsparams.args.Add("gs");
    gsparams.args.Add("-sDEVICE=pdfwrite");
    gsparams.outputfile = Path.GetTempFileName();
    gsparams.args.Add("-o" + gsparams.outputfile);
    gsparams.task = GS_Task_t.PS_DISTILL;

    return RunGhostscriptAsync(gsparams);
}</code></pre>
<p>Here we can see a parameter payload being setup before being passed on to the asynchronous method <code>RunGhostscriptAsync</code> which sets up a worker thread to run according to the task type in the payload.</p>
<p><code>GhostNET</code> handles many common operations on an application developer's behalf, however if you require to write your own methods to interface with <code>GhostAPI</code> then referring to the public methods in <code>GhostNET</code> is a good starting point.</p>
<p>For full documentation on parameters refer to <a href="https://www.ghostscript.com/doc/current/Use.htm#Parameters">Ghostscript parameters</a>.</p>
<h2 id="the-event-class">The Event class</h2>
<p><code>GhostNET</code> contains a public class <code>gsEventArgs</code> which is an extension of the C# class <a href="https://docs.microsoft.com/en-us/dotnet/api/system.eventargs?view=net-5.0">EventArgs</a>. This class is used to set and get events as they occur. <code>GhostNET</code> will create these payloads and deliver them back to the application layer's <code>ProgressCallBack</code> method <a href="#delegates">asynchronously</a>.</p>
<div class="tag classDefinition csharp"></div>

<pre><code class="language-c">public class gsEventArgs : EventArgs
{
    private bool m_completed;
    private int m_progress;
    private gsParamState_t m_param;
    public bool Completed
    {
        get { return m_completed; }
    }
    public gsParamState_t Params
    {
        get { return m_param; }
    }
    public int Progress
    {
        get { return m_progress; }
    }
    public gsEventArgs(bool completed, int progress, gsParamState_t param)
    {
        m_completed = completed;
        m_progress = progress;
        m_param = param;
    }
}</code></pre>
<h2 id="gsnet">GSNET</h2>
<p>This class should be instantiated as a member variable in your application with callback definitions setup as required.</p>
<p>Handlers for asynchronous operations can injected by providing your own bespoke callback methods to your instance's <code>ProgressCallBack</code> function.</p>
<div class="tag sampleCode csharp"></div>

<pre><code class="language-c">/* Set up ghostscript with callbacks for system updates */
m_ghostscript = new GSNET();
m_ghostscript.ProgressCallBack += new GSNET.Progress(gsProgress);
m_ghostscript.StdIOCallBack += new GSNET.StdIO(gsIO);
m_ghostscript.DLLProblemCallBack += new GSNET.DLLProblem(gsDLL);
m_ghostscript.PageRenderedCallBack += new GSNET.PageRendered(gsPageRendered);
m_ghostscript.DisplayDeviceOpen();

/* example callback stubs for asynchronous operations */
private void gsProgress(gsEventArgs asyncInformation)
{
    Console.WriteLine($"gsProgress().progress:{asyncInformation.Progress}");

    if (asyncInformation.Completed) // task complete
    {
        // what was the task?
        switch (asyncInformation.Params.task)
        {
            case GS_Task_t.CREATE_XPS:
                Console.WriteLine($"CREATE_XPS.outputfile:");
                Console.WriteLine($"{asyncInformation.Params.result.outputfile}");
                break;

            case GS_Task_t.PS_DISTILL:
                Console.WriteLine($"PS_DISTILL.outputfile:");
                Console.WriteLine($"{asyncInformation.Params.result.outputfile}");
                break;

            case GS_Task_t.SAVE_RESULT:

                break;

            case GS_Task_t.DISPLAY_DEV_THUMBS:

                break;

            case GS_Task_t.DISPLAY_DEV_RUN_FILE:

                break;

            case GS_Task_t.DISPLAY_DEV_PDF:

                break;

            case GS_Task_t.DISPLAY_DEV_NON_PDF:

                break;

            default:

                break;
        }

        // task failed
        if (asyncInformation.Params.result == GS_Result_t.gsFAILED)
        {
            switch (asyncInformation.Params.task)
            {
                case GS_Task_t.CREATE_XPS:

                    break;

                case GS_Task_t.PS_DISTILL:

                    break;

                case GS_Task_t.SAVE_RESULT:

                    break;

                default:

                    break;
            }
            return;
        }

        // task cancelled
        if (asyncInformation.Params.result == GS_Result_t.gsCANCELLED)
        {

        }
    }
    else // task is still running
    {
        switch (asyncInformation.Params.task)
        {
            case GS_Task_t.CREATE_XPS:

                break;

            case GS_Task_t.PS_DISTILL:

                break;

            case GS_Task_t.SAVE_RESULT:

                break;
        }
    }
}

private void gsIO(String message, int len)
{
    Console.WriteLine($"gsIO().message:{message}, length:{len}");
}

private void gsDLL(String message)
{
    Console.WriteLine($"gsDLL().message:{message}");
}

private void gsPageRendered(int width,
                            int height,
                            int raster,
                            IntPtr data,
                            gsParamState_t state)
{

};</code></pre>
<blockquote>
<p><strong>NOTE</strong><br>Once a Ghostscript operation is in progress any defined callback functions will be called as the operation runs up unto completion. These callback methods are essential for your application to interpret activity events and react accordingly.</p>
</blockquote>
<p>An explanation of callbacks and the available public methods within <code>GSNET</code> are explained below.</p>
<h3 id="delegates">Delegates</h3>
<p>To handle asynchronous events <code>GhostNET</code> has four delegates which define callback methods that an application can assign to.</p>
<table>
<thead>
<tr>
<th>Callback</th>
<th>Description</th>
</tr>
</thead>
<tbody><tr>
<td><code>DLLProblemCallBack</code></td>
<td>Occurs if there is some issue with the Ghostscript DLL</td>
</tr>
<tr>
<td><code>StdIOCallBack</code></td>
<td>Occurs if Ghostscript outputs something to <code>stderr</code> or <code>stdout</code></td>
</tr>
<tr>
<td><code>ProgressCallBack</code></td>
<td>Occurs as Ghostscript makes its way through a file</td>
</tr>
<tr>
<td><code>PageRenderedCallBack</code></td>
<td>Occurs when a page has been rendered and the data from the display device is ready</td>
</tr>
</tbody></table>
<h4 id="dllproblemcallback">DLLProblemCallBack</h4>
<div class="tag callbackDefinition csharp"></div>

<pre><code class="language-c">internal delegate void DLLProblem(String mess);
internal event DLLProblem DLLProblemCallBack;</code></pre>
<h4 id="stdiocallback">StdIOCallBack</h4>
<div class="tag callbackDefinition csharp"></div>

<pre><code class="language-c">internal delegate void StdIO(String mess,
                             int len);
internal event StdIO StdIOCallBack;</code></pre>
<h4 id="progresscallback">ProgressCallBack</h4>
<div class="tag callbackDefinition csharp"></div>

<pre><code class="language-c">internal delegate void Progress(gsEventArgs info);
internal event Progress ProgressCallBack;</code></pre>
<h4 id="pagerenderedcallback">PageRenderedCallBack</h4>
<div class="tag callbackDefinition csharp"></div>

<pre><code class="language-c">internal delegate void PageRendered(int width,
                                    int height,
                                    int raster,
                                 IntPtr data,
                         gsParamState_t state);
internal event PageRendered PageRenderedCallBack;</code></pre>
<h3 id="getversion">GetVersion</h3>
<p>Use this method to get Ghostscript version info as a handy <code>String</code>.</p>
<div class="tag methodDefinition csharp"></div>

<pre><code class="language-c">public String GetVersion()</code></pre>
<div class="tag sampleCode csharp"></div>

<pre><code class="language-c">String gs_vers = m_ghostscript.GetVersion();</code></pre>
<blockquote>
<p><strong>NOTE</strong><br>An exception will be thrown if there is any issue with the Ghostscript DLL.</p>
</blockquote>
<h3 id="displaydeviceopen">DisplayDeviceOpen</h3>
<p>Sets up the <a href="https://ghostscript.com/doc/current/Devices.htm#Display_devices">display device</a> ahead of time.</p>
<div class="tag methodDefinition csharp"></div>

<pre><code class="language-c">public gsParamState_t DisplayDeviceOpen()</code></pre>
<div class="tag sampleCode csharp"></div>

<pre><code class="language-c">m_ghostscript.DisplayDeviceOpen();</code></pre>
<blockquote>
<p><strong>NOTE</strong><br>Calling this method <a href="c-sharp-ghost-api.html#gsapi_new_instance">instantiates ghostscript</a> and configures the encoding and the callbacks for the display device.</p>
</blockquote>
<h3 id="displaydeviceclose">DisplayDeviceClose</h3>
<p>Closes the <a href="https://ghostscript.com/doc/current/Devices.htm#Display_devices">display device</a> and deletes the instance.</p>
<div class="tag methodDefinition csharp"></div>

<pre><code class="language-c">public gsParamState_t DisplayDeviceClose()</code></pre>
<div class="tag sampleCode csharp"></div>

<pre><code class="language-c">m_ghostscript.DisplayDeviceClose();</code></pre>
<blockquote>
<p><strong>NOTE</strong><br>Calling this method <a href="c-sharp-ghost-api.html#gsapi_delete_instance">deletes ghostscript</a>.</p>
</blockquote>
<h3 id="getpagecount">GetPageCount</h3>
<p>Use this method to get the number of pages in a supplied document.</p>
<div class="tag methodDefinition csharp"></div>

<pre><code class="language-c">public int GetPageCount(String fileName)</code></pre>
<div class="tag sampleCode csharp"></div>

<pre><code class="language-c">int page_number = m_ghostscript.GetPageCount("my_document.pdf");</code></pre>
<blockquote>
<p><strong>NOTE</strong><br>If Ghostscript is unable to determine the page count then this method will return <code>-1</code>.</p>
</blockquote>
<h3 id="createxps">CreateXPS</h3>
<p>Launches a thread to create an XPS document for Windows printing. This method is <a href="#delegates">asynchronous</a> and logic should be hooked into your application upon <a href="#gsnet">GSNET instantiation</a> to interpret progress.</p>
<div class="tag methodDefinition csharp async"></div>

<pre><code class="language-c">public gsStatus CreateXPS(String fileName,
                             int resolution,
                             int num_pages,
                          double width,
                          double height,
                            bool fit_page,
                             int firstpage,
                             int lastpage)</code></pre>
<div class="tag sampleCode csharp"></div>

<pre><code class="language-c">m_ghostscript.CreateXPS("my_document.pdf",
                        300,
                        10,
                        1000,
                        1000,
                        true,
                        0,
                        9);</code></pre>
<span class="smallText alignRight">

<p><em><a href="#delegates">asynchronous</a></em></p>
</span>

<h3 id="distillps">DistillPS</h3>
<p>Launches a thread rendering all the pages of a supplied PostScript file to a PDF.</p>
<div class="tag methodDefinition csharp async"></div>

<pre><code class="language-c">public gsStatus DistillPS(String fileName, int resolution)</code></pre>
<div class="tag sampleCode csharp"></div>

<pre><code class="language-c">m_ghostscript.DistillPS("my_postscript_document.ps", 300);</code></pre>
<span class="smallText alignRight">

<p><em><a href="#delegates">asynchronous</a></em></p>
</span>


<h3 id="displaydevicerunfile">DisplayDeviceRunFile</h3>
<p>Launches a thread to run a file with the <a href="https://ghostscript.com/doc/current/Devices.htm#Display_devices">display device</a>.</p>
<div class="tag methodDefinition csharp async"></div>

<pre><code class="language-c">public gsStatus DisplayDeviceRunFile(String fileName,
                                     double zoom,
                                       bool aa, // anti-aliasing value
                                        int firstpage,
                                        int lastpage)</code></pre>
<div class="tag sampleCode csharp"></div>

<pre><code class="language-c">m_ghostscript.DisplayDeviceRunFile("my_document.pdf",
                                   1.0,
                                   true,
                                   0,
                                   9);</code></pre>
<span class="smallText alignRight">

<p><em><a href="#delegates">asynchronous</a></em></p>
</span>

<h3 id="displaydevicerenderthumbs">DisplayDeviceRenderThumbs</h3>
<p>Launches a thread rendering all the pages with the <a href="https://ghostscript.com/doc/current/Devices.htm#Display_devices">display device</a> to collect thumbnail images.</p>
<p>Recommended zoom level for thumbnails is between 0.05 and 0.2, additionally anti-aliasing is probably not required.</p>
<div class="tag methodDefinition csharp async"></div>

<pre><code class="language-c">public gsStatus DisplayDeviceRenderThumbs(String fileName,
                                          double zoom,
                                            bool aa)</code></pre>
<div class="tag sampleCode csharp"></div>

<pre><code class="language-c">m_ghostscript.DisplayDeviceRenderThumbs("my_document.pdf",
                                        0.1,
                                        false);</code></pre>
<span class="smallText alignRight">

<p><em><a href="#delegates">asynchronous</a></em></p>
</span>

<h3 id="displaydevicerenderpages">DisplayDeviceRenderPages</h3>
<p>Launches a thread rendering a set of pages with the <a href="https://ghostscript.com/doc/current/Devices.htm#Display_devices">display device</a>. For use with languages that can be indexed via pages which include PDF and XPS. <sup><a href="#1-ghostscript-page-description-languages">1</a></sup></p>
<div class="tag methodDefinition csharp async"></div>

<pre><code class="language-c">public gsStatus DisplayDeviceRenderPages(String fileName,
                                            int first_page,
                                            int last_page,
                                         double zoom)</code></pre>
<div class="tag sampleCode csharp"></div>

<pre><code class="language-c">m_ghostscript.DisplayDeviceRenderPages("my_document.pdf",
                                       0,
                                       9,
                                       1.0);</code></pre>
<span class="smallText alignRight">

<p><em><a href="#delegates">asynchronous</a></em></p>
</span>




<h3 id="getstatus">GetStatus</h3>
<p>Returns the current <a href="#status">status</a> of <code>Ghostscript</code>.</p>
<div class="tag methodDefinition csharp"></div>

<pre><code class="language-c">public gsStatus GetStatus()</code></pre>
<div class="tag sampleCode csharp"></div>

<pre><code class="language-c">gsStatus status = m_ghostscript.GetStatus();</code></pre>
<h3 id="cancel">Cancel</h3>
<p>Cancels <a href="#delegates">asynchronous</a> operations.</p>
<div class="tag methodDefinition csharp"></div>

<pre><code class="language-c">public void Cancel()</code></pre>
<div class="tag sampleCode csharp"></div>

<pre><code class="language-c">m_ghostscript.Cancel();</code></pre>
<h3 id="ghostscriptexception">GhostscriptException</h3>
<p>An application developer can log any exceptions in this public class as required by editing the constructor.</p>
<div class="tag classDefinition csharp"></div>

<pre><code class="language-c">public class GhostscriptException : Exception
{
    public GhostscriptException(string message) : base(message)
    {
        // Report exceptions as required
    }
}</code></pre>
<h2 id="notes">Notes</h2>
<h4 id="1-ghostscript-page-description-languages">1: Ghostscript &amp; Page Description Languages</h4>
<p>Ghostscript handles the following <a href="https://en.wikipedia.org/wiki/Page_description_language">PDLs</a>: <code>PCL</code> <code>PDF</code> <code>PS</code> <code>XPS</code>.</p>
<p><code>PCL</code> and <code>PS</code> do not allow random access, meaning that, to print page 2 in a 100 page document, Ghostscript has to read the entire document stream of 100 pages.</p>
<p>On the other hand, <code>PDF</code> and <code>XPS</code> allow for going directly to page 2 and then only dealing with that content. The tasks <code>DISPLAY_DEV_NON_PDF</code> and <code>DISPLAY_DEV_PDF</code> keep track of what sort of input Ghostscript is dealing with and enables the application to direct progress or completion callbacks accordingly.</p>
</article>

            </div><!-- /middle -->

            <div class="right">

                <div class="link"><a href="#about">About</a></div>
                <div class="link"><a href="#enums">Enums</a></div>
                    <div class="sub-link"><a href="#tasks">Tasks</a></div>
                    <div class="sub-link"><a href="#results">Results</a></div>
                    <div class="sub-link"><a href="#status">Status</a></div>
                <div class="link"><a href="#the-parameter-struct">The Parameter Struct</a></div>
                    <div class="sub-link"><a href="#parameters-explained">Parameters explained</a></div>
                <div class="link"><a href="#the-event-class">The Event class</a></div>
                <div class="link"><a href="#gsnet">GSNET</a></div>
                    <div class="sub-link"><a href="#delegates">Delegates</a></div>
                    <div class="sub-link"><a href="#getversion">GetVersion</a></div>
                    <div class="sub-link"><a href="#displaydeviceopen">DisplayDeviceOpen</a></div>
                    <div class="sub-link"><a href="#displaydeviceclose">DisplayDeviceClose</a></div>
                    <div class="sub-link"><a href="#getpagecount">GetPageCount</a></div>
                    <div class="sub-link"><a href="#createxps">CreateXPS</a></div>
                    <div class="sub-link"><a href="#distillps">DistillPS</a></div>
                    <div class="sub-link"><a href="#displaydevicerunfile">DisplayDeviceRunFile</a></div>
                    <div class="sub-link"><a href="#displaydevicerenderthumbs">DisplayDeviceRenderThumbs</a></div>
                    <div class="sub-link"><a href="#displaydevicerenderpages">DisplayDeviceRenderPages</a></div>
                    <div class="sub-link"><a href="#getstatus">GetStatus</a></div>
                    <div class="sub-link"><a href="#cancel">Cancel</a></div>
                    <div class="sub-link"><a href="#ghostscriptexception">GhostscriptException</a></div>
                <div class="link"><a href="#notes">Notes</a></div>

            </div>

        </div>

        <footer></footer>

    </body>

</html>