mermaidjs / mermaid.cli

Development has been moved to https://github.com/mermaid-js/mermaid-cli
MIT License
1.09k stars 117 forks source link

gantt: pdf output page is too big and the -w and -H options don't seem to affect it #48

Closed rhz closed 1 year ago

rhz commented 6 years ago

The gantt chart is printed at the top of the page and the rest is just blank space. Also, the -w and -H don't seem to affect the output pdf. It would be great if the output pdf would be cropped to fit just the chart. A partial solution would be to have the option to create a landscape pdf.

rhz commented 6 years ago

To fix this issue, I had to add the following to the object passed to the page.pdf function.

width: width,
height: height,
preferCSSPageSize: true,
margin: { left: 30 }

Without the preferCSSPageSize it would keep printing the pdf on a letter size page. The margin helps to position the gantt chart at the centre. Unfortunately, 30 pixels might not be a good choice in every situation and the page.pdf function doesn't understand relative (eg percentage) units for its margin. Maybe something like 0.015*width would be better.

I'll keep this issue open in the hope that the snippet above gets incorporated into the master branch.

Rokko11 commented 6 years ago

Hi @rhz, in which file did you added these four lines? Regards

rhz commented 6 years ago

In index.js (line 119).

aantonello commented 5 years ago

Hi, all.

Actually a change is not needed. We can control the page size, margin and orientation using CSS:

@page {
    size: A4 Landscape;
    margin: 1cm;
}

This works fine in the current version.

bebuch commented 5 years ago

Tools using this program depend on the command line parameters working. Work around by CSS won't fit such use cases.

bglnelissen commented 2 years ago

I use mermaid-cli version 8.11.0 with the --pdfFit flag.

mmdc --pdfFit -i input.md -o output.pdf

aloisklink commented 1 year ago

Development has moved to the https://github.com/mermaid-js/mermaid-cli repo, please re-open your issue there if it's still relevant. The package has also been renamed on NPM to @mermaid-js/mermaid-cli, so you may need to run npm uninstall mermaid.cli && npm install @mermaid-js/mermaid-cli to get the latest version of this package.