-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapi.html
536 lines (467 loc) · 16.6 KB
/
api.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MapFish Print 3 Documentation - Web Protocol</title>
<link rel="stylesheet" href="css/sphinx_rtd_theme.css" type="text/css" />
<link rel="stylesheet" href="css/readthedocs-doc-embed.css" type="text/css" />
<link rel="stylesheet" href="css/custom.css" type="text/css" />
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="index.html" class="icon icon-home"> MapFish Print 3</a>
</div>
<div
class="wy-menu wy-menu-vertical"
data-spy="affix"
role="navigation"
aria-label="main navigation"
>
<ul class="current">
<li class="toctree-l1 ">
<a class="reference internal " href="index.html">Introduction</a>
</li>
<li class="toctree-l1 ">
<a class="reference internal " href="jasperreports.html"
>JasperReports</a
>
</li>
<li class="toctree-l1 current">
<a class="reference internal current" href="api.html">Web API</a>
</li>
<li class="toctree-l1 ">
<a class="reference internal " href="attributes.html">Attributes</a>
</li>
<li class="toctree-l1 ">
<a class="reference internal " href="configuration.html"
>Configuration</a
>
</li>
<li class="toctree-l1 ">
<a class="reference internal " href="layers.html">Map Layers</a>
</li>
<li class="toctree-l1 ">
<a class="reference internal " href="processors.html">Processors</a>
</li>
<li class="toctree-l1 ">
<a class="reference internal " href="fileloaders.html">File-Loaders</a>
</li>
<li class="toctree-l1 ">
<a class="reference internal " href="outputformats.html"
>Output Formats</a
>
</li>
<li class="toctree-l1 ">
<a class="reference internal " href="styles.html">Styles</a>
</li>
<li class="toctree-l1 ">
<a class="reference internal " href="tableimages.html"
>Images in tables</a
>
</li>
<li class="toctree-l1 ">
<a class="reference internal " href="download.html">Download</a>
</li>
<li class="toctree-l1 ">
<a class="reference internal " href="docker.html">Docker</a>
</li>
<li class="toctree-l1 ">
<a class="reference internal " href="scaling.html">Horizontal scaling</a>
</li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">MapFish Print 3</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> »</li>
<li>Web Protocol</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/mapfish/mapfish-print" class="fa fa-github">
mapfish/mapfish-print</a
>
</li>
</ul>
<hr />
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Web Protocol</h1>
<div class="section"><div class="api">
<p>The API is the web/HTTP protocol allowing a client to interact with the print service via the web.</p>
<ul>
<li><a href="#apps">List available print configurations</a></li>
<li><a href="#capabilities">Get the capabilities for a print configuration</a></li>
<li><a href="#create">Create a print job</a></li>
<li><a href="#status">Get the status for a print job</a></li>
<li><a href="#download">Download the report for a print job</a></li>
<li><a href="#cancel">Cancel a print job</a></li>
<li><a href="#buildreport">Create a print job and download its report</a></li>
<li>
<a href="#listFonts">List available fonts</a>
<!-- <li>Create and get report -->
</li>
</ul>
<h3 id="apps">
List available print configurations
<a class="headerlink" href="#apps" title="Permalink to this headline">¶</a>
</h3>
<p>Lists the identifiers of all print configurations that are available in the MapFish Print instance.</p>
<h4>URI</h4>
<p>
<code>GET /apps.json</code>
</p>
<h4>Response Sample</h4>
<div class="highlight">
<pre>
[
"simple",
"default"
]
</pre>
</div>
<h3 id="capabilities">
Get the capabilities for a print configuration
<a class="headerlink" href="#capabilities" title="Permalink to this headline">¶</a>
</h3>
<p>Return the capabilities for a specific print configuration.</p>
<h4>URI</h4>
<p>
<code>GET /:appId/capabilities.json</code>
</p>
<p><code>:appId</code> should be the identifier of one of the available print configurations.</p>
<h4>Request Sample</h4>
<p>Request URI: <code>GET /simple/capabilities.json</code></p>
<h4>Response Sample</h4>
<div class="highlight">
<pre>
{
"app": "simple",
"layouts": [
{
"name": "A4 Portrait",
"attributes": [
...
]
}
],
"formats": [
"bmp",
"gif",
"pdf",
"png",
"tif",
"tiff"
],
"smtp": {
"enabled": false
}
}
</pre>
</div>
<p>
The smtp section shows <code>"enabled": true</code> if the reports can be sent by email. To enable this
feature, please refer to the <a href="configuration.html#!smtpConfig">!smtpConfig</a> section.
</p>
<h3 id="create">
Create a print job <a class="headerlink" href="#create" title="Permalink to this headline">¶</a>
</h3>
<p>Send a print request to create a print job.</p>
<h4>URI</h4>
<p>
<code>POST /:appId/report.:format</code>
</p>
<p><code>:appId</code> should be the identifier of one of the available print configurations.</p>
<p>
<code>:format</code> should be one of the formats supported by the specified print configuration (e.g.
<code>pdf</code> or <code>png</code>).
</p>
<h4>Request</h4>
<p>
The POST body must be either a print request encoded as JSON, or a form-encoded request where the field
<code>spec</code> contains the print request encoded as JSON.
</p>
<p>The print request must contain the following properties:</p>
<ul>
<li><code>layout</code>: One of the available layouts of the specified print configuration.</li>
<li><code>attributes</code>: A list of attributes that are required by the specified layout.</li>
</ul>
<p>
If the report must be sent by email and the feature is enabled in the app, an <code>smtp</code> property
looking like that (<code>subject</code> and <code>body</code> are optional) must be added to the request:
</p>
<div class="highlight">
<pre>
{
"smtp": {
"to": "[email protected]",
"subject": "The email subject",
"body": "Some <b>html</b> body"
}
}
</pre>
</div>
<h4>Response</h4>
<p>The JSON response contains the following properties:</p>
<ul>
<li>
<code>ref</code>: A reference id that can be used to request the status for the print job or to download
the finished report.
</li>
<li><code>statusURL</code>: The URL to request the status.</li>
<li>
<code>downloadURL</code>: The URL under which the report will be available once the print job has
finished.
</li>
</ul>
<h4>Request Sample</h4>
<p>Request URI: <code>POST /simple/report.pdf</code></p>
<p>Request body</p>
<div class="highlight">
<pre>
{
"layout": "A4 Portrait",
"attributes": {
"map": {
"center": [
957352.8034848921,
5936844.140278816
],
"dpi": 72,
"layers": [
...
],
"projection": "EPSG:3857",
"rotation": 0,
"scale": 25000
},
"scalebar": {
"projection": "EPSG:21781"
},
"title": "Sample Print"
}
}
</pre>
</div>
<h4>Response Sample</h4>
<div class="highlight">
<pre>
{
"ref": "15179fee-618d-4356-8114-cfd8f146e273@3067ade6-0768-4fc6-b41d-40422d0cdb8b",
"statusURL": "/print/status/15179fee-618d-4356-8114-cfd8f146e273.json",
"downloadURL": "/print/report/15179fee-618d-4356-8114-cfd8f146e273"
}
</pre>
</div>
<h3 id="status">
Get the status for a print job
<a class="headerlink" href="#status" title="Permalink to this headline">¶</a>
</h3>
<p>Returns the status for a print job.</p>
<p>You should not call this API if you requested the report to be sent by email.</p>
<h4>URI</h4>
<p>
<code>GET /status/:referenceId.json</code>
</p>
<p>
<code>:referenceId</code> should be the reference id of a print job, which is returned when creating a
job.
</p>
<h4>Response</h4>
<p>The JSON response contains the following properties:</p>
<ul>
<li>
<code>done</code>: <code>true</code> if the print job has finished (either successful or not). Otherwise
<code>false</code>.
</li>
<li>
<code>status</code>: One of the following values:
<ul>
<li><code>waiting</code>: The job hasn't yet started processing and is waiting in a queue.</li>
<li><code>running</code>: The job is currently being processed.</li>
<li><code>finished</code>: The job has finished processing.</li>
<li><code>canceled</code>: The job was canceled.</li>
<li><code>error</code>: There was an error executing the job.</li>
</ul>
</li>
<li>
<code>elapsedTime</code>: The elapsed time in ms from the point the job started. If the job is done,
this is the duration it took to process the job.
</li>
<li>
<code>waitingTime</code>: A rough estimate for the time in ms the job still has to wait in the queue
until it starts processing. Only set when the status is <code>waiting</code>.
</li>
<li><code>error</code>: An error message, if an error occurred.</li>
<li>
<code>downloadURL</code>: The URL under which the report will be available once the print job has
finished.
</li>
</ul>
<h4>Request Sample</h4>
<p>Request URI: <code>GET /status/15179fee-618d-4356-8114-cfd8f146e273.json</code></p>
<p>You should not call this API if you requested the report to be sent by email.</p>
<h4>Response Sample</h4>
<div class="highlight">
<pre>
{
"done": false,
"status": "running",
"elapsedTime": 507,
"waitingTime": 0,
"downloadURL": "/print/report/15179fee-618d-4356-8114-cfd8f146e273"
}
</pre>
</div>
<h3 id="download">
Download the report for a print job
<a class="headerlink" href="#download" title="Permalink to this headline">¶</a>
</h3>
<p>Downloads a finished print job.</p>
<h4>URI</h4>
<p>
<code>GET /report/:referenceId</code>
</p>
<p>
<code>:referenceId</code> should be the reference id of a print job, which is returned when creating a
job.
</p>
<h4>Response</h4>
<p>Returns the report in the format that was requested when created the print job.</p>
<h4>Request Sample</h4>
<p>Request URI: <code>GET /report/15179fee-618d-4356-8114-cfd8f146e273</code></p>
<h3 id="cancel">
Cancel a print job <a class="headerlink" href="#cancel" title="Permalink to this headline">¶</a>
</h3>
<p>Request the cancellation of a print job.</p>
<h4>URI</h4>
<p>
<code>DELETE /cancel/:referenceId</code>
</p>
<p>
<code>:referenceId</code> should be the reference id of a print job, which is returned when creating a
job.
</p>
<h4>Response</h4>
<p>Status: <code>200 OK</code></p>
<h4>Request Sample</h4>
<p>Request URI: <code>DELETE /cancel/15179fee-618d-4356-8114-cfd8f146e273</code></p>
<h3 id="buildreport">
Create a print job and download its report
<a class="headerlink" href="#buildreport" title="Permalink to this headline">¶</a>
</h3>
<p>
Triggers the creation of a print job, then download the report. Although it seems synchronous from the
client perspective, the print job might be run by a different server in cluster mode. Despite this, it is
not the recommended manner to use the print server (as too many requests in parallel will grab all the
server resources).
</p>
<h4>URI</h4>
<p>
<code>POST /:appId/buildreport.:format</code>
</p>
<p><code>:appId</code> should be the identifier of one of the available print configurations.</p>
<p>
<code>:format</code> should be one of the formats supported by the specified print configuration (e.g.
<code>pdf</code> or <code>png</code>).
</p>
<h4>Response</h4>
<p>Status: <code>200 OK</code></p>
<h4>Request Sample</h4>
<p>Request URI: <code>POST /simple/buildreport.pdf</code></p>
<p>See <a href="#create">Create a print job</a> request sample for the request body.</p>
<h3 id="listFonts">
List Available Fonts <a class="headerlink" href="#listFonts" title="Permalink to this headline">¶</a>
</h3>
<p>
List fonts installed in Java Runtime on server. This lists the fonts that can be put in the Jasper Report
Templates
</p>
<h4>URI</h4>
<p>
<code>GET /fonts</code>
</p>
<h4>Response</h4>
<p>
A JSON array containing all the available fonts face names on the server that can be used in Jasper Report
Templates
</p>
<h4>Request Sample</h4>
<p>Request URI: <code>GET /fonts</code></p>
</div>
</div>
</div>
</div>
<footer>
<hr />
<div role="contentinfo">
<p>
<a href="https://www.camptocamp.com/geospatial_solutions" target="_blank" rel="noopener"
>Camptocamp</a
>
<br />
<span class="commit">
Revision
<code
><a
href="https://github.com/mapfish/mapfish-print/commit/a2c9774eb1a2c92fcd85c2b91670e45fce89bc46"
target="_blank"
>a2c9774e</a
></code
>.
</span>
</p>
</div>
Theme based on a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">template</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script
type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"
integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script
type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/jquery-migrate/3.5.2/jquery-migrate.min.js"
integrity="sha512-BzvgYEoHXuphX+g7B/laemJGYFdrq4fTKEo+B3PurSxstMZtwu28FHkPKXu6dSBCzbUWqz/rMv755nUwhjQypw=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script
type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.13.7/underscore-min.js"
integrity="sha512-dvWGkLATSdw5qWb2qozZBRKJ80Omy2YN/aF3wTUVC5+D1eqbA+TjWpPpoj8vorK5xGLMa2ZqIeWCpDZP/+pQGQ=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script
type="text/javascript"
src="js/theme.js"
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>