changeset 2207:da902f0dac88 pdf-export

pdf-gen: add fixed coordinates and values * enter coordinates and values for scalebar and pageinfo to template 1,2 examples
author Fadi Abbud <fadi.abbud@intevation.de>
date Wed, 06 Feb 2019 09:56:36 +0100
parents 2e64d1be3dbc
children 763c520a7717
files client/src/components/Pdftool.vue
diffstat 1 files changed, 29 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/Pdftool.vue	Tue Feb 05 16:50:59 2019 +0100
+++ b/client/src/components/Pdftool.vue	Wed Feb 06 09:56:36 2019 +0100
@@ -153,7 +153,8 @@
               x_coordinate: 0,
               y_coordinate: 0,
               elementWidth: 118,
-              elementHeight: 8
+              elementHeight: 8,
+              textSize: 9
             },
             {
               type: "image",
@@ -166,7 +167,7 @@
             },
             {
               type: "scalebar",
-              //x_coordinate:,
+              x_coordinate: 226.5,
               y_coordinate: 204
               //elementsize: 50
             },
@@ -194,6 +195,14 @@
           },
           elements: [
             {
+              type: "docinfo",
+              x_coordinate: 0,
+              y_coordinate: 0,
+              elementWidth: 118,
+              elementHeight: 8,
+              textSize: 9
+            },
+            {
               type: "image",
               imageType: "PNG",
               imageUrl: "",
@@ -204,8 +213,8 @@
             },
             {
               type: "scalebar",
-              //x_coordinate: 250,
-              y_coordinate: 420 - 6
+              x_coordinate: 247.3,
+              y_coordinate: 414
               //elementsize: 50
             },
             {
@@ -217,13 +226,6 @@
               color: "black"
             },
             {
-              type: "docinfo",
-              x_coordinate: 0,
-              y_coordinate: 0,
-              elementWidth: 118,
-              elementHeight: 8
-            },
-            {
               type: "aboutbox"
               //x_coordinate: 0,
               //y_coordinate: 210 - 20
@@ -353,7 +355,6 @@
           template.elements.forEach(t => {
             switch (t.type) {
               case "image": {
-                console.log("autobox from template");
                 if (t.imageUrl.length > 0) {
                   pdf.addImage(
                     t.imageUrl,
@@ -372,6 +373,7 @@
                   width,
                   height,
                   scaleNominator,
+                  t.x_coordinate,
                   t.y_coordinate
                 );
                 break;
@@ -389,7 +391,14 @@
                 break;
               }
               case "docinfo": {
-                self.addPageInfo(pdf);
+                self.addPageInfo(
+                  pdf,
+                  t.x_coordinate,
+                  t.y_coordinate,
+                  t.elementWidth,
+                  t.elementHeight,
+                  t.textSize
+                );
                 break;
               }
               case "aboutbox": {
@@ -410,8 +419,8 @@
 
           pdf.save("map.pdf");
         } else {
-          self.addScaleBar(pdf, width, height, scaleNominator, 204);
-          self.addPageInfo(pdf);
+          self.addScaleBar(pdf, width, height, scaleNominator, 226.5, 204);
+          self.addPageInfo(pdf, 0, 0, 110, 8, 9);
           self.addAboutBox(pdf, width, height);
           pdf.save("map.pdf");
         }
@@ -463,7 +472,7 @@
       doc.setFillColor(255, 255, 255);
       doc.roundedRect(x, y, w, h, 3, 3, "FD");
     },
-    addScaleBar(doc, docWidth, docHeight, scaleNominator, y) {
+    addScaleBar(doc, docWidth, docHeight, scaleNominator, x, y) {
       // scaleNominator is the x in 1:x of the map scale
 
       // hardcode maximal width for now and place in lower right corner
@@ -522,7 +531,7 @@
 
       let size = (length * unitConversionFactor) / scaleNominator / 4;
 
-      let x = docWidth - (size * 4 + 8);
+      //let x = docWidth - (size * 4 + 8);
       //let y = docHeight - 6;
 
       this.addRoundedBox(doc, x - 4, y - 4, size * 4 + 12, 10);
@@ -581,8 +590,8 @@
       doc.setFontSize(size);
       doc.text(postitionX, positionY, textLines);
     },
-    addPageInfo(doc) {
-      this.addRoundedBox(doc, 0, 0, 110, 8);
+    addPageInfo(doc, x, y, width, height, textSize) {
+      this.addRoundedBox(doc, x, y, width, height);
       let str =
         this.$gettext("Date of publication:") +
         " " +
@@ -591,7 +600,7 @@
         this.$gettext("– generated by:") +
         " " +
         this.user;
-      this.addText(doc, 5, 5, 9, "black", 100, str);
+      this.addText(doc, x + 5, y + 5, textSize, "black", 100, str);
     },
     addAboutBox(doc, docWidth, docHeight) {
       let top = docHeight - 20;