Add support for Chrome scaling.

This commit is contained in:
Matt Ward
2020-02-01 18:06:48 +00:00
parent b5a3df85a8
commit 198038f5ea
6 changed files with 99 additions and 9 deletions

View File

@@ -45,6 +45,7 @@ type ChromePrinterOptions struct {
PageRanges string
RpccBufferSize int64
CustomHTTPHeaders map[string]string
Scale float64
}
// DefaultChromePrinterOptions returns the default
@@ -66,6 +67,7 @@ func DefaultChromePrinterOptions(config conf.Config) ChromePrinterOptions {
PageRanges: "",
RpccBufferSize: config.DefaultGoogleChromeRpccBufferSize(),
CustomHTTPHeaders: make(map[string]string),
Scale: 1.0,
}
}
@@ -176,7 +178,8 @@ func (p chromePrinter) Print(destination string) error {
SetDisplayHeaderFooter(true).
SetHeaderTemplate(p.opts.HeaderHTML).
SetFooterTemplate(p.opts.FooterHTML).
SetPrintBackground(true)
SetPrintBackground(true).
SetScale(p.opts.Scale)
if p.opts.PageRanges != "" {
printToPdfArgs.SetPageRanges(p.opts.PageRanges)
}