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 :)
Our Free Plan has 200 credits/month with 5 Mb per PDF file.
Large PDF files use 1 credit per 500kb of network traffic.
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); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; //needed for older .net versions byte[] result = client.UploadValues("https://api.html2pdfrocket.com/pdf", options); System.IO.File.WriteAllBytes(Server.MapPath(Path.Combine("~/", @"c:\temp\mypdf.pdf")), result); }
<a href="https://api.html2pdfrocket.com/pdf?value=http://www.google.com&apikey=ABCD-1234">Download PDF</a>
$apikey = 'ABCD-1234'; $value = 'http://www.google.com'; // a url starting with http or an HTML string (1600 byte limit). see example #5 if you have a long HTML string $result = file_get_contents("https://api.html2pdfrocket.com/pdf?apikey=" . urlencode($apikey) . "&value=" . urlencode($value)); file_put_contents('mypdf.pdf',$result);
We've just added a Java example! Please check it out here
We've just added an Android example! 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("https://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
All the optional parameters can be used in the different code examples.
For PDF conversion taking more than 30 seconds or input/output files more than 6 Mb, you need to use the batch/asynchronous parameters. Examples: C#, PHP
Batch
true to send it through batch process. API will return a PdfToken that you could use for your next api call.
PdfToken
Token to retrieve the pdf file that was passed in batch process. You will get a PdfLink as a return.
Webhook
Instead of polling if the pdf file is already ready, you can send a webhook url where we could post once the file is ready.
PdfDownloadExpirySeconds
Number of seconds before the PdfLink expires. Default and minimum is 300 seconds, max is 900 seconds.
<!DOCTYPE html> <html> <head> <style> .page { padding: 100px; } @media screen { .page { page-break-before: always !important; } } </style> </head> <body> <div class="page"> <div style="height: 20px; background-color: #f91">Page 1</div> </div> <div class="page"> <div style="height: 20px; background-color: #000">Page 2</div> </div> </body> </html>
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 :)
Our Free Plan has 200 credits/month with 5 Mb per PDF file.
Large PDF files use 1 credit per 500kb of network traffic.