npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@grabzit/js

v3.5.2

Published

Automatically convert HTML or URL's into images, rendered HTML, DOCX or PDF documents using JavaScript. Additionally convert online videos into animated GIF's or convert HTML tables to CSV.

Downloads

59

Readme

GrabzIt 3.5

This library allows you to dynamically convert HTML or a URL to a image, rendered HTML, DOCX document or PDF, a online video to a animated gif or a HTML table into a CSV, JSON or excel spreadsheet. The resulting capture can then be added to anywhere within the webpage or returned as a data URI. Full documentation of this library can be found here: https://grabz.it/api/javascript/

An example of the GrabzIt in action can be found in the demo.html and demoDataURI.html files. Remember to replace the "Your Application Key" with your actual application key found here: https://grabz.it/api/

GrabzIt JavaScript library provides eleven methods:

  • ConvertURL([url to capture], [options])
  • ConvertHTML([html to convert], [options])
  • ConvertPage([options])
  • UseSSL()
  • Encrypt()
  • AddPostVariable(name, value)
  • AddTemplateVariable(name, value)
  • AddTo([element | element id])
  • Create()
  • CreateInvisible()
  • DataURI([callback], [decrypt])

The ConvertURL or ConvertHTML method must be called and then either the AddTo, Create, CreateInvisible or DataURI method. The AddTo method must specify the id of a element or the element were the capture should be displayed, so the first two calls below will work. The Create method just creates the capture on the body tag or the root element of the HTML document if the body tag doesn't exist. An example of this is shown in calls three and four below.

<html>
<body>
<div id="screenshot"></div>
<script>
//Call One
GrabzIt("YOUR APPLICATION KEY").ConvertURL('http://www.bbc.com').AddTo('screenshot');

//Call Two
var elem = document.getElementById('screenshot');
GrabzIt("YOUR APPLICATION KEY").ConvertHTML('<h1>Hello World</h1>').AddTo(elem);

//Call Three
GrabzIt("YOUR APPLICATION KEY").ConvertURL('http://www.bbc.com').Create();

//Call Four
GrabzIt("YOUR APPLICATION KEY").ConvertHTML('<h1>Hello World</h1>').Create();   
</script>
</body>
</html>

The DataURI method requires a callback function this function must have one parameter that the dataUri will be returned in. In both of the examples below the capture is created and then the function is called which appends the dataURI to the datauri div.

<html>
<body>
<div id="datauri" style="width:100%;word-break:break-all"></div>
<script>
function callback(dataUri)
{
    document.getElementById('datauri').innerHTML += dataUri;
}   

//Call One
GrabzIt("YOUR APPLICATION KEY").ConvertURL('http://www.bbc.com').DataURI(callback);

//Call Two
GrabzIt("YOUR APPLICATION KEY").ConvertHTML('<h1>Hello World</h1>').DataURI(callback);
</script>
</body>
</html>

With the CreateInvisible method the capture is created but not shown on the webpage.

<html>
<body>
<script>
//Call One
GrabzIt("YOUR APPLICATION KEY").ConvertURL('http://www.bbc.com').CreateInvisible();

//Call Two
GrabzIt("YOUR APPLICATION KEY").ConvertHTML('<h1>Hello World</h1>').CreateInvisible();  
</script>
</body>
</html>     

The Encrypt method automatically makes a cryptographically secure key and passes it to GrabzIt's API to encrypt your capture. To access encrypted captures use the DataURI method, if a true is passed to the decrypt parameter of the DataURI method any encrypted data will be automatically decrypted using the key created in the Encrypt method.

The options parameter takes all of the parameters found here (excluding the URL and application key parameters): https://grabz.it/api/javascript/parameters.aspx in the options object. For instance if you wanted to set the width and height to be 250 x 200 you could do this like so:

GrabzIt("YOUR APPLICATION KEY").ConvertURL('http://www.bbc.com', {"width": 250, "height": 200}).AddTo('div_id');

GrabzIt JavaScript Library can also be used as a ES 6 Module, for more information follow these step-by-step instructions: https://grabz.it/api/javascript/advanced/