We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
omitBackground: true
Tell us about your environment:
What steps will reproduce the problem?
I am using the following script: render-svg.js:
render-svg.js
const puppeteer = require('puppeteer'); if (process.argv.length < 4 || process.argv.length > 6) { console.log('Usage: output-html.js URL filename [width] [height]'); } else { const inputFile = process.argv[2]; const outputFile = process.argv[3]; (async() => { const browser = await puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox', '--single-process'], timeout: 600000 }); const page = await browser.newPage(); page.on("pageerror", function(err) { var tmp = err.toString(); console.log("Page error: " + tmp); }); if(process.argv.length == 6) { var pageWidth = parseInt(process.argv[4]); var pageHeight = parseInt(process.argv[5]); await page.setViewport({ width: pageWidth, height: pageHeight }); } try { await page.goto('file://' + inputFile, { timeout: 6000000 }); if (outputFile.includes('jpg') || outputFile.includes('png')) { await page.screenshot({ path: outputFile, omitBackground: true }); } else if (outputFile.includes('pdf')) { await page.pdf({path: outputFile}); } } catch(e) { console.log('Failed to render with error: ' + e.toString()); } await browser.close(); })(); }
And trying to render this sample html file with SVG embedded in it:
<!DOCTYPE html> <html> <head> </head> <body> <svg xmlns="http://www.w3.org/2000/svg" width="663" height="217" requires_chrome="true" inch_width="6.906222982885085" inch_height="2.2604078239608802"><text x="0" y="30.88012080242857" textLength="659"><tspan style="font-size: 32.0001px; fill: rgb(0, 0, 0); font-family: "ewert", "emoji", "open sans", "noto sans cjk", "noto sans arabic";" textLength="659">Type here with a bunch of tex</tspan><tspan style="font-size: 32.0001px; fill: rgb(0, 0, 0); font-family: "ewert", "emoji", "open sans", "noto sans cjk", "noto sans arabic"; font-weight: bold;" textLength="659">t</tspan></text><text x="0" y="73.44028729696743" textLength="659"><tspan style="font-size: 32.0001px; fill: rgb(0, 0, 0); font-family: "ewert", "emoji", "open sans", "noto sans cjk", "noto sans arabic"; font-weight: bold;" textLength="659">on mul</tspan><tspan style="font-size: 32.0001px; fill: rgb(0, 0, 0); font-family: "ewert", "emoji", "open sans", "noto sans cjk", "noto sans arabic";" textLength="659">tiple with lots lines and</tspan></text><text x="0" y="116.00045379150629" textLength="659"><tspan style="font-size: 32.0001px; fill: rgb(0, 0, 0); font-family: "ewert", "emoji", "open sans", "noto sans cjk", "noto sans arabic";" textLength="659">and see how this lets see how</tspan></text><text x="0" y="158.56062028604512" textLength="659"><tspan style="font-size: 32.0001px; fill: rgb(0, 0, 0); font-family: "ewert", "emoji", "open sans", "noto sans cjk", "noto sans arabic";" textLength="659">this aligns with lets see how</tspan></text><text x="0" y="201.12078678058398"><tspan style="font-size: 32.0001px; fill: rgb(0, 0, 0); font-family: "ewert", "emoji", "open sans", "noto sans cjk", "noto sans arabic";">this aligns </tspan></text></svg> </body> <style> body { margin: 0; padding: 0; } </style> <script type="text/javascript"> $(function() { }); </script> </html>
What is the expected result? Get a rendered jpg. Example with omitBackground: false which has a white background:
omitBackground: false
What happens instead? Get a black jpg with omitBackground: true:
The text was updated successfully, but these errors were encountered:
After #3240 I realize I am a retard. Sorry for trying to add transparency to a jpg and not realizing why it wasn't working 🤦♂️
Sorry, something went wrong.
fix: set JPG background to white when omitBackground option is used (#…
d929f7e
…3240) Fixes #3234
Successfully merging a pull request may close this issue.
Steps to reproduce
Tell us about your environment:
What steps will reproduce the problem?
I am using the following script:
render-svg.js
:And trying to render this sample html file with SVG embedded in it:
What is the expected result?
Get a rendered jpg. Example with
omitBackground: false
which has a white background:What happens instead?
Get a black jpg with
omitBackground: true
:The text was updated successfully, but these errors were encountered: