{"id":13753664,"url":"https://github.com/msokk/electron-render-service","last_synced_at":"2025-05-09T21:35:30.979Z","repository":{"id":57221883,"uuid":"49789227","full_name":"msokk/electron-render-service","owner":"msokk","description":"Microservice for rendering PDF/PNG/JPEG from HTML with Electron","archived":true,"fork":false,"pushed_at":"2019-04-27T09:45:56.000Z","size":2162,"stargazers_count":102,"open_issues_count":11,"forks_count":31,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-04T09:05:52.794Z","etag":null,"topics":["docker","electron","html2image","html2pdf","microservice","pdf"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/msokk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-16T20:13:35.000Z","updated_at":"2023-10-30T13:34:56.000Z","dependencies_parsed_at":"2022-08-31T09:41:40.732Z","dependency_job_id":null,"html_url":"https://github.com/msokk/electron-render-service","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msokk%2Felectron-render-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msokk%2Felectron-render-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msokk%2Felectron-render-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msokk%2Felectron-render-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msokk","download_url":"https://codeload.github.com/msokk/electron-render-service/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224884615,"owners_count":17386121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","electron","html2image","html2pdf","microservice","pdf"],"created_at":"2024-08-03T09:01:26.876Z","updated_at":"2024-11-16T06:30:35.097Z","avatar_url":"https://github.com/msokk.png","language":"HTML","readme":"# :no_entry: [DEPRECATED] \nThis project is not actively developed anymore as there are better solutions out there that are headless.\nI would suggest using https://github.com/alvarcarto/url-to-pdf-api\n\n\n# electron-render-service\n\n[![Greenkeeper badge](https://badges.greenkeeper.io/msokk/electron-render-service.svg)](https://greenkeeper.io/)\n[![Build Status](https://travis-ci.org/msokk/electron-render-service.svg?branch=master)](https://travis-ci.org/msokk/electron-render-service)\n[![](https://images.microbadger.com/badges/image/msokk/electron-render-service.svg)](http://microbadger.com/images/msokk/electron-render-service \"Get your own image badge on microbadger.com\")\n[![Docker Hub](https://img.shields.io/badge/docker-ready-blue.svg)](https://hub.docker.com/r/msokk/electron-render-service/)\n[![npm](https://img.shields.io/npm/v/electron-render-service.svg)](https://www.npmjs.com/package/electron-render-service)\n\nSimple PDF/PNG/JPEG render service, accepts webpage URL and returns the resource.\n\nAlternatively an HTML payload can be POST-ed.\n\n## Docker usage\n\nBased on official [Debian Jessie](https://hub.docker.com/_/debian/) image, uses latest [electron](https://github.com/atom/electron).\n\n\n1. `docker run -t -e RENDERER_ACCESS_KEY=secret -p 3000:3000 msokk/electron-render-service`\n2. `wget -O out.pdf 'http://\u003cnode_address\u003e:3000/pdf?accessKey=secret\u0026url=https%3A%2F%2Fgithub.com%2Fmsokk%2Felectron-render-service'`\n\n\u003e NB: Set bigger shared memory size `--shm-size=Xm` (default: `64m`) if dealing with very heavy pages.\n\n\u003e Docker Swarm needs extra configuration to work - [`--shm-size` is not implemented](https://github.com/moby/moby/issues/26714) use `--mount type=tmpfs,dst=/dev/shm,tmpfs-size=134217728 ` instead and blank hostname `-e HOSTNAME=`.\n\n\n## Installation on Debian with Node.js\n\n```sh\n# Enable contrib packages\nsed -i 's/main/main contrib/g' /etc/apt/sources.list\n\n# Install packages needed for runtime\napt-get update \u0026\u0026 apt-get install -y xvfb libgtk2.0-0 ttf-mscorefonts-installer libnotify4 libgconf2-4 libxss1 libnss3 dbus-x11\n\n# Install from NPM\nnpm install -g electron-render-service\n\n# Run in virtual framebuffer\nRENDERER_ACCESS_KEY=secret xvfb-run --server-args=\"-screen 0 1024x768x24\" electron-render-service\n\nwget -O out.pdf 'http://localhost:3000/pdf?accessKey=secret\u0026url=https%3A%2F%2Fgithub.com%2Fmsokk%2Felectron-render-service'\n```\n\n\n## Endpoints\n\n#### `GET /pdf` - Render PDF\n\n*Query params ([About PDF params](https://github.com/electron/electron/blob/master/docs/api/web-contents.md#contentsprinttopdfoptions-callback)):*\n\n  * `accessKey` - Authentication key.\n  * `url` - Full URL to fetch.\n  * `pageSize` - Specify page size of the generated PDF. Can be `A3`, `A4`, `A5`, `Legal`, `Letter`, `Tabloid` or `\u003cwidth\u003ex\u003cheight\u003e` in microns (e.g. `210000x297000` for A4)(default: `A4`)\n  * `marginsType` - Specify the type of margins to use (default: `0`)\n  * `printBackground` - Whether to print CSS backgrounds. (default: `true`)\n  * `landscape` -  `true` for landscape, `false` for portrait. (default: `false`)\n  * `removePrintMedia` - Removes any `\u003clink media=\"print\"\u003e` stylesheets on page before render. (default: `false`)\n  * `delay` - Specify how many seconds to wait before generating the PDF (default: `0`)\n  * `waitForText` - Specify a specific string of text to find before generating the PDF (default: `false`)\n\n### `POST /pdf`\n\nIdentical as above, omit `url` and provide HTML in request body.\n\n#### `GET /png|jpeg` - Render PNG/JPEG\n\n*Query params:*\n\n  * `accessKey` - Authentication key.\n  * `url` - Full URL to fetch.\n  * `quality` - JPEG quality. (default: `80`)\n  * `delay` - Specify how many seconds to wait before generating the image (default: `0`)\n  * `waitForText` - Specify a specific string of text to find before generating the image (default: `false`)\n  * `browserWidth` - Browser window width (default: `rect.width || env.WINDOW_WIDTH`, max: `3000`)\n  * `browserHeight` - Browser window height (default: `rect.height || env.WINDOW_HEIGHT`, max: `3000`)\n  * Clipping rectangle (optional, but all four fields must be defined)\n    * `clippingRect[x]`\n    * `clippingRect[y]`\n    * `clippingRect[width]`\n    * `clippingRect[height]`\n\n### `POST /png|jpeg`\n\nIdentical as above, omit `url` and provide HTML in request body.\n\n#### `GET /stats` - Display render pool stats\n\n*Query params:*\n\n* `accessKey` - Generic authentication key is required.\n\n\n## Environment variables\n\n##### *Required*\n* `RENDERER_ACCESS_KEY` or `RENDERER_ACCESS_KEY_\u003csuffix\u003e` - Secret key for limiting access. Suffixed keys are used as labels in access log for debugging usage.\n\n##### *Optional*\n* `CONCURRENCY` - Number of browser windows to run in parallel (default: `1`)\n* `TIMEOUT` - Number of seconds before request timeouts (default: `30`)\n* `WINDOW_WIDTH` - Default window width (default: `1024`)\n* `WINDOW_HEIGHT` - Default window height (default: `768`)\n* `HOSTNAME` - Hostname to accept Express connections on (default: `0.0.0.0`)\n* `PORT` - (default: `3000`)\n* `CHROMIUM_CLI_SWITCHES` - Comma separated list of Chromium command line switches to append. For example pass `ignore-certificate-errors` as value to render self-signed pages (at your own risk).\n\n\n## Delayed Rendering\n\nNot all content is loaded once the DOM is loaded, some data can take time because calls are being made via websockets and other methods. You can delay the rendering by either providing a `delay` value in the query string or you can provide `waitForText` in the query string.\n\nIf you specify `waitForText` the service will continually scan the loaded URL until the overall timeout is reached. If the text passed to the variable `waitForText` is found before the timeout, the PDF/image will generate and return.\n","funding_links":[],"categories":["pdf"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsokk%2Felectron-render-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsokk%2Felectron-render-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsokk%2Felectron-render-service/lists"}