Convert HTML to PDF files

PDF Rocket is a fast, easy to use web service to convert an HTML webpage into an image or PDF file

Now used commercially by 3000+ 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

Why HTML 2 PDF Rocket

How to convert an html string or save a url or webpage to PDF

    • ASP.NET / C#

    • string apiKey = "ABCD-1234";
      string value = "http://www.google.com"; // a url starting with http or an HTML string.  See php example #5 if you are using long strings  
      using (var client = new WebClient())
      {
                                                  client.QueryString.Add("apikey", apiKey);
                                                  client.QueryString.Add("value", value);
                                                  client.DownloadFile("http://api.html2pdfrocket.com/pdf/", @"c:\temp\mypdf.pdf");
      }
      
      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);
      }
      
    • See more ASP.NET / C# examples including MVC..


    • HTML

    • <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.

    • See more javascript examples

    • PHP

    • $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);
      
    • See more PHP examples including streaming to the browser..

    • Java

    • We've just added a Java example! All the optional parameters below can be used. Please check it out here

    • Android

    • We've just added an Android example! All the optional parameters below can be used. Please check it out here

    • RUBY

    • 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
      
    • Optional PDF Parameters (See here for image thumbnail parameters)

    • 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
    • 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 PageHeight
    • 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 or FooterUrl, or passing in a small snippet of 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.

    • 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

Try it yourself

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 :)


We get feedback daily! Here is some of what our customers say

Everything works like a charm! Thank you for creating a service that is easy to use and provide good error information - Sten, September 2016

Wonderful product, our tests show that it converts very well and quickly - Michael, September 2016

Your online PDF conversion service is fantastic! The API integration is quite simple and have had limited HTML formatting issues and the PDFs always come in perfect. Great service! - Huzza, September 2016

Our initial tests and basic integration were successful. The service is really easy to set up and "just works" :-) - Tom, September 2016

Thank u sir ur pdf converting app is nice and the code u provide as examples r also very nice! - Tarun, September 2016

It was super easy. Within a few minutes, I had converted an HTML string to a PDF - Mike, September 2016

Thanks a lot, much much! - Fabio, September 2016

Thank you for your immediate reply.. my customer will be very happy :-) - Silvan, August 2016

This is a fantastic service! Thank you very much for putting it together! - John, August 2016

Love your product! - Nick, August 2016

I think it is a wonderful service. I will purchase a plan - Tommy, August 2016

Works perfectly for me - Nicholas, August 2016

I'm really loving your API, it very simple & fast is compare to others! - Vijay, August 2016

Your product is working nicely in Azure so far and I am very pleased with it - Simon, August 2016

We've been testing your service and are really happy with it. You guys have done a great job with it. - Troy, August 2016

It works great for me, thank you! - Eric, August 2016

Thanks for your help - and sorry I took so much of your time! - Craig, August 2016

I appreciate the help and I just wanna say that you're service is great and I plan to continue using it on other projects that need HTML to PDF generation - Matt, August 2016

The service seems fast and affordable, thanks! - Adrian, August 2016

Thanks for the wonderful utility. It worked like a charm. Kudos for such great work - Mayur, August 2016

Your service does what I want at a good price - Rob, August 2016

Love it! - Christian, July 2016

Congratulations for the service and the excellent customer support :) - Eduard, July 2016

Thanks for all the services and wonderful API you have developed - Rahul, July 2016

Congratulations on a terrific product - John, July 2016

Many thanks for your valuable help and support ! - Phillipe, July 2016

Liking the quality of your service very much - Huub, July 2016

We love the simplicity of how html2pdfrocket works, and thanks making this upgrade for us here, you are awesome! - Daniel, June 2016

Your service works like a charm! - Silvio, June 2016

Excellent product by the way, you saved me an incredible amount of time! - Pieter, June 2016

Great service, so much easier to create my own C# class than expected. Will integrate this in our commercial solution with paid credits - Kim, June 2016

We are using the crap out of your tool :) - Steve, June 2016

It works steady for far and fast to, well done - Colin, June 2016

Thank you for your help! :) - Jorge, June 2016

I've been enjoying the service so far! - Chris, June 2016

My team registered a test account today and within a couple hours we were converting html strings into PDF doc. Great product. Well done - Joe, May 2016

Great product, kept me from wasting hours building my own to get around Azure sandbox limitations - Matt, May 2016

Fast and responsive technical support made setup easy, thanks! - Nayshil, May 2016

Thank you for your excellent work during these months - Ivan, May 2016

I found your API incredibly easy to use and it produced much better PDFs that any of the alternatives that I tried. Assuming everything continues to work this well I intend to recommend html2pdfrocket for all future projects where we need PDFs generated - Bary, May 2016

I am getting a very good output ...thanks for the tools! - Karmakar, May 2016

It's working good for me! - Alan, May 2016

It has been a wonderful and easy to use experience. Thanks for launching an efficient and user friendly product - Namitha, May 2016

Thank you vary much! - Ashdora, May 2016

Love it! It works great! - James, May 2016

The initial tests have gone really well. I’ll be using the service for a few clients from now on - George, May 2016

Thank you very much! - Craig, May 2016

It works nice!!!! - Srivathsan, May 2016

I really like your product! - Brad, May 2016

First of all: Great service!!! I'm setting up an invoice creation platform, and will be integrating your service. I'm hoping to become a big customer soon :) - Kevin, May 2016

The job you made with your API is amazing! - Divino, May 2016

Excellent API and simple in use. thanks - Hamid, May 2016

See more feedback

Monthly Credit Pricing

Each plan receives credits each month. Each credit allows one conversion. Large PDF files use 1 credit per 500kb of network traffic.


    • Always Free

    • $0 / Month

      • 200 credits
      • 5mb per PDF file
    • Get Key
    • Starter

    • $5/month

      • 500+ credits
      • 20mb per PDF file
    • Purchase
    • Basic

    • $10/month

      • 1000 credits
      • 20mb per file
    • Purchase
    • Standard

    • $20/month

      • 3000 credits
      • 20mb per file
    • Purchase
    • Pro

    • $25/month

      • 5000 credits
      • 20mb per file
    • Purchase
    • Advanced

    • $40/month

      • 10000 credits
      • 20mb per file
    • Purchase

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

Top Four Frequently Asked Questions

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.


See more frequently asked questions

Example Webpages Converted

Get Started
Please help us by spreading the word