Starter
$5/month
Now used commercially by 9300+ companies! We've grown too big to be a completely free service - read the backstory.
Code examples available for asp.net, jquery/javascript, php, java, android and others
Conversions are done on multiple server clusters spread across different datacenters
string apiKey = "ABCD-1234"; string value = "http://www.google.com"; // a url starting with http or an HTML string using (var client = new WebClient()) { NameValueCollection options = new NameValueCollection(); options.Add("apikey", apiKey); options.Add("value", value); byte[] result = client.UploadValues("http://api.html2pdfrocket.com/pdf", options); System.IO.File.WriteAllBytes(Server.MapPath(Path.Combine("~/", @"c:\temp\mypdf.pdf")), result); }
<a href="http://api.html2pdfrocket.com/pdf?value=http://www.google.co.nz&apikey=ABCD-1234">Download PDF</a>
<a href="http://html2pdfrocket.com/html/topdf?apikey=ABCD-1234">Download Current Page as PDF</a>
If you wish to use extra parameters when doing API conversions, you must use follow the api.html2pdfrocket.com example. The http://html2pdfrocket.com/html/topdf shortcut example only works with the default parameters.
$apikey = 'ABCD-1234'; $value = 'http://www.google.com'; // a url starting with http or an HTML string. see example #5 if you have a long HTML string $result = file_get_contents("http://api.html2pdfrocket.com/pdf?apikey=" . urlencode($apikey) . "&value=" . urlencode($value)); file_put_contents('mypdf.pdf',$result);
We've just added a Java example! All the optional parameters below can be used. Please check it out here
We've just added an Android example! All the optional parameters below can be used. Please check it out here
require 'net/http' apikey = 'ABCD-1234' value = 'http://www.google.com' # a url starting with http or an HTML string uri = URI("http://api.html2pdfrocket.com/pdf?apikey=#{apikey}&value=#{value}") Net::HTTP.start(uri.host, uri.port) do |http| request = Net::HTTP::Get.new uri.request_uri http.request request do |response| open 'mypdf.pdf', 'w' do |io| response.read_body do |chunk| io.write chunk end end end end
MarginLeft
Value of left margin - default is 0
MarginRight
Value of right margin - default is 0
MarginTop
Value of top margin - default is 0
MarginBottom
Value of bottom margin - default is 0
UseGrayscale
true to generate PDF in grayscale, false or leave blank for full colour
UseLandscape
true to rotate page to landscape, false or leave blank for portrait
EnableForms
true to turn html form fields into pdf form fields
LowQuality
true to reduce the quality, which may lower your network usage if quality is still satisfactory
ImageQuality
override the default image quality percentage (94) and use your own
DisableShrinking
true to disable the intelligent shrinking process we use make the pixel/dpi ratio constant
DisableJavascript
true to disable running JS on page, otherwise javascript runs
JavascriptDelay
Milliseconds to wait for JS to finish executing before converting the page. Useful for ajax calls.
UsePrintStylesheet
true to use the print media stylesheet, false or leave blank to use normal stylesheet
FooterSpacing
Spacing between the header and the content in mm - default is 0
HeaderSpacing
Spacing between the footer and the content in mm - default is 0
PageSize
Default size is A4 but you can use Letter, A0, A2, A3, A5, Legal, etc.
PageWidth
Page width - if you use this, you must also use PageWidth
PageHeight
Page height - if you use this, you must also use PageHeight
ViewPort
e.g. 800x600 - Set if you have custom scrollbars or css attribute overflow to emulate window size
Dpi
Explicitly set the DPI, which is 96 by default. Also see Zoom settings
Zoom
Default zoom is 1.00 You can use any floating point number, e.g. 0.5, 0.75, 1.10, 2.55, 3...
OutputFormat
Must be either "pdf", "jpg", "png", "bmp" or "svg" if not supplied the default is PDF
FileName
Optionally the name you want the file to be called when downloading or $unique$ for guid
Username
For URL conversions, creates a secure basic authentication connection to your server
Password
For URL conversions, creates a secure basic authentication connection to your server
Cookie
Supply in format: NAME|||VALUE|||NAME|||VALUE (that's 2 cookies). Often used for authentication.
Headers and footers, including automatic page numbering can be done by either passing in a url to HeaderUrl/HeaderHtml or FooterUrl/FooterHtml, or passing in a small snippet of plain text to HeaderLeft, HeaderRight, FooterLeft or FooterRight. Note that if you want to use a header or footer, you must also use a margin parameter like MarginTop or MarginBottom to ensure there is space for the header or footer. Your Html should also start with <!DOCTYPE html> and include the <html> and <body> tags
HeaderHtml
To use an html header on each page - a string starting with <!DOCTYPE html>
FooterHtml
To use an html footer on each page - a string starting with <!DOCTYPE html>
HeaderUrl
To use an html header on each page - a url starting with http containing the html
FooterUrl
To use an html footer on each page - a url starting with http containing the html
HeaderLeft
Top left header text (can use replacement tags below)
HeaderRight
Top right header text (can use replacement tags below)
FooterLeft
Bottom left footer (can use replacement tags below)
FooterRight
Bottom right footer (can use replacement tags below)
FooterFontName
Footer font names - Arial by default
HeaderFontName
Header font names - Arial by default
FooterFontSize
The font sizes - 12 by default. Use the the plain value (do not use px or pt)
HeaderFontSize
The font sizes - 12 by default. Use the the plain value (do not use px or pt)
The replacement tags in the following table can be used to set the page numbering. For example, using FooterRight with a value of 'Page [page] of [toPage]', and remembering to also use a margin per above, e.g. MarginBottom with a value of 20
[page]
Tag replaced with number of the pages currently being printed
[frompage]
Tag replaced with the number of the first page to be printedr
[topage]
Tag replaced with the number of the last page to be printed
[section]
Tag replaced with the name of the current section
Let us know if you need extra parameters or other API features
Enter your url beginning with http - or a html string - to convert to a PDF or image file.
Your page doesn't have to be W3C compliant, but please be certain that the page your trying isn't missing links to images or files as we tend to reject pages like that by default :)
I am using it via a ColdFusion server. I used to use iText but that was becoming a real pain. Very happy to have found this!Murray, October 2017
Just tried your solution and it seems nice! - James, October 2017
Pretty good so far👍🏿 - Sam, October 2017
As always thank you for the quick response! - Gene, October 2017
Thanks for an excellent service! - David, October 2017
The pdf works perfectly, Thanks so much for your help !!!! - Federico, October 2017
That looks like what I need - thanks! - Simon, September 2017
Your service is great and works better than anything we've found - Rodrigo, September 2017
Thanks for an awesome service you provide and the awesome customer support. You on the ball for sure:) - Seth, September 2017
Its awesome. Excellent service! - Daniel, September 2017
Thanks for the quick response! We will start our account on your service soon - Stefan, September 2017
Thanks mate, great service! - Antonio, September 2017
The PDFs look really great. Your competitions PDFs are really bad, compared to html2pdfrocket-generated PDF - Rasmus, August 2017
Yepp been brilliant so far! Very fast ... Brendan, August 2017
I'm very happy with your service - Hannes, July 2017
The Java example was simple to follow and to implement - Michael, July 2017
I really like your product - Kent, July 2017
No problema with your service! - Armando, July 2017
See more feedback
Each plan receives credits each month. Each credit allows one conversion. Large PDF files use 1 credit per 500kb of network traffic.
$0 / Month
$5/month
$10/month
$20/month
$25/month
$40/month
Numbers don't fit into your budget or plan? drop us a line with what you do need - we have customers affordably doing 1.6 million PDF's per month
What about security (and also testing on localhost) - do I have to make my webpage publically available?
No - you can send the html (instead of a url) - there is no need to put the page you want to convert publically on the web. This is also slighly faster as we don't have to download the webpage from the internet.
If I do use the URL option, what security options like SSL are there?
You can use basic authentication and pass in a username and password. Our API supports SSL and also reading from https pages. Alternatively some customers use a simple token system, e.g. by passing a secret parameter on the url that noone else will know, e.g. www.myurl.com/invoice?secret=abc123. The token could be simple - the same each time, or it could be time based and expire after a minute or so.
What about data privacy?
We take privacy very seriously and we do not store either the webpage content you sent to us or outputted PDF. Not even in audit trails or exception logs. HTML is processed and sent back to you, and to be perfectly honest, storing all that html, css, images etc or worse, the resulting PDFs would quickly result in terrabytes of useless data that would cost us a lot of money so doesn't make any sense - we also do not have time to sift though tens of thousands of PDF's to find one with something interesting.. Please see our privacy policy for more details
Can I run this on my own private server or cluster?
Yes - we have sent the API source code to several companies, and we can also spin up a dedicated server, or server cluster just for you drop us a line.