Skip to content

mkhuda/dom-screenshot

Repository files navigation

dom-screenshot

Build Status npm version

DOM screenshot by dom-to-image forked & modified from dom-to-image

Install

# YARN
yarn add @mkhuda/dom-screenshot
# NPM
npm install @mkhuda/dom-screenshot

Added & Fix:

  • Change to rollup build
  • Add encodeURIComponent on makeSvgDataUri. Based on this issue
  • Add Typescript support, (.d.ts) battery included.

TODO (on progress):

  • Full rewrite to Typescript
  • Adding chai test (on progress).

Usages (React)

import DomScreenshot from "@mkhuda/dom-screenshot";
....

return(
    <button
        onClick={() => {
          const getElement = document.getElementById("root") as HTMLElement;
          const image = DomScreenshot.toPng(document.body, {});
          image.then((generatedImage) => {
            window.open(generatedImage);
          });
        }}
      >
        Test
    </button>
)
...

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT