{"_id":"@bplok20010/rasterizehtml","_rev":"1-a339b59f485919771a4575d7460746b5","name":"@bplok20010/rasterizehtml","dist-tags":{"latest":"1.3.2"},"versions":{"1.3.1":{"name":"@bplok20010/rasterizehtml","title":"rasterizeHTML.js","version":"1.3.1","description":"Renders HTML into the browser's canvas.","keywords":["canvas","HTML"],"homepage":"http://www.github.com/cburgmer/rasterizeHTML.js","bugs":{"url":"https://github.com/cburgmer/rasterizeHTML.js/issues"},"license":"MIT","author":{"name":"Christoph Burgmer","email":"christoph.burgmer@gmail.com"},"directories":{"lib":"./src/","example":"./examples/"},"main":"dist/rasterizeHTML.js","types":"dist/rasterizeHTML.d.ts","repository":{"type":"git","url":"git+https://github.com/bplok20010/rasterizeHTML.js.git"},"dependencies":{"inlineresources":"^1.0.1","sane-domparser-error":"~0.2.0","url":"~0.11.0","xmlserializer":"~0.6.0"},"devDependencies":{"grunt":"^1.4.1","grunt-browserify":"^6.0.0","grunt-cli":"^1.4.3","grunt-contrib-clean":"^2.0.0","grunt-contrib-concat":"^2.0.0","grunt-contrib-connect":"^3.0.0","grunt-contrib-jasmine":"^2.2.0","grunt-contrib-jshint":"^3.1.1","grunt-contrib-uglify":"^5.0.1","grunt-contrib-watch":"^1.1.0","grunt-umd":"^3.0.0","imagediff":"git://github.com/HumbleSoftware/js-imagediff.git#5edce005fe","jasmine-core":"^4.0.0","prettier":"^2.5.1","puppeteer":"^13.0.1"},"prettier":{"tabWidth":4},"scripts":{"test":"grunt && prettier -c test src Gruntfile.js && ./test/integrationTest.js"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"gitHead":"262b3404d1c469ce4a7750a2976dec09b8ae2d6c","_id":"@bplok20010/rasterizehtml@1.3.1","_nodeVersion":"14.17.0","_npmVersion":"7.18.1","dist":{"integrity":"sha512-csOHvYVjwq7T7Y+ZTuE1rx9l69fs8thGIc5TWT7RG8Jrh2przoC+0hFqTkj6wRvXGv68Qa7EN3rshh8p+xS1ow==","shasum":"51be0c5e6c4679fa902d46b5f1707028d32ced7c","tarball":"https://registry.npmjs.org/@bplok20010/rasterizehtml/-/rasterizehtml-1.3.1.tgz","fileCount":74,"unpackedSize":716554,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCzlsI+ABt83AQnoAKeLqMz098estarRQJg/IQqKyiIFAIgTOZaCFJWU9DYFJCknqdzio1W0hj/Ka3nLqwl42ePx9s="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiT3vSACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo4rg/+LmfdUl7Wo57v9/lUKCQs4N+PCg6Hy+gP8KmZq8H49JMu5WCC\r\nwIAe64tLuRDKZMSkrBGaJ1eCitGoaJP/UGcg8gPH5O9Was+wXH5S/RxEcpux\r\nyrsWPEolMGLzWIE23vloEFo+Wuf0plpDjFAxisEyWWPtAI892Y7TUzYrd/bg\r\nac6XsLYhVztrzDCE0bvNHFSFWFxn4yMAFE5y1UzRUzQzwVD0tKK9HeIFgapf\r\neXXagPZJUi8k9tJJrejGMbk41ogzNrB3tGuJV22T1v42k8D9BjB+oDD1EARw\r\nO9Mmv/yqP/8ciKZtVMR0bcrCUKSntVznBMLObEsGQAzIPaJGDzTeWNuCH4ol\r\n+NDhV0WT/0MRmitKZsu95BQnNY8vInpcnq9dLoWF7a4H5MMpLJ0m28/xscls\r\nOuzr2kBi6WVV3ePe8Lh1j3Y7Hlouqp4+OyczsvBm2M5sxCVO2gH8O0cZb8o4\r\n3hv6/3kOlp16kH3ofXVrsYylgl9LOpS5lDnfqAJh+XCilOsvPHRiFkS2g049\r\nxS1TTYeuRUSZKhvZjom3fHfA06RipLJDPev3o/rJ6TjbD+ayoAci2wLg9LUF\r\ntsZI1Bm4qK0ZX75aCOhBM89RBmutYarPTq8UPhjrYID/yDZEpN9T/ZCmWnxc\r\ni66rA55+OMTkX02RsTvVYSMJjpXVdeop09Y=\r\n=6spN\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"bplok20010","email":"nobo.zhou@foxmail.com"},"maintainers":[{"name":"bplok20010","email":"nobo.zhou@foxmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rasterizehtml_1.3.1_1649376210319_0.46284636584904204"},"_hasShrinkwrap":false},"1.3.2":{"name":"@bplok20010/rasterizehtml","title":"rasterizeHTML.js","version":"1.3.2","description":"Renders HTML into the browser's canvas.","keywords":["canvas","HTML"],"homepage":"http://www.github.com/cburgmer/rasterizeHTML.js","bugs":{"url":"https://github.com/cburgmer/rasterizeHTML.js/issues"},"license":"MIT","author":{"name":"Christoph Burgmer","email":"christoph.burgmer@gmail.com"},"directories":{"lib":"./src/","example":"./examples/"},"main":"dist/rasterizeHTML.js","types":"dist/rasterizeHTML.d.ts","repository":{"type":"git","url":"git+https://github.com/bplok20010/rasterizeHTML.js.git"},"dependencies":{"inlineresources":"^1.0.1","sane-domparser-error":"~0.2.0","url":"~0.11.0","xmlserializer":"~0.6.0"},"devDependencies":{"grunt":"^1.4.1","grunt-browserify":"^6.0.0","grunt-cli":"^1.4.3","grunt-contrib-clean":"^2.0.0","grunt-contrib-concat":"^2.0.0","grunt-contrib-connect":"^3.0.0","grunt-contrib-jasmine":"^2.2.0","grunt-contrib-jshint":"^3.1.1","grunt-contrib-uglify":"^5.0.1","grunt-contrib-watch":"^1.1.0","grunt-umd":"^3.0.0","imagediff":"git://github.com/HumbleSoftware/js-imagediff.git#5edce005fe","jasmine-core":"^4.0.0","prettier":"^2.5.1","puppeteer":"^13.0.1"},"prettier":{"tabWidth":4},"scripts":{"test":"grunt && prettier -c test src Gruntfile.js && ./test/integrationTest.js"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"gitHead":"c8e18f12fffc81a63de183a7219054efb955b8c6","_id":"@bplok20010/rasterizehtml@1.3.2","_nodeVersion":"14.17.0","_npmVersion":"7.18.1","dist":{"integrity":"sha512-9X+A7cNGUSEC6VpbptgKcRNwt7T+mfLEQqaGT3U64PSHbIX6Szv+Jz081knpafQj/0H7UsWMIA9pX6jnglvHEw==","shasum":"b02f3c87059f8640b788eb273b56a7ecd15d75db","tarball":"https://registry.npmjs.org/@bplok20010/rasterizehtml/-/rasterizehtml-1.3.2.tgz","fileCount":74,"unpackedSize":716784,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGmtII45rKBAmftWkaWrSK4wi/xqUzjTeSy2oemUeWwBAiBVH2Scy8G/JGCt4nJqfHmmMx7N5qfNrkhayJLMHOEyow=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiT307ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmooXA//RaJkV3nq1XPpBUS8qbvLzuZF1OVKN/vMbBuAKTYt4zIksmkd\r\nOFf7NrBDapw+IXkaA4FAemrmBIMauHSy2yUYXTN7O92qB/5PeY8Jg85tV3dL\r\n+EGxUGIc6CtBR7oMkqm7xVrtgri2ORjDQgPIl4cG2kQIp/N595+DIPm6GCV6\r\nJTkBQwW7mYqCuTECF9/e/uwQlCRDLiOzjU7Fn8y8cyKyXrqQNaBXa4I7WBpk\r\n8+G6NWpc5PhKOMLQrYAsnAjDi1P3V8Rz/AinF91SzBcL53huXr2E3YOF7Q6j\r\nmqXzqTCf7mZmPcdqtrdI2J1LcuDSoJyt+ZU2Bs7ACpL6Md81JYd3DLI773rT\r\nVJA0PEgZC9pp5056oh1cUZozCh3Go9hj8QGhPwtLM3v8f6H761ODyN9/U9mY\r\nwVXFy+gQxrtk2h6ap3/1kd0apib2KYD5Sz/p8ouBLm4C15+BMwj4ELsVOBbj\r\nOg/+mngSyUct56SZvJ3GQoe2tM4SyjGR3NkjjPKOkmae4wX6uZU1G/c4Kdan\r\nrBKRynEbt3b2zmNEyoNmqhOZF+8Id2Z2/P5M84mcrXK3IYBOujz/zFh5GkVB\r\nKz+EPbi+w5h9iormFHUaQNSFQff5tAVUK2Vv4xpWECSe0nFZvCGIeSNi7oYL\r\nNmJuKZ0FTZmNzDKdiv+RoeJfEFfs23Tz5DY=\r\n=VYiI\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"bplok20010","email":"nobo.zhou@foxmail.com"},"maintainers":[{"name":"bplok20010","email":"nobo.zhou@foxmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rasterizehtml_1.3.2_1649376571208_0.6140847970540138"},"_hasShrinkwrap":false}},"time":{"created":"2022-04-08T00:03:30.249Z","1.3.1":"2022-04-08T00:03:30.574Z","modified":"2022-04-08T00:09:31.564Z","1.3.2":"2022-04-08T00:09:31.489Z"},"maintainers":[{"name":"bplok20010","email":"nobo.zhou@foxmail.com"}],"description":"Renders HTML into the browser's canvas.","homepage":"http://www.github.com/cburgmer/rasterizeHTML.js","keywords":["canvas","HTML"],"repository":{"type":"git","url":"git+https://github.com/bplok20010/rasterizeHTML.js.git"},"author":{"name":"Christoph Burgmer","email":"christoph.burgmer@gmail.com"},"bugs":{"url":"https://github.com/cburgmer/rasterizeHTML.js/issues"},"license":"MIT","readme":"rasterizeHTML.js\n================\n\n<a href=\"https://www.npmjs.org/package/rasterizehtml\">\n    <img src=\"https://badge.fury.io/js/rasterizehtml.svg\"\n        align=\"right\" alt=\"NPM version\" height=\"18\">\n</a>\n\nRenders HTML into the browser's canvas.\n\nSee the [API](https://github.com/cburgmer/rasterizeHTML.js/wiki/API).\n\n\nInstall\n-------\n\n    $ npm install rasterizehtml\n\nThen include a script tag with `node_modules/rasterizehtml/dist/rasterizeHTML.allinone.js` or require through [browserify](https://github.com/substack/node-browserify).\n\nExample\n-------\n\n```js\nvar canvas = document.getElementById(\"canvas\");\nrasterizeHTML.drawHTML('Some ' +\n                       '<span style=\"color: green; font-size: 20px;\">HTML</span>' +\n                       ' with an image <img src=\"someimg.png\">',\n                       canvas);\n```\n\nSee [the examples page](https://github.com/cburgmer/rasterizeHTML.js/wiki/Examples). The code also [ships with examples](https://github.com/cburgmer/rasterizeHTML.js/tree/master/examples), make sure to run `npm test` first to compile the library.\n\nHow does it work\n----------------\n\nFor security reasons rendering HTML into a canvas is severly limited. Firefox offers such a function via `ctx.drawWindow()`, but only with Chrome privileges (see https://developer.mozilla.org/en/Drawing_Graphics_with_Canvas).\n\nAs described in http://robert.ocallahan.org/2011/11/drawing-dom-content-to-canvas.html and https://developer.mozilla.org/en/HTML/Canvas/Drawing_DOM_objects_into_a_canvas however it is possible by embedding the HTML into an SVG image as a `<foreignObject>` and then drawing the resulting image via `ctx.drawImage()`.\n\nIn addition SVG is not allowed to link to external resources and so rasterizeHTML.js will load external images, fonts and stylesheets and store them inline via [data: URIs](http://en.wikipedia.org/wiki/Data_URI_scheme) (or inline style elements respectively).\n\nLimitations\n-----------\n\nAll resources (HTML page, CSS, images, fonts and JS) that are needed for drawing the page can only be loaded if from the [same origin](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Same_origin_policy_for_JavaScript), unless techniques like [CORS](http://enable-cors.org) are used. I.E. `drawURL()` can only load pages from the same domain as the current page and all draw methods can equally only embed styling and images from that domain.\n\nThe code is tested under Firefox, Chrome & Safari.\n\nThere's basic support for Microsoft Edge, however **it will not work under [any version of Internet Explorer](https://github.com/cburgmer/rasterizeHTML.js/wiki/Limitations#ie).**\n\nAlso the individual browsers still have some issues when rendering SVGs with embedded HTML to the canvas.\n\n[The full list of limitations is here](https://github.com/cburgmer/rasterizeHTML.js/wiki/Limitations).\n\nTypeScript\n----------\nImport type definitions as follows:\n\n```ts\nimport * as rasterizeHTML from 'rasterizehtml';\n```\nDevelopment\n-----------\n\nRun `npm test`.\n\nFor tests against individual browsers run `python3 -m http.server` and `open http://localhost:8000/test/SpecRunner.html`.\n\nWhere is it used?\n-----------------\n\n* [CSS Critic](https://github.com/cburgmer/csscritic), a lightweight tool for regression testing of Cascading Style Sheets\n* ...\n","readmeFilename":"README.md"}