diff client/src/lib/mixins.js @ 4135:a6eda41e7724 improvepdf

hydrological_conditions: use offsets relative to svgwidth and svgheight
author Thomas Junk <thomas.junk@intevation.de>
date Thu, 01 Aug 2019 10:38:15 +0200
parents 7959f62d3051
children 33deb8634783
line wrap: on
line diff
--- a/client/src/lib/mixins.js	Wed Jul 31 18:33:49 2019 +0200
+++ b/client/src/lib/mixins.js	Thu Aug 01 10:38:15 2019 +0200
@@ -149,13 +149,14 @@
     addDiagram(position, offset, width, height) {
       let x = offset.x,
         y = offset.y;
-      const svgWidth = this.millimeter2pixels(width, 80);
-      const svgHeight = this.millimeter2pixels(height, 80);
+      const DPI = 80;
+      const svgWidth = this.millimeter2pixels(width, DPI);
+      const svgHeight = this.millimeter2pixels(height, DPI);
       // draw the diagram in a separated html element to get the full size
       const offScreen = document.querySelector("#offScreen");
       offScreen.style.width = `${svgWidth}px`;
       offScreen.style.height = `${svgHeight}px`;
-      const layout = this.getPrintLayout(svgHeight);
+      const layout = this.getPrintLayout(svgHeight, svgWidth);
       this.renderTo({
         element: offScreen,
         dimensions: this.getDimensions({
@@ -171,10 +172,11 @@
       if (["bottomright", "bottomleft"].indexOf(position) !== -1) {
         y = this.pdf.height - offset.y - height;
       }
+      //debugSVG({ svg, svgWidth, svgHeight });
       svg2pdf(svg, this.pdf.doc, {
         xOffset: x,
         yOffset: y,
-        scale: this.pixel2millimeter(1, 80)
+        scale: this.pixel2millimeter(1, DPI)
       });
       offScreen.removeChild(svg);
     },