<!DOCTYPE html><html> <head> <meta charset="utf-8"> <title>Text Layer to PNG</title>
<style type="text/css"> @font-face { font-family: 'Sitka-Regular.ttf'; font-style: normal; font-weight: 300; src: url('Sitka-Regular.ttf') format('truetype'); }
* { margin: 0; padding: 0; }
html { font-family: 'Sitka-Regular.ttf', cursive; font-size: 60px; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; }
div.layer-container { -webkit-user-modify: read-write; word-wrap: break-word; -webkit-line-break: after-white-space; }
div.layer-container p { line-height: 1.2em; }
.layer-container .secondary {color: #fb0000} </style> </head> <body> <div style="width: 908px; height: 568px;"> <div class="layer-container" style=" position: absolute; top: 21px; left: 52px; width: 102px; height: 504px; " > <p style="line-height: 1em; font-size: 60%;">defaulttextdef<strong>aulttex<span class="secondary">tdefa</span>u</strong>lttextdefaulttextdefaulttextdefaulttextdefaulttextdefaulttextdefaulttext</p> </div> </div> </body></html>
const CDP = require('chrome-remote-interface');const fs = require('fs');
const viewportWidth = 908;const viewportHeight = 800;
CDP(async (client) => { const {Page, Emulation} = client;
try { await Page.enable();
await Page.navigate({url: 'http://localhost/1.html'}); await Page.loadEventFired(async () => { await Emulation.setDefaultBackgroundColorOverride({color: {r: 0, g: 0, b: 0, a: 0}}); await Emulation.setDeviceMetricsOverride({ width: viewportWidth, height: viewportHeight, deviceScaleFactor: 1, mobile: false, fitWindow: false, }); await Emulation.setVisibleSize({width: viewportWidth, height: viewportHeight});
const screenshot = await Page.captureScreenshot(); const buffer = new Buffer(screenshot.data, 'base64');
fs.writeFile('transparency.png', buffer, function(err) { if (err) { console.error(err); } else { console.log('Success'); }
client.close(); }); }); } catch (err) { console.error(err); client.close(); }}).on('error', (err) => { console.error(err);});
Ah nevermind. I see you're calling them both.
--
You received this message because you are subscribed to the Google Groups "headless-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to headless-dev...@chromium.org.
To post to this group, send email to headle...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/5a46bc9a-2e7a-4584-8fae-63ea9560117a%40chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/f50eb42a-a7bf-417b-ad6d-9ffdf2c87741%40chromium.org.