Html Renderer
Pricing
Pay per usage
Go to Apify Store
Html Renderer
Generate image for your HTML using a headless browser
0.0 (0)
Pricing
Pay per usage
1
32
4
Last modified
3 years ago
Pricing
Pay per usage
Generate image for your HTML using a headless browser
0.0 (0)
Pricing
Pay per usage
1
32
4
Last modified
3 years ago
# Dockerfile contains instructions how to build a Docker image that# will contain all the code and configuration needed to run your actor.# For a full Dockerfile reference,# see https://docs.docker.com/engine/reference/builder/
# First, specify the base Docker image. Apify provides the following# base images for your convenience:# apify/actor-node-basic (Node.js 10 on Alpine Linux, small and fast)# apify/actor-node-chrome (Node.js 10 + Chrome on Debian)# apify/actor-node-chrome-xvfb (Node.js 10 + Chrome + Xvfb on Debian)# For more information, see https://apify.com/docs/actor#base-images# Note that you can use any other image from Docker Hub.FROM apify/actor-node-chrome
# Copy all files and directories with the source codeCOPY . ./
# Install NPM packages, skip optional and development dependencies to# keep the image small. Avoid logging to much and print the dependency# tree for debuggingRUN npm --quiet set progress=false \ && npm install --only=prod --no-optional \ && echo "Installed NPM packages:" \ && npm list \ && echo "Node.js version:" \ && node --version \ && echo "NPM version:" \ && npm --version
# Specify how to run the source codeCMD npm start
1const Apify = require('apify');2
3Apify.main(async () => {4
5 const input = await Apify.getInput();6
7 const options = {};8
9 if (input.viewport) {10 options.defaultViewport = input.viewport11 }12 const browser = await Apify.launchPuppeteer(options);13
14 const page = await browser.newPage();15 await page.setContent(input.html);16 const image = await page.screenshot({type: input.format, fullPage: true});17
18 await Apify.setValue('screenshot', image, { contentType: `image/${input.format}` });19 if (input.outputType == "link") {20 const keyValueStore = await Apify.openKeyValueStore();21 const link = keyValueStore.getPublicUrl('screenshot');22 await Apify.setValue('OUTPUT', {link});23 } else {24 await Apify.setValue('OUTPUT', image, { contentType: `image/${input.format}` });25 }26});
{ "name": "my-actor", "version": "0.0.1", "dependencies": { "apify": "^0.13.7" }, "scripts": { "start": "node main.js" }, "author": "Me!"}