xwikisas / application-diagram

Create various types of diagrams using draw.io
GNU Lesser General Public License v2.1
0 stars 7 forks source link

On page print via Ctrl+P, diagrams do not get resized to page width in Chrome #179

Closed slauriere closed 3 years ago

slauriere commented 3 years ago

Steps to reproduce

  1. Create a diagram
  2. Add a rectangle to it, with a width of approximately 1200 pixels
  3. Save and view the page
  4. Hit Ctrl+P

Actual result

Diagram page

diagram-page

Diagram page print preview on Chrome

diagram-print-chrome

Diagram page print preview on Firefox

diagram-print-firefox

Expected result

Workaround

Bypassing the dynamic sizing mechanism of the application by displaying the diagram as an image pointing at the generated SVG file allows to obtain the expected result on Ctrl+P on Chrome (an option is then to include that img element in the standard diagram sheet with a @media print rule displaying it only on print, while the diagram viewer should then get hidden on print (class="hidden-print")).

{{html clean="false"}}
<img src='/xwiki/bin/download/Diagram/ABC/WebHome/diagram.svg' />
{{/html}}

Diagram print preview on Chrome with workaround

diagram-print-chrome-workaround

Environment

See also

oanalavinia commented 3 years ago

The problem seems to be that for Chrome the page is not scaled automatically at print step. On Firefox, the setting "Fit to page width" is set by default. Such a setting is not present on Chrome, but you can set Settings -> More settings -> Scale to a Custom width, with the value 89 for example, and this will lead to the same result as in the other browser. Note that this scale will be available for all prints until it is changed back.