Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
save-html-as-image
Advanced tools
Changelog
[1.7.1] - 2022-02-16
Readme
This can be used for a couple of things, it can save HTML (DOM) as an image (JPG,PNG) and it can convert SVG images to PNG. Converting SVG to PNG is useful for Safari Browser compatibility since it cannot render SVG images.
saveAsPng(NODE_ELEMENT, USER_OPTIONS, DOM_OPTIONS);
saveAsJpeg(NODE_ELEMENT, USER_OPTIONS, DOM_OPTIONS);
import { saveAsPng, saveAsJpeg } from 'save-html-as-image';
const node = document.getElementById('elementId');
//download the node as png. Image (2019-12-01).png
saveAsPng(node);
//download the node as png. Report (2019-12-01).png
saveAsPng(node, { filename: 'Report', printDate: true });
//download the node as jpeg. Album.jpeg
saveAsJpeg(node, { filename: 'Album', printDate: false });
//download the node as jpeg. Album50.jpeg (With 50% of quality)
saveAsJpeg(node,
{ filename: 'Album50', printDate: false },
{ quality: 0.5 }
);
//download the node as png and Add padding and center element
saveAsPng(
node,
{ filename: 'Report', printDate: true },
{
backgroundColor: 'rgba(101,198,185,0.5)',
style: {
padding: '4px',
display: 'flex',
justifyContent: 'center',
},
}
);
The options are:
Modify the DOM and IMAGE to download.
The options available are:
You can hide elements adding the class "hide-when-downloading".
Hide elements apply display: hidden
to the elements with this class;
<section>
<article>One..</article>
<article class="hide-when-downloading">Two...</article>
</section>
saveAsPng(node, { filename: 'News', printDate: true });
//Only the first article will be visible on the image
Note: The class "hide-when-downloading" must be on root element, That we want hide.
You can remove elements adding the class "remove-when-downloading".
Remove Elements apply display: none
to the elements. So the space into the element will remove.
It's tested on the lasted Chrome (Chrome 76), Firefox and Safari.
We resolve the Safari support with a litte hack and replace svg with image. It's tested with FontAwesomeIcons svgs.
We use a collection of packages to generate and donwnload images, all in one action. The packages are:
FAQs
Save the html as image like png or jpg
The npm package save-html-as-image receives a total of 481 weekly downloads. As such, save-html-as-image popularity was classified as not popular.
We found that save-html-as-image demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.