Closed rhz closed 1 year 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.
Hi @rhz, in which file did you added these four lines? Regards
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.
Tools using this program depend on the command line parameters working. Work around by CSS won't fit such use cases.
I use mermaid-cli version 8.11.0 with the --pdfFit flag.
mmdc --pdfFit -i input.md -o output.pdf
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.
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.