Coverage for gws-app/gws/base/printer/__init__.py: 100%

2 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-05 13:35 +0200

1"""Printing. 

2 

3Prints maps and templates to PDF or PNG. Printing runs as a background job: 

4the client sends a print request, polls the job status and downloads the 

5result when the job is complete. 

6 

7Submodules: 

8 

9- ``core``: the default printer (``gws.Printer``), a print template offered to 

10 users, with a title, quality levels (DPI) and optional models whose fields 

11 appear as input fields in the print dialog. Printers are configured in the 

12 application and in projects. If no quality levels are configured, a single 

13 ``default`` level is used. The title defaults to the template title. The 

14 client props include the model the user can write, if any. 

15- ``manager``: the printer manager (``gws.PrinterManager``), available as 

16 ``root.app.printerMgr``. Starts print jobs and runs prints synchronously. 

17 The request is passed to the job as a pickle file. 

18- ``worker``: the job worker that executes a print request. It resolves the 

19 project and the printer, determines the output format and DPI (limited by 

20 the printer quality levels), converts the map planes sent by the client 

21 (raster and vector layers, bitmaps, data URLs, features, SVG soup) into render 

22 planes, renders the template and stores the result in the job. 

23- ``action``: the ``printer`` action with the API commands ``printerStart``, 

24 ``printerStatus``, ``printerCancel`` and ``printerOutput``, and the 

25 ``printerPrint`` CLI command. 

26 

27A print request (``gws.PrintRequest``) is either of type ``template``, which uses 

28a configured printer, or ``map``, which renders the map with a temporary map 

29template of the requested output size. 

30 

31Example:: 

32 

33 actions+ { type "printer" } 

34 

35 printers+ { 

36 title "A4 portrait" 

37 template { type "html" path "a4.cx.html" mapSize [ "150mm" "100mm" ] } 

38 qualityLevels [ 

39 { dpi 90 name "screen" } 

40 { dpi 300 name "print" } 

41 ] 

42 } 

43""" 

44 

45from .core import Config, Object, Props 

46from . import manager