PrintPDF with template - JSON configuration

From MapbenderWiki

Jump to: navigation, search

User:Michael Schulz (Module maintainer)

Description

english

Definition of the structure and used keywords of the JSON configuration files for the PrintPDF with template module. Unfortunately JSON does not offer the possibility to include comments in the JSON code itself, so we have to comment it this way. Please be sure to read the defintion of the JSON syntax.


Be aware that the definition is still in development. So keywords and structure will change.


The structure is explained using the numbers of the example JSON configuration you can find at the bottom.

The root object of the configuration contains at the moment 6 members:

(1) type 
shall be used to be able to differentiate between output formats, e.g. templatePDF, image or whatever. Currently only "templatePDF" supported.
(2) orientation 
the page orientation in the PDF. Possible values are "L" and "P" (check possible values defined in the fpdf library)
(3) units 
the units used in PDF positions and calculations, "mm", "cm", ... (check possible values defined in the fpdf library)
(4) format 
the dimension of the pdf page. Can be "a4" (and other DIN formats), "letter", ... (check possible values defined in the fpdf library)
(5) controls 
define the HTML-form elements, that are created on the fly when the configuration is read by the module in the application view.
(6) pages 
define the pages of the resulting PDF. Specify which PDF template is used and which elements are placed where on a certain page

deutsch

Definition der Struktur und verwendeten Schlüsselwörter der JSON Konfigurationsdateien für den Template Druck. Leider kennt JSON keine Kommentarfunktionalität, so dass der Quelltext nur hier kommentiert werden kann. Bitte auch die eigentliche Definition der JSON syntax lesen.

{
(1) "type" : "templatePDF",  
(2) "orientation" : "L",     
(3) "units" : "mm",          
(4) "format" : "a4",         
(5) "controls" : [           
    	{
    		"id" : "title",
    		"label" : "Titel",
    		"type" : "text",
    		"size" : 20,
    		"pageElementsLink" : {
    			"titel" : "value"
    		}
    	},
    	{
    		"id" : "dpi",
    		"label" : "DPI",
    		"type" : "select",
    		"size" : 20,
    		"pageElementsLink" : {
    			"karte" : "res_dpi"
    		},
    		"options" : [
    			{
    			"value" : "56",
    			"label" : "niedrig (56)"
    			},{
    			"value" : "72",
    			"label" : "normal (72)"
    			},{
    			"value" : "144",
    			"label" : "hoch (dpi)"
    			}
    		]
    	},
    	{
    		"id" : "comment",
    		"label" : "Kommentar",
    		"type" : "textarea",
    		"size" : 5,
    		"pageElementsLink" : {
    			"kommentar" : "value"
    		}
    	},
    	{
    		"id" : "rotation",
    		"type" : "hidden",
    		"pageElementsLink" : {
    			"nordpfeil" : "rotation"
    		}
    	}    	    		
    ],
(6) "pages" : [
    	{
    	 "tpl" : "mbtemplate1.pdf",
    	 "useTplPage" : 1,
    	 "elements" : {
	    	 "karte" : {
    			"type" : "map",
    			"res_dpi" : 72, 
    			"x_ul" : 10.1,
	    		"y_ul" : 15.2,
	    		"width" : 280,
    			"height" : 185,
    			"coords" : 1,
    			"coords_font_family" : "Arial",
    			"coords_font_size" : 6
	   	},
	   	"messung" : {
    			"type" : "measure",
    			"do_fill" : 0,
    			"fill_color" : {
    				"r" : 255,
    				"g" : 0,
    				"b" : 0
    			},
    			"do_stroke" : 0,
    			"stroke_color" : {
    				"r" : 0,
    				"g" : 0,
    				"b" : 0
    			},
    			"line_style" : {
    				"width" : 1.0
    			}    			
	   	},	   			
	   	"minikarte" : {
    			"type" : "overview",
    			"res_dpi" : 72, 
    			"x_ul" : 10.1,
	    		"y_ul" : 15.2,
	    		"width" : 50,
    			"height" : 50
	   	},
	   	"titel" : {
    			"type" : "text", 
    			"x_ul" : 10.1,
	    		"y_ul" : 10,
	    		"font_family" : "Arial",
	    		"font_size" : 14
	   	},
	   	"kommentar" : {
    			"type" : "para", 
    			"x_ul" : 10.1,
	    		"y_ul" : 129.2,
	    		"font_family" : "Arial",
	    		"font_size" : 11,
	    		"width" : 100,
	    		"height" : 10,
	    		"align" : "L",
	    		"border" : 1,
	    		"fill" : 1,
	    		"border_width" : 0.5
	   	},
	   	"scale" : {
    			"type" : "text", 
    			"x_ul" : 49.2,
	    		"y_ul" : 10.4,
	    		"font_family" : "Arial",
	    		"font_size" : 14,
			"value" : "scale"
	   	},
	   	"nordpfeil" : {
    			"type" : "image", 
    			"x_ul" : 280.1,
	    		"y_ul" : 35.2,
	    		"width" : 8,
	    		"height" : 18,
	    		"rotation" : 0,
			"filename" : "./img/northarrow.png"
	   	}		   						
	   }
       }
   ]
}
Views
Personal tools