Use GrabzIt's free API to easily convert HTML to PDF and HTML to images. When GrabzIt converts HTML it uses a web browser instance to ensure that any resources, referenced within the HTML are rendered properly. e.g. CSS, JavaScript, videos, Flash, SVG or web fonts.
However any resources not in-lined in the HTML must be referenced using an absolute URL in order to be rendered by GrabzIt. For instance a CSS file should be referenced in the HTML code using http://www.example.com/mystyle.css
rather than mystyle.css
As you can see in the demo above, using the HTML to PDF API or HTML to Image API allows developers to create anything they can imagine. Then have it accurately transformed into an image or PDF by our converter.
GrabzIt can easily enable your app to convert HTML to PDF by using our easy to use API, which is available in nine different programming languages. Just choose your required programming language below and then follow the relevant instructions.
The example code below shows how easy it is to use our API to convert HTML to PDF using C#, although GrabzIt's ASP.NET library is compatible with any .NET language. To start creating PDF's just download the ASP.NET Library, get your key and secret and then use the demo contained within. Then check out the API documentation for ASP.NET to find out all the ways you can use GrabzIt's API.
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); grabzIt.HTMLToPDF("<html><body><h1>Hello World!</h1></body></html>"); grabzIt.SaveTo("documents/result.pdf");
The example code below shows how easy it is to use our HTML to PDF Java Library. To start creating PDF's just download the Java Library, get your key and secret and then use the demo contained within. Then check out the API documentation for Java to find out all the ways you can use GrabzIt's API.
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); grabzIt.HTMLToPDF("<html><body><h1>Hello World!</h1></body></html>"); grabzIt.SaveTo("documents/result.pdf");
The example code below shows how easy it is to use our API to convert HTML to PDF using JavaScript. To start creating PDF's download GrabzIt's JavaScript Library. Then get your key and secret, add the domain you want to use the JavaScript on and then check out the API documentation for JavaScript to find out all the ways you can use GrabzIt's API.
<script src="https://cdn.jsdelivr.net/npm/@grabzit/js@<%= APIVersion.JavaScript %>/grabzit.min.js"></script>
<script>
GrabzIt("Sign in to view your Application Key").ConvertHTML("<html><body><h1>Hello World!</h1></body></html>",
{"format": "pdf"}).Create();
</script>
The example code below shows how easy it is to use our API to perform an HTML to PDF conversion using Node.js. To start creating PDF's 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"); client.html_to_pdf("<html><body><h1>Hello World!</h1></body></html>"); client.save_to("documents/result.pdf", function (error, id){ if (error != null){ throw error; } });
The example code below shows how easy it is to use our API to convert HTML to PDF using Perl. To start creating PDF's just download the Perl Library, get your key and secret and then use the demo contained within. Then check out the API documentation for Perl to find out all the ways you can use GrabzIt's API.
#!/usr/bin/perl use GrabzItClient; $grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret"); $grabzIt->HTMLToPDF("<html><body><h1>Hello World!</h1></body></html>"); $grabzIt->SaveTo("documents/result.pdf");
The example code below shows how easy it is to use our API to convert HTML to PDF using PHP. To start creating PDF's 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"); $grabzIt->HTMLToPDF("<html><body><h1>Hello World!</h1></body></html>"); $grabzIt->SaveTo("documents/result.pdf");
The example code below shows how easy it is to use our API to convert HTML to PDF using Python. To start creating PDF's 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") grabzIt.HTMLToPDF("<html><body><h1>Hello World!</h1></body></html>") grabzIt.SaveTo("documents/result.pdf")
The example code below shows how easy it is to use our API to convert HTML to PDF 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.
curl
-d key=Sign in to view your Application Key
-d format=pdf
-d html=%3Chtml%3E%3Cbody%3E%3Ch1%3EHello%20World%21%3C%2Fh1%3E%3C%2Fbody%3E%3C%2Fhtml%3E
https://api.grabz.it/services/convert
The example code below shows how easy it is to use our API to convert HTML to PDF using Ruby. To start creating PDF's just download the Ruby Gem, get your key and secret and then use the demo contained within. Then check out the API documentation for Ruby to find out all the ways you can use GrabzIt's API.
require 'grabzit' grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret") grabzItClient.html_to_pdf("<html><body><h1>Hello World!</h1></body></html>") grabzItClient.save_to("documents/result.pdf")
If you have HTM or HTML files and are using a server-side language such as PHP, then these documents can also be used to generate PDF. Just use the appropriate FileToPDF method for the language you are using instead.
When creating PDF files it is often necessary to specify where you want page breaks to appear in a PDF to stop related content splitting across two pages. To do this you need to specify the special page break HTML syntax as explained in this tutorial.
GrabzIt also enables your application to convert HTML to Images. In one of the following file formats: JPG, PNG, BMP, WEBP or TIFF. Using one of nine different programming languages. Just choose the programming language you want to use below, and then follow the associated instructions.
The example code below shows how easy it is convert HTML to PNG image using ASP.NET. To start creating images just download the ASP.NET Library, get your key and secret and then use the demo contained within. Then check out the API documentation for ASP.NET to find out all the ways you can use GrabzIt's API.
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); ImageOptions options = new ImageOptions(); options.Format = ImageFormat.png; grabzIt.HTMLToImage("<html><body><h1>Hello World!</h1></body></html>", options); grabzIt.SaveTo("images/result.jpg");
The example code below shows how easy it is to convert HTML to PNG image using Java. To start creating images just download the Java Library, get your key and secret and then use the demo contained within. Then check out the API documentation for Java to find out all the ways you can use GrabzIt's API.
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); ImageOptions options = new ImageOptions(); options.setFormat(ImageFormat.PNG); grabzIt.HTMLToImage("<html><body><h1>Hello World!</h1></body></html>", options); grabzIt.SaveTo("images/result.jpg");
The example code below shows how easy it is to convert HTML to JPG in JavaScript. To start creating images download GrabzIt's JavaScript Library. Then get your key and secret, add the domain you want to use the JavaScript on and then check out the API documentation for JavaScript to find out all the ways you can use GrabzIt's API.
<script src="https://cdn.jsdelivr.net/npm/@grabzit/js@<%= APIVersion.JavaScript %>/grabzit.min.js"></script>
<script>
GrabzIt("Sign in to view your Application Key").ConvertHTML("<html><body><h1>Hello World!</h1></body></html>").Create();
</script>
The example code below shows how easy it is to convert HTML to an image 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"); client.html_to_image("<html><body><h1>Hello World!</h1></body></html>"); client.save_to("images/result.jpg", function (error, id){ if (error != null){ throw error; } });
The example code below shows how easy it is to convert HTML to JPG using Perl. To start creating images just download the Perl Library, get your key and secret and then use the demo contained within. Then check out the API documentation for Perl to find out all the ways you can use GrabzIt's API.
#!/usr/bin/perl use GrabzItClient; $grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret"); $grabzIt->HTMLToImage("<html><body><h1>Hello World!</h1></body></html>"); $grabzIt->SaveTo("images/result.jpg");
The example code below shows how easy it is to convert HTML to JPG free 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"); $grabzIt->HTMLToImage("<html><body><h1>Hello World!</h1></body></html>"); $grabzIt->SaveTo("images/result.jpg");
The example code below shows how easy it is to convert HTML to an image 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") grabzIt.HTMLToImage("<html><body><h1>Hello World!</h1></body></html>") grabzIt.SaveTo("images/result.jpg")
The example code below shows how easy it is to convert HTML to a JPG format 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.
curl
-d key=Sign in to view your Application Key
-d format=jpg
-d html=%3Chtml%3E%3Cbody%3E%3Ch1%3EHello%20World%21%3C%2Fh1%3E%3C%2Fbody%3E%3C%2Fhtml%3E
https://api.grabz.it/services/convert
The example code below shows how easy it is to convert HTML to a JPG format using Ruby. To start creating images just download the Ruby Gem, get your key and secret and then use the demo contained within. Then check out the API documentation for Ruby to find out all the ways you can use GrabzIt's API.
require 'grabzit' grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret") grabzItClient.html_to_image("<html><body><h1>Hello World!</h1></body></html>") grabzItClient.save_to("images/result.jpg")