Print

From MapbenderWiki

Jump to: navigation, search

User:Astrid Emde (Module maintainer)

Contents

Description

english

With Mapbender Version 2.1.0 pdf-print is used as standard.

With version 2.42 you have the posibility to choose size A4-A0 and landscape or portrait.

Print temporary elements

$theMeasureConfigArray = array(
  "do_fill" => FALSE,          // true or false, shall the polygon be filled?
  "fill_color" => array(       // values for the fill color
    "r" => 128 / 255,
    "g" => 128 / 255,
    "b" => 128 / 255
  ),
  "do_stroke" => TRUE,         // true or false, shall a line be drawn
  "stroke_color" => array(     // values for the line color
    "r" => 254 / 255,
    "g" => 1 / 255,
    "b" => 1 / 255
  ),
  "line_style" => array(       // values for the line style
    "width" => 2,
    "cap" => 'butt',
    "join" => 'miter',
    "dash" => array(10, 6)
  )
);
  • Colors: r, g, b - x / 255 (choose x between 1-254, 0 or 1 won't work!
  • dashed line:
    • "do_stroke" => TRUE
    • "dash" to an appropriate array of values: array(10, 6) => (a line of length 10 and free space with a length of 6)

Source

The Sources you can find under:

  • mapbender/http/print/

Configure the printPDF.conf

  1. In the printPDF.conf you have to configure the path where temporary imagefiles shall be stored. Make sure that the WebServer has write permissions for this directory.

$filename = "/tmp/map_".substr(md5(uniqid(rand())),0,7).".png";

or

$filename = TMPDIR."/map_".substr(md5(uniqid(rand())),0,7).".png";

In case of using the variable TMPDIR. you may have to change the value of this variable in the file mapbender.conf.


  1. Configure the Printframe

You can fill the variables $text1 to $text10 with text, that should be displayed in the printframe. This textes will be displayed above the mapimage. With the variables $text11 to $text17 you can difine the text below the mapimage.

  1. Supported Formats
with the varables $a4 to $a0 you can define wich format shall be supported.
  1. available formats:
$a4 = true;
$a3 = false;
$a2 = false;
$a1 = false;
$a0 = false;
Notice

The pdf-Print generates a png-file. Therefore in the administration you have to choose mapformat png for every WMS of the GUI.


  1. Special Image

To include your own image, e.g. your logo, you can use the variable

$specialImage

Use

$special = true;

to enable this feature. Note: Make sure that the image not contain an alpha channel. In this case the image will be ingnored.


Troubleshooting printPDF

Known error: Fatal error: Cannot redeclare class exception

As of PHP 5.0 there is a predefined class 'exception'. So the PHP parser raises the above mentioned fatal error when calling the Mapbender-Class 'exception'. Future versions of MapBender are likely to have the class renamed to 'mb_exception', to avoid this behaviour.

How do I fix this?
  • Change the class definition in /classes/class_exception.php from class exception { ... to class mb_exception { ...
  • In /classes/class_stripRequest.php change all lines containing new exception to new mb_exception (Most likely there are three instances of this code)



deutsch

Ab der Mapbender Version 2.1.0 erfolgt der Standardausdruck von Mapbender als PDF.

Seit 2.4.2 stehen A4, A3, A2, A1 und A0 Druck zur Auswahl im Hoch- und Querformat.

Temporäre Elemete drucken

$theMeasureConfigArray = array(
  "do_fill" => FALSE,
    "fill_color" => array(
    "r" => 128 / 255,
    "g" => 128 / 255,
    "b" => 128 / 255
  ),
  "do_stroke" => TRUE,
    "stroke_color" => array(
    "r" => 254 / 255,
    "g" => 1 / 255,
    "b" => 1 / 255
  ),
  "line_style" => array(
      "width" => 2,
      "cap" => 'butt',
      "join" => 'miter',
      "dash" => array(10, 6)
      )
  );
  • Farben: r, g, b - x / 255 (x wählen zwischen 1-254)


Sources

Die Dateien, die für den Druck benötigt werden befinden sich unter:

  • mapbender/http/print/

Anpassung der Konfigurationsdatei printPDF.conf

  1. Bitte beachten Sie, dass in der Datei printPDF.conf der Pfad, unter den die temporären Imagedateien abgelegt werden sollen, an Ihre Umgebung angepaßt werden muss. Auf jeden Fall muss sichergestellt sein, dass der Webserver (z. B. Apache) schreibenden Zugriff auf das obige temp-Verzeichnis hat (am einfachsten ein temp-Verzeichnis im www-root (htdocs) des WebServers einrichten und die print.conf entsprechend anpassen).

$filename = "/tmp/map_".substr(md5(uniqid(rand())),0,7).".png";

oder

$filename = TMPDIR."/map_".substr(md5(uniqid(rand())),0,7).".png";

Der Pfad wird anhand der Variable TMPDIR. in der Datei mapbender.conf mitgegeben!

  1. Anpassung des Druckrahmens

Über die Belegung der Variablen $text1 bis $text10 können Sie die Texte, die im Druckrahmen angezeigt werden sollen, festlegen. Diese erscheinen im Druckrahmen oberhalb des Kartenauschnittes. Über die Anpassung der Variablen $text11 bis $text17 kann der Text, der unterhalb der Karte erscheinen soll, angepasst werden.

  1. Formatunterstützung

Über die Belegung der Variablen $a4 bis $a0 können Sie bestimmen welche Formate unterstützt werden sollen.

  1. available formats:
$a4 = true;
$a3 = false;
$a2 = false;
$a1 = false;
$a0 = false;
Hinweis

Beim PDF-Druck wird als Kartenbild ein png erzeugt. Daher muss in der Administration das Mapformat für alle beteiligten WMS auf png eingestellt sein.


  1. Special Image

Um ein eigenes Bild, z.B. ein Logo, einzubinden, benutzen Sie diese Variable

$specialImage

Benutzen Sie

$special = true;

um diese Funktion einzuschalten Hinweis: Stellen Sie sicher, daß sich in dem Bild kein Alpha-Kanal befindet. Das Bild würde sonst ignoriert werden.


Problemlösungen beim PDF Druck


Files

For this module the following files are required / Für dieses Modul werden die folgenden Dateien benötigt:

SQL

Use this sql statement to insert this module in the corresponding gui / Mit diesem SQL kann das Modul in die entsprechende GUI eingefügen werden:

css Style for printPDF.

In Mapbender 2.5 the printPDF needs an Element-Var that links the css.

Search for GUIs where is no link to css:

Give them a css by Admin-GUI or ...

Personal tools