Skip to content
Snippets Groups Projects
Commit 91a74511 authored by Tobias Fuhlroth's avatar Tobias Fuhlroth Committed by Tobias Fuhlroth
Browse files

Add shortcut option to force a transparent background

parent 9c080999
No related branches found
No related tags found
3 merge requests!15Feature/force transparent background,!14Feature/force transparent background,!13Feature/force transparent background
This commit is part of merge request !13. Comments created here will be created in the context of that merge request.
...@@ -18,6 +18,7 @@ program ...@@ -18,6 +18,7 @@ program
.option("-s, --page-size [size]", "Print to Page Size [size]") .option("-s, --page-size [size]", "Print to Page Size [size]")
.option("-w, --width [size]", "Print to Page Width [width] in MM") .option("-w, --width [size]", "Print to Page Width [width] in MM")
.option("-h --height [size]", "Print to Page Height [weight] in MM") .option("-h --height [size]", "Print to Page Height [weight] in MM")
.option("--forceTransparentBackground", "Print with transparent background")
// .option("-m, --page-margin [margin]", "Print with margin [margin]") // .option("-m, --page-margin [margin]", "Print with margin [margin]")
// .option("-n, --hyphenate [lang]", "Hyphenate with language [language], defaults to "en-us"") // .option("-n, --hyphenate [lang]", "Hyphenate with language [language], defaults to "en-us"")
// .option("-hi, --hypher_ignore [str]", "Ignore passed element selectors, such as ".class_to_ignore, h1"") // .option("-hi, --hypher_ignore [str]", "Ignore passed element selectors, such as ".class_to_ignore, h1"")
...@@ -107,14 +108,20 @@ if (typeof input === "string") { ...@@ -107,14 +108,20 @@ if (typeof input === "string") {
} }
(async () => { (async () => {
let printer = new Printer({ const printerOptions = {
headless: headless, headless: headless,
allowLocal: allowLocal, allowLocal: allowLocal,
allowRemote: !program.blockRemote, allowRemote: !program.blockRemote,
allowedPaths: program.allowedPaths, allowedPaths: program.allowedPaths,
allowedDomains: program.allowedDomains, allowedDomains: program.allowedDomains,
additionalScripts: program.additionalScript, additionalScripts: program.additionalScript,
}); };
if (program.forceTransparentBackground) {
printerOptions.overrideDefaultBackgroundColor = { r: 0, g: 0, b: 0, a: 0 }; // Workaround to get a transparent background in the resulting PDF. See https://bugs.chromium.org/p/chromium/issues/detail?id=498892 for more information.
}
let printer = new Printer(printerOptions);
printer.on("page", (page) => { printer.on("page", (page) => {
if (page.position === 0) { if (page.position === 0) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment