Set the width and height of the image to -1 so that the image matches the size of the targeted HTML element. By setting the browser height to -1 the length of the browser window will also automatically increase to ensure that if the targeted HTML element fits into the browser.
The example code below shows how easy it is to start capturing HTML elements as images from web pages using Node.js. To start creating images just download the Node.js Package, get your key and secret and then use the demo contained within. Then check out the API documentation for Node.js to find out all the ways you can use GrabzIt's API.
var grabzit = require('grabzit');
var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");
// The minus ones indicates that image should not be cropped
var options = {"browserHeight":-1, "width":-1, "height":-1, "format":"jpg", "target":"#Article"};
client.url_to_image("http://www.example.com/", options);
client.save_to("images/result.jpg", function (error, id){
if (error != null){
throw error;
}
});
The example code below shows how easy it is to start capturing HTML elements as images from web pages using PHP. To start creating image files just download the PHP Library, get your key and secret and then use the demo contained within. Then check out the API documentation for PHP to find out all the ways you can use GrabzIt's API.
include("GrabzItClient.php");
$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
// The -1 indicates that image should not be cropped
$options = new \GrabzIt\GrabzItImageOptions();
$options->setWidth(-1);
$options->setHeight(-1);
$options->setBrowserHeight(-1);
$options->setFormat("jpg");
$options->setTargetElement("#Article");
$grabzIt->URLToImage("http://www.example.com/", $options);
$grabzIt->SaveTo("images/result.jpg");
The example code below shows how easy it is to start capturing HTML elements as images from web pages using Python. To start creating images just download the Python Library, get your key and secret and then use the demo contained within. Then check out the API documentation for Python to find out all the ways you can use GrabzIt's API.
from GrabzIt import GrabzItClient
grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")
# The -1 indicates that image should not be cropped
options = GrabzItImageOptions.GrabzItImageOptions()
options.width = 250
options.height = 250
options.browserHeight = -1
options.format = "jpg"
options.targetElement = "#Article"
grabzIt.URLToImage("http://www.example.com/", options)
grabzIt.SaveTo("images/result.jpg")
The example code below shows how easy it is to start capturing HTML elements as images from web pages using our REST API. Then check out the API documentation for the REST API to find out all the ways you can customize your captures.
https://api.grabz.it/services/convert.ashx?key=Sign in to view your Application Key&width=-1&height=-1&bheight=-1&target=%23Article&format=jpg&url=https%3A%2F%2Fwww.example.com%2F
When converting a captured HTML element into a Word document the captured HTML element will appear in the top-left of the Word document page.
The example code below shows how easy it is to start capturing HTML elements as Word documents from web pages using our REST API. Then check out the API documentation for the REST API to find out all the ways you can customize your captures.
https://api.grabz.it/services/convert.ashx?key=Sign in to view your Application Key&target=%23Article&format=docx&url=https%3A%2F%2Fwww.example.com%2F
By default when converting a captured HTML element into a PDF document the captured HTML element will appear in the top-left of the PDF page in the same fashion as for DOCX. However in PDF it is also possible to automatically set the page size so that it matches the size of the HTML element.
The example code below shows how easy it is to start capturing HTML elements as PDF from web pages using our REST API. Then check out the API documentation for the REST API to find out all the ways you can customize your captures.
https://api.grabz.it/services/convert.ashx?key=Sign in to view your Application Key&target=%23Article&format=pdf&url=https%3A%2F%2Fwww.example.com%2F