Posted by & filed under HTML to PDF API.

In this post we’ll show you a list of examples of using the HTML to PDF API. Each of these examples is intended as addition to the documentation, that explains all options.

The HTML to PDF API works in all programming languages. So you can invoke it in C#, Java, PHP, Ruby, Python, VB.NET or whatever else you want to use – as long as you can send HTTP requests.

In this post we’ll focus on just the calling of the API and not so much the implementation in any programming language. You’ll find documentation throughout the site on all the different langauges – particularly in the HTML to PDF API documentation.

Since we’re using a HTTP request to call the API, it’s just like typing in a URL in your browser window. So all the examples below will work by just entering them in the address bar of your Firefox, Opera, Chrome, Internet Explorer, Safari or whatever browser you have.

Below we’ll show you examples of how you can control the HTML to PDF API call to do more things with it.

Examples of different HTTP requests

To get a single page PDF of http://www.google.com, that’s 300mm wide

http://api.htm2pdf.co.uk/urltopdf?apikey=yourapikey&url=http://www.google.com&width=300

To return a PDF of http://www.bbc.co.uk protected with a password ‘htm2pdf’

http://api.htm2pdf.co.uk/urltopdf?apikey=yourapikey&url=http://www.bbc.co.uk&userpass=htm2pdf

To convert the URL http://www.cnn.com to PDF and setting the top and bottom margins to 20mm

http://api.htm2pdf.co.uk/urltopdf?apikey=yourapikey&url=http://www.cnn.com&top=20&bottom=20&unit=mm

To convert http://www.baidu.com and apply our logo as watermark, rotated at 45 degrees.

http://api.htm2pdf.co.uk/urltopdf?apikey=yourapikey&url=http://www.baidu.com&wm=http://www.htm2pdf.co.uk/img/logo.png&wm_angle=45

Hopefully these examples show you how easy, yet powerful this functionality is. Of course you can also pass a lot of the parameters together. If you want to learn more about it then please check out the HTML to PDF API documentation. If you want to use this in our application or on your website today, then please Join our service.

Leave a Reply

You must be logged in to post a comment.