{"versions":{"2.6.0":{"name":"dom-to-image","version":"2.6.0","description":"Generates an image from a DOM node using HTML5 canvas and SVG","main":"src/dom-to-image.js","dependencies":{},"devDependencies":{"chai":"^2.2.0","grunt":"~0.4.5","grunt-cli":"^1.2.0","grunt-contrib-jshint":"^0.11.2","grunt-contrib-uglify":"^0.9.1","grunt-contrib-watch":"^0.6.1","grunt-karma":"^1.0.0","karma":"^0.13.22","karma-chai":"^0.1.0","karma-chrome-launcher":"^0.1.8","karma-firefox-launcher":"^0.1.4","karma-mocha":"^0.1.10","karma-mocha-reporter":"^1.3.0","mocha":"^2.2.4"},"scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git+https://github.com/tsayen/dom-to-image.git"},"keywords":["dom","image","raster","render","html","canvas","svg"],"author":{"name":"Anatolii Saienko","email":"anatoly.sayenko@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/tsayen/dom-to-image/issues"},"homepage":"https://github.com/tsayen/dom-to-image#readme","gitHead":"fae625bce0970b3a039671ea7f338d05ecb3d0e8","_id":"dom-to-image@2.6.0","_shasum":"8a503608088c87b1c22f9034ae032e1898955867","_from":".","_npmVersion":"3.9.5","_nodeVersion":"6.2.2","_npmUser":{"name":"anonymous","email":"anatoly.sayenko@gmail.com"},"dist":{"shasum":"8a503608088c87b1c22f9034ae032e1898955867","size":1497291,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/dom-to-image/-/dom-to-image-2.6.0.tgz"},"maintainers":[{"name":"anonymous","email":"anatoly.sayenko@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dom-to-image-2.6.0.tgz_1507145144015_0.3901117821224034"},"directories":{},"publish_time":1507145146167,"_cnpm_publish_time":1507145146167,"_hasShrinkwrap":false,"contributors":[]},"2.5.2":{"name":"dom-to-image","version":"2.5.2","description":"Generates an image from a DOM node using HTML5 canvas and SVG","main":"src/dom-to-image.js","dependencies":{},"devDependencies":{"chai":"^2.2.0","grunt":"~0.4.5","grunt-contrib-jshint":"^0.11.2","grunt-contrib-uglify":"^0.9.1","grunt-contrib-watch":"^0.6.1","grunt-karma":"^1.0.0","karma":"^0.13.22","karma-chai":"^0.1.0","karma-chrome-launcher":"^0.1.8","karma-firefox-launcher":"^0.1.4","karma-mocha":"^0.1.10","karma-mocha-reporter":"^1.3.0","mocha":"^2.2.4"},"scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git+https://github.com/tsayen/dom-to-image.git"},"keywords":["dom","image","raster","render","html","canvas","svg"],"author":{"name":"Anatolii Saienko","email":"anatoly.sayenko@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/tsayen/dom-to-image/issues"},"homepage":"https://github.com/tsayen/dom-to-image#readme","gitHead":"8e60e04b16e97195b851f22ed65313eb19b5c3c3","_id":"dom-to-image@2.5.2","_shasum":"6476b9f43c27c00b76ce4f164d20e5eeab032497","_from":".","_npmVersion":"3.9.5","_nodeVersion":"6.2.2","_npmUser":{"name":"anonymous","email":"anatoly.sayenko@gmail.com"},"dist":{"shasum":"6476b9f43c27c00b76ce4f164d20e5eeab032497","size":147664,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/dom-to-image/-/dom-to-image-2.5.2.tgz"},"maintainers":[{"name":"anonymous","email":"anatoly.sayenko@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/dom-to-image-2.5.2.tgz_1474790819210_0.6053437637165189"},"directories":{},"publish_time":1474790820581,"_cnpm_publish_time":1474790820581,"_hasShrinkwrap":false,"contributors":[]},"2.5.1":{"name":"dom-to-image","version":"2.5.1","description":"Generates an image from a DOM node using HTML5 canvas and SVG","main":"src/dom-to-image.js","dependencies":{},"devDependencies":{"chai":"^2.2.0","grunt":"~0.4.5","grunt-contrib-jshint":"^0.11.2","grunt-contrib-uglify":"^0.9.1","grunt-contrib-watch":"^0.6.1","grunt-karma":"^1.0.0","karma":"^0.13.22","karma-chai":"^0.1.0","karma-chrome-launcher":"^0.1.8","karma-firefox-launcher":"^0.1.4","karma-mocha":"^0.1.10","karma-mocha-reporter":"^1.3.0","mocha":"^2.2.4"},"scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git+https://github.com/tsayen/dom-to-image.git"},"keywords":["dom","image","raster","render","html","canvas","svg"],"author":{"name":"Anatolii Saienko","email":"anatoly.sayenko@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/tsayen/dom-to-image/issues"},"homepage":"https://github.com/tsayen/dom-to-image#readme","gitHead":"e40eac0832ba4c40f9038d360fdcff331dd6ed5d","_id":"dom-to-image@2.5.1","_shasum":"1f83801b615d69e6a7970080efd0e8d638ee6d06","_from":".","_npmVersion":"3.9.5","_nodeVersion":"6.2.2","_npmUser":{"name":"anonymous","email":"anatoly.sayenko@gmail.com"},"dist":{"shasum":"1f83801b615d69e6a7970080efd0e8d638ee6d06","size":146951,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/dom-to-image/-/dom-to-image-2.5.1.tgz"},"maintainers":[{"name":"anonymous","email":"anatoly.sayenko@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/dom-to-image-2.5.1.tgz_1469947443046_0.9683640236034989"},"directories":{},"publish_time":1469947444862,"_cnpm_publish_time":1469947444862,"_hasShrinkwrap":false,"contributors":[]},"2.5.0":{"name":"dom-to-image","version":"2.5.0","description":"Generates an image from a DOM node using HTML5 canvas and SVG","main":"src/dom-to-image.js","dependencies":{},"devDependencies":{"chai":"^2.2.0","grunt":"~0.4.5","grunt-contrib-jshint":"^0.11.2","grunt-contrib-uglify":"^0.9.1","grunt-contrib-watch":"^0.6.1","grunt-karma":"^0.10.1","karma":"^0.12.31","karma-chai":"^0.1.0","karma-chrome-launcher":"^0.1.8","karma-firefox-launcher":"^0.1.4","karma-mocha":"^0.1.10","karma-mocha-reporter":"^1.3.0","mocha":"^2.2.4"},"scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git+https://github.com/tsayen/dom-to-image.git"},"keywords":["dom","image","raster","render","html","canvas","svg"],"author":{"name":"Anatolii Saienko","email":"anatoly.sayenko@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/tsayen/dom-to-image/issues"},"homepage":"https://github.com/tsayen/dom-to-image#readme","gitHead":"5a937b6aa2e507ec8ed8f1056d969182db183737","_id":"dom-to-image@2.5.0","_shasum":"6ee2d9e7b4645f05373e9e3490e515ca0f39fddd","_from":".","_npmVersion":"3.9.5","_nodeVersion":"6.2.2","_npmUser":{"name":"anonymous","email":"anatoly.sayenko@gmail.com"},"dist":{"shasum":"6ee2d9e7b4645f05373e9e3490e515ca0f39fddd","size":143009,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/dom-to-image/-/dom-to-image-2.5.0.tgz"},"maintainers":[{"name":"anonymous","email":"anatoly.sayenko@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/dom-to-image-2.5.0.tgz_1469511482444_0.5713886886369437"},"directories":{},"publish_time":1469511484430,"_cnpm_publish_time":1469511484430,"_hasShrinkwrap":false,"contributors":[]},"2.4.0":{"name":"dom-to-image","version":"2.4.0","description":"Generates an image from a DOM node using HTML5 canvas and SVG","main":"src/dom-to-image.js","dependencies":{},"devDependencies":{"chai":"^2.2.0","grunt":"~0.4.5","grunt-contrib-jshint":"^0.11.2","grunt-contrib-uglify":"^0.9.1","grunt-contrib-watch":"^0.6.1","grunt-karma":"^0.10.1","karma":"^0.12.31","karma-chai":"^0.1.0","karma-chrome-launcher":"^0.1.8","karma-firefox-launcher":"^0.1.4","karma-mocha":"^0.1.10","karma-mocha-reporter":"^1.3.0","mocha":"^2.2.4"},"scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git+https://github.com/tsayen/dom-to-image.git"},"keywords":["dom","image","raster","render","html","canvas","svg"],"author":{"name":"Anatolii Saienko","email":"anatoly.sayenko@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/tsayen/dom-to-image/issues"},"homepage":"https://github.com/tsayen/dom-to-image#readme","gitHead":"aae870fd759257aaa84d9f2397d039ad71a3e7b0","_id":"dom-to-image@2.4.0","_shasum":"b4e548caa1bd0227ebb88594264391ec4d1283a9","_from":".","_npmVersion":"3.8.7","_nodeVersion":"0.12.13","_npmUser":{"name":"anonymous","email":"anatoly.sayenko@gmail.com"},"dist":{"shasum":"b4e548caa1bd0227ebb88594264391ec4d1283a9","size":139852,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/dom-to-image/-/dom-to-image-2.4.0.tgz"},"maintainers":[{"name":"anonymous","email":"anatoly.sayenko@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/dom-to-image-2.4.0.tgz_1461516497616_0.8592578393872827"},"directories":{},"publish_time":1461516499521,"_cnpm_publish_time":1461516499521,"_hasShrinkwrap":false,"contributors":[]},"2.3.0":{"name":"dom-to-image","version":"2.3.0","description":"Generates an image from a DOM node using HTML5 canvas and SVG","main":"src/dom-to-image.js","dependencies":{},"devDependencies":{"chai":"^2.2.0","grunt":"~0.4.5","grunt-contrib-jshint":"^0.11.2","grunt-contrib-uglify":"^0.9.1","grunt-contrib-watch":"^0.6.1","grunt-karma":"^0.10.1","karma":"^0.12.31","karma-chai":"^0.1.0","karma-chrome-launcher":"^0.1.8","karma-firefox-launcher":"^0.1.4","karma-mocha":"^0.1.10","karma-mocha-reporter":"^1.0.2","mocha":"^2.2.4"},"scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git+https://github.com/tsayen/dom-to-image.git"},"keywords":["dom","image","raster","render","html","canvas","svg"],"author":{"name":"Anatolii Saienko","email":"anatoly.sayenko@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/tsayen/dom-to-image/issues"},"homepage":"https://github.com/tsayen/dom-to-image#readme","gitHead":"941464ef083ba09ad876ad10a970d7204591d5eb","_id":"dom-to-image@2.3.0","_shasum":"728a2912aeb23849258997a85e805e21feef635a","_from":".","_npmVersion":"3.8.7","_nodeVersion":"0.12.13","_npmUser":{"name":"anonymous","email":"anatoly.sayenko@gmail.com"},"dist":{"shasum":"728a2912aeb23849258997a85e805e21feef635a","size":139482,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/dom-to-image/-/dom-to-image-2.3.0.tgz"},"maintainers":[{"name":"anonymous","email":"anatoly.sayenko@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/dom-to-image-2.3.0.tgz_1461479940153_0.8658299052622169"},"directories":{},"publish_time":1461479942007,"_cnpm_publish_time":1461479942007,"_hasShrinkwrap":false,"contributors":[]},"2.2.1":{"name":"dom-to-image","version":"2.2.1","description":"Generates an image from a DOM node using HTML5 canvas and SVG","main":"src/dom-to-image.js","dependencies":{},"devDependencies":{"chai":"^2.2.0","grunt":"~0.4.5","grunt-contrib-jshint":"^0.11.2","grunt-contrib-uglify":"^0.9.1","grunt-contrib-watch":"^0.6.1","grunt-karma":"^0.10.1","karma":"^0.12.31","karma-chai":"^0.1.0","karma-chrome-launcher":"^0.1.8","karma-firefox-launcher":"^0.1.4","karma-mocha":"^0.1.10","karma-mocha-reporter":"^1.0.2","mocha":"^2.2.4"},"scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git+https://github.com/tsayen/dom-to-image.git"},"keywords":["dom","image","raster","render","html","canvas","svg"],"author":{"name":"Anatolii Saienko","email":"anatoly.sayenko@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/tsayen/dom-to-image/issues"},"homepage":"https://github.com/tsayen/dom-to-image#readme","gitHead":"b923d610a9f7fae19890e10ce3107e85a6030921","_id":"dom-to-image@2.2.1","_shasum":"41877d84a5f8bd47e9d52589cf39ce4bceec138f","_from":".","_npmVersion":"3.6.0","_nodeVersion":"0.12.9","_npmUser":{"name":"anonymous","email":"anatoly.sayenko@gmail.com"},"dist":{"shasum":"41877d84a5f8bd47e9d52589cf39ce4bceec138f","size":138405,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/dom-to-image/-/dom-to-image-2.2.1.tgz"},"maintainers":[{"name":"anonymous","email":"anatoly.sayenko@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/dom-to-image-2.2.1.tgz_1461436608603_0.6424572088290006"},"directories":{},"publish_time":1461436610480,"_cnpm_publish_time":1461436610480,"_hasShrinkwrap":false,"contributors":[]}},"dist-tags":{"latest":"2.6.0"},"name":"dom-to-image","time":{"modified":"2023-07-27T21:29:22.694Z","created":"2022-01-26T18:24:23.361Z","2.6.0":"2017-10-04T19:25:46.167Z","2.5.2":"2016-09-25T08:07:00.581Z","2.5.1":"2016-07-31T06:44:04.862Z","2.5.0":"2016-07-26T05:38:04.430Z","2.4.0":"2016-04-24T16:48:19.521Z","2.3.0":"2016-04-24T06:39:02.007Z","2.2.1":"2016-04-23T18:36:50.480Z"},"readme":"# DOM to Image\n\n[![Build Status](https://travis-ci.org/tsayen/dom-to-image.svg?branch=master)](https://travis-ci.org/tsayen/dom-to-image)\n\n## What is it\n\n**dom-to-image** is a library which can turn arbitrary DOM node into\na vector (SVG) or raster (PNG or JPEG) image, written in JavaScript. It's\nbased on [domvas by Paul Bakaus](https://github.com/pbakaus/domvas)\nand has been completely rewritten, with some bugs fixed and some new\nfeatures (like web font and image support) added.\n\n## Installation\n\n### NPM\n\n`npm install dom-to-image`\n\nThen load\n\n```javascript\n/* in ES 6 */\nimport domtoimage from 'dom-to-image';\n/* in ES 5 */\nvar domtoimage = require('dom-to-image');\n```\n\n### Bower\n\n`bower install dom-to-image`\n\nInclude either `src/dom-to-image.js` or `dist/dom-to-image.min.js` in your page\nand it will make the `domtoimage` variable available in the global scope.\n\n```html\n<script src=\"path/to/dom-to-image.min.js\" />\n<script>\n  domtoimage.toPng(node)\n  //...\n</script>\n```\n\n## Usage\n\nAll the top level functions accept DOM node and rendering options,\nand return promises, which are fulfilled with corresponding data URLs.  \nGet a PNG image base64-encoded data URL and display right away:\n\n```javascript\nvar node = document.getElementById('my-node');\n\ndomtoimage.toPng(node)\n    .then(function (dataUrl) {\n        var img = new Image();\n        img.src = dataUrl;\n        document.body.appendChild(img);\n    })\n    .catch(function (error) {\n        console.error('oops, something went wrong!', error);\n    });\n```\n\nGet a PNG image blob and download it (using [FileSaver](https://github.com/eligrey/FileSaver.js/),\nfor example):\n\n```javascript\ndomtoimage.toBlob(document.getElementById('my-node'))\n    .then(function (blob) {\n        window.saveAs(blob, 'my-node.png');\n    });\n```\n\nSave and download a compressed JPEG image:\n\n```javascript\ndomtoimage.toJpeg(document.getElementById('my-node'), { quality: 0.95 })\n    .then(function (dataUrl) {\n        var link = document.createElement('a');\n        link.download = 'my-image-name.jpeg';\n        link.href = dataUrl;\n        link.click();\n    });\n```\n\nGet an SVG data URL, but filter out all the `<i>` elements:\n\n```javascript\nfunction filter (node) {\n    return (node.tagName !== 'i');\n}\n\ndomtoimage.toSvg(document.getElementById('my-node'), {filter: filter})\n    .then(function (dataUrl) {\n        /* do something */\n    });\n```\n\nGet the raw pixel data as a [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)\nwith every 4 array elements representing the RGBA data of a pixel:\n\n```javascript\nvar node = document.getElementById('my-node');\n\ndomtoimage.toPixelData(node)\n    .then(function (pixels) {\n        for (var y = 0; y < node.scrollHeight; ++y) {\n          for (var x = 0; x < node.scrollWidth; ++x) {\n            pixelAtXYOffset = (4 * y * node.scrollHeight) + (4 * x);\n            /* pixelAtXY is a Uint8Array[4] containing RGBA values of the pixel at (x, y) in the range 0..255 */\n            pixelAtXY = pixels.slice(pixelAtXYOffset, pixelAtXYOffset + 4);\n          }\n        }\n    });\n```\n\n* * *\n\n_All the functions under `impl` are not public API and are exposed only\nfor unit testing._\n\n* * *\n\n### Rendering options\n\n#### filter\n\nA function taking DOM node as argument. Should return true if passed node\nshould be included in the output (excluding node means excluding it's\nchildren as well). Not called on the root node.\n\n#### bgcolor\n\nA string value for the background color, any valid CSS color value.\n\n#### height, width\n\nHeight and width in pixels to be applied to node before rendering.\n\n#### style\n\nAn object whose properties to be copied to node's style before rendering.\nYou might want to check [this reference](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Properties_Reference)\nfor JavaScript names of CSS properties.\n\n#### quality\n\nA number between 0 and 1 indicating image quality (e.g. 0.92 => 92%) of the\nJPEG image. Defaults to 1.0 (100%)\n\n#### cacheBust\n\nSet to true to append the current time as a query string to URL requests to enable cache busting. Defaults to false\n\n#### imagePlaceholder\n\nA data URL for a placeholder image that will be used when fetching an image fails. Defaults to undefined and will throw an error on failed images\n\n## Browsers\n\nIt's tested on latest Chrome and Firefox (49 and 45 respectively at the time\nof writing), with Chrome performing  significantly better on big DOM trees,\npossibly due to it's more performant SVG support, and the fact that it supports\n `CSSStyleDeclaration.cssText` property.  \n\n_Internet Explorer is not (and will not be) supported, as it does not support\nSVG `<foreignObject>` tag_  \n\n_Safari [is not supported](https://github.com/tsayen/dom-to-image/issues/27), as it uses a stricter security model on `<foreignObject`> tag. Suggested workaround is to use `toSvg` and render on the server._`\n\n## Dependencies\n\n### Source\n\nOnly standard lib is currently used, but make sure your browser supports:  \n\n-   [Promise](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise)  \n-   SVG `<foreignObject>` tag\n\n### Tests\n\nMost importantly, tests depend on:\n\n-   [js-imagediff](https://github.com/HumbleSoftware/js-imagediff),\n    to compare rendered and control images\n\n-   [ocrad.js](https://github.com/antimatter15/ocrad.js), for the\n    parts when you can't compare images (due to the browser\n    rendering differences) and just have to test whether the text is rendered\n\n## How it works\n\nThere might some day exist (or maybe already exists?) a simple and standard\nway of exporting parts of the HTML to image (and then this script can only\nserve as an evidence of all the hoops I had to jump through in order to get\nsuch obvious thing done) but I haven't found one so far.  \n\nThis library uses a feature of SVG that allows having arbitrary HTML content\ninside of the `<foreignObject>` tag. So, in order to render that DOM node\nfor you, following steps are taken:  \n\n1.  Clone the original DOM node recursively\n\n2.  Compute the style for the node and each sub-node and copy it to\n    corresponding clone\n\n    -   and don't forget to recreate pseudo-elements, as they are not\n        cloned in any way, of course\n\n3.  Embed web fonts\n\n    -   find all the `@font-face` declarations that might represent web fonts\n\n    -   parse file URLs, download corresponding files\n\n    -   base64-encode and inline content as `data:` URLs\n\n    -   concatenate all the processed CSS rules and put them into one `<style>`\n        element, then attach it to the clone\n\n4.  Embed images\n\n    -   embed image URLs in `<img>` elements\n\n    -   inline images used in `background` CSS property, in a fashion similar to\n        fonts\n\n5.  Serialize the cloned node to XML\n\n6.  Wrap XML into the `<foreignObject>` tag, then into the SVG, then make it a\n    data URL\n\n7.  Optionally, to get PNG content or raw pixel data as a Uint8Array, create an\n    Image element with the SVG as a source, and render it on an off-screen\n    canvas, that you have also created, then read the content from the canvas\n\n8.  Done!  \n\n## Things to watch out for\n\n-   if the DOM node you want to render includes a `<canvas>` element with\n    something drawn on it, it should be handled fine, unless the canvas is\n    [tainted](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image) -\n    in this case rendering will rather not succeed.  \n\n-   at the time of writing, Firefox has a problem with some external stylesheets\n    (see issue #13). In such case, the error will be caught and logged.  \n\n## Authors\n\nAnatolii Saienko, Paul Bakaus (original idea)\n\n## License\n\nMIT","users":{}}