DocRaptor HTML TO PDF API

Test DocRaptor for yourself

Copy and paste this functioning HTML to PDF code with our public key or generate a PDF from your own HTML and CSS. No account required!

  1. cat <<-'DOCUMENT_OPTIONS' > docraptor_parameters.json { "test": true, "document_type": "pdf", "document_url": "https://docraptor.com/examples/invoice.html" } DOCUMENT_OPTIONS curl https://YOUR_API_KEY_HERE@api.docraptor.com/docs \ --fail --silent --show-error \ --header "Content-Type:application/json" \ --data @docraptor_parameters.json \ > example-invoice.pdfcat <<-'DOCUMENT_OPTIONS' > docraptor_parameters.json { "test": true, "document_type": "xls", "document_url": "https://docraptor.com/examples/cohort_analysis.html" } DOCUMENT_OPTIONS curl https://YOUR_API_KEY_HERE@api.docraptor.com/docs \ --fail --silent --show-error \ --header "Content-Type:application/json" \ --data @docraptor_parameters.json \ > example-cohort-analysis.xlscat <<-'DOCUMENT_OPTIONS' > docraptor_parameters.json { "test": true, "document_type": "pdf", "document_url": "https://docraptor.com/examples/ebook.html" } DOCUMENT_OPTIONS curl https://YOUR_API_KEY_HERE@api.docraptor.com/docs \ --fail --silent --show-error \ --header "Content-Type:application/json" \ --data @docraptor_parameters.json \ > example-ebook.pdfcat <<-'DOCUMENT_OPTIONS' > docraptor_parameters.json { "test": true, "document_type": "xls", "document_url": "https://docraptor.com/examples/report.html" } DOCUMENT_OPTIONS curl https://YOUR_API_KEY_HERE@api.docraptor.com/docs \ --fail --silent --show-error \ --header "Content-Type:application/json" \ --data @docraptor_parameters.json \ > example-report.xls
  2. # # INSTALLATION # # Add the docraptor gem to your project: # $ bundle add docraptor require "docraptor" DocRaptor.configure do |config| config.username = "YOUR_API_KEY_HERE" # this key works in test mode! end docraptor = DocRaptor::DocApi.new begin response = docraptor.create_doc( test: true, # test documents are free but watermarked document_type: "pdf", # document_content: "<h1>Hello, World!</h1>", document_url: "https://docraptor.com/examples/invoice.html", # javascript: true, # prince_options: { # media: "print", # @media 'screen' or 'print' CSS # baseurl: "https://yoursite.com", # the base URL for any relative URLs # } ) # create_doc() returns a binary string File.write("example-invoice.pdf", response, mode: "wb") puts "Successfully created example-invoice.pdf!" rescue DocRaptor::ApiError => error puts "#{error.class}: #{error.message}" puts error.code puts error.response_body puts error.backtrace[0..3].join("\n") end # # INSTALLATION # # Add the docraptor gem to your project: # $ bundle add docraptor require "docraptor" DocRaptor.configure do |config| config.username = "YOUR_API_KEY_HERE" # this key works in test mode! end docraptor = DocRaptor::DocApi.new begin response = docraptor.create_doc( test: true, # test documents are free but watermarked document_type: "xls", # document_content: "<h1>Hello, World!</h1>", document_url: "https://docraptor.com/examples/cohort_analysis.html", # javascript: true, # prince_options: { # media: "print", # @media 'screen' or 'print' CSS # baseurl: "https://yoursite.com", # the base URL for any relative URLs # } ) # create_doc() returns a binary string File.write("example-cohort-analysis.xls", response, mode: "wb") puts "Successfully created example-cohort-analysis.xls!" rescue DocRaptor::ApiError => error puts "#{error.class}: #{error.message}" puts error.code puts error.response_body puts error.backtrace[0..3].join("\n") end # # INSTALLATION # # Add the docraptor gem to your project: # $ bundle add docraptor require "docraptor" DocRaptor.configure do |config| config.username = "YOUR_API_KEY_HERE" # this key works in test mode! end docraptor = DocRaptor::DocApi.new begin response = docraptor.create_doc( test: true, # test documents are free but watermarked document_type: "pdf", # document_content: "<h1>Hello, World!</h1>", document_url: "https://docraptor.com/examples/ebook.html", # javascript: true, # prince_options: { # media: "print", # @media 'screen' or 'print' CSS # baseurl: "https://yoursite.com", # the base URL for any relative URLs # } ) # create_doc() returns a binary string File.write("example-ebook.pdf", response, mode: "wb") puts "Successfully created example-ebook.pdf!" rescue DocRaptor::ApiError => error puts "#{error.class}: #{error.message}" puts error.code puts error.response_body puts error.backtrace[0..3].join("\n") end # # INSTALLATION # # Add the docraptor gem to your project: # $ bundle add docraptor require "docraptor" DocRaptor.configure do |config| config.username = "YOUR_API_KEY_HERE" # this key works in test mode! end docraptor = DocRaptor::DocApi.new begin response = docraptor.create_doc( test: true, # test documents are free but watermarked document_type: "xls", # document_content: "<h1>Hello, World!</h1>", document_url: "https://docraptor.com/examples/report.html", # javascript: true, # prince_options: { # media: "print", # @media 'screen' or 'print' CSS # baseurl: "https://yoursite.com", # the base URL for any relative URLs # } ) # create_doc() returns a binary string File.write("example-report.xls", response, mode: "wb") puts "Successfully created example-report.xls!" rescue DocRaptor::ApiError => error puts "#{error.class}: #{error.message}" puts error.code puts error.response_body puts error.backtrace[0..3].join("\n") end
  3. # # INSTALLATION # # Add the docraptor package to your project: # $ pip install --upgrade docraptor import docraptor doc_api = docraptor.DocApi() # this key works in test mode! doc_api.api_client.configuration.username = 'YOUR_API_KEY_HERE' try: response = doc_api.create_doc({ 'test': True, # test documents are free but watermarked 'document_type': 'pdf', # 'document_content': '<h1>Hello, World!</h1>', 'document_url': 'https://docraptor.com/examples/invoice.html', # 'javascript': True, # 'prince_options': # { # 'media': 'print', # @media 'screen' or 'print' CSS # 'baseurl': 'https://yoursite.com', # the base URL for any relative URLs # }, }) # create_doc() returns a binary string with open('example-invoice.pdf', 'w+b') as f: binary_formatted_response = bytearray(response) f.write(binary_formatted_response) f.close() print('Successfully created example-invoice.pdf!') except docraptor.rest.ApiException as error: print(error.status) print(error.reason) print(error.body) # # INSTALLATION # # Add the docraptor package to your project: # $ pip install --upgrade docraptor import docraptor doc_api = docraptor.DocApi() # this key works in test mode! doc_api.api_client.configuration.username = 'YOUR_API_KEY_HERE' try: response = doc_api.create_doc({ 'test': True, # test documents are free but watermarked 'document_type': 'xls', # 'document_content': '<h1>Hello, World!</h1>', 'document_url': 'https://docraptor.com/examples/cohort_analysis.html', # 'javascript': True, # 'prince_options': # { # 'media': 'print', # @media 'screen' or 'print' CSS # 'baseurl': 'https://yoursite.com', # the base URL for any relative URLs # }, }) # create_doc() returns a binary string with open('example-cohort-analysis.xls', 'w+b') as f: binary_formatted_response = bytearray(response) f.write(binary_formatted_response) f.close() print('Successfully created example-cohort-analysis.xls!') except docraptor.rest.ApiException as error: print(error.status) print(error.reason) print(error.body) # # INSTALLATION # # Add the docraptor package to your project: # $ pip install --upgrade docraptor import docraptor doc_api = docraptor.DocApi() # this key works in test mode! doc_api.api_client.configuration.username = 'YOUR_API_KEY_HERE' try: response = doc_api.create_doc({ 'test': True, # test documents are free but watermarked 'document_type': 'pdf', # 'document_content': '<h1>Hello, World!</h1>', 'document_url': 'https://docraptor.com/examples/ebook.html', # 'javascript': True, # 'prince_options': # { # 'media': 'print', # @media 'screen' or 'print' CSS # 'baseurl': 'https://yoursite.com', # the base URL for any relative URLs # }, }) # create_doc() returns a binary string with open('example-ebook.pdf', 'w+b') as f: binary_formatted_response = bytearray(response) f.write(binary_formatted_response) f.close() print('Successfully created example-ebook.pdf!') except docraptor.rest.ApiException as error: print(error.status) print(error.reason) print(error.body) # # INSTALLATION # # Add the docraptor package to your project: # $ pip install --upgrade docraptor import docraptor doc_api = docraptor.DocApi() # this key works in test mode! doc_api.api_client.configuration.username = 'YOUR_API_KEY_HERE' try: response = doc_api.create_doc({ 'test': True, # test documents are free but watermarked 'document_type': 'xls', # 'document_content': '<h1>Hello, World!</h1>', 'document_url': 'https://docraptor.com/examples/report.html', # 'javascript': True, # 'prince_options': # { # 'media': 'print', # @media 'screen' or 'print' CSS # 'baseurl': 'https://yoursite.com', # the base URL for any relative URLs # }, }) # create_doc() returns a binary string with open('example-report.xls', 'w+b') as f: binary_formatted_response = bytearray(response) f.write(binary_formatted_response) f.close() print('Successfully created example-report.xls!') except docraptor.rest.ApiException as error: print(error.status) print(error.reason) print(error.body)
  4. // // INSTALLATION // // The Axios package is the only requirement for this example: // $ npm install axios const axios = require("axios"); const fs = require("fs"); config = { url: "https://api.docraptor.com/docs", method: "post", responseType: "arraybuffer", //IMPORTANT! Required to fetch the binary PDF headers: { "Content-Type": "application/json" }, data: { user_credentials: "YOUR_API_KEY_HERE", // this key works in test mode! doc: { test: true, // test documents are free but watermarked document_type: "pdf", // document_content: "<h1>Hello, World!</h1>", document_url: "https://docraptor.com/examples/invoice.html" // javascript: true, // prince_options: { // media: "print", // @media 'screen' or 'print' CSS // baseurl: "https://yoursite.com", // the base URL for any relative URLs // } } } }; axios(config) .then(function(response) { fs.writeFile("example-invoice.pdf", response.data, "binary", function( writeErr ) { if (writeErr) throw writeErr; console.log("Saved example-invoice.pdf!"); }); }) .catch(function(error) { // DocRaptor error messages are contained in the response body // Since the response is binary encoded, let's decode var decoder = new TextDecoder("utf-8"); console.log(decoder.decode(error.response.data)); }); // // INSTALLATION // // The Axios package is the only requirement for this example: // $ npm install axios const axios = require("axios"); const fs = require("fs"); config = { url: "https://api.docraptor.com/docs", method: "post", responseType: "arraybuffer", //IMPORTANT! Required to fetch the binary PDF headers: { "Content-Type": "application/json" }, data: { user_credentials: "YOUR_API_KEY_HERE", // this key works in test mode! doc: { test: true, // test documents are free but watermarked document_type: "xls", // document_content: "<h1>Hello, World!</h1>", document_url: "https://docraptor.com/examples/cohort_analysis.html" // javascript: true, // prince_options: { // media: "print", // @media 'screen' or 'print' CSS // baseurl: "https://yoursite.com", // the base URL for any relative URLs // } } } }; axios(config) .then(function(response) { fs.writeFile( "example-cohort-analysis.xls", response.data, "binary", function(writeErr) { if (writeErr) throw writeErr; console.log("Saved example-cohort-analysis.xls!"); } ); }) .catch(function(error) { // DocRaptor error messages are contained in the response body // Since the response is binary encoded, let's decode var decoder = new TextDecoder("utf-8"); console.log(decoder.decode(error.response.data)); }); // // INSTALLATION // // The Axios package is the only requirement for this example: // $ npm install axios const axios = require("axios"); const fs = require("fs"); config = { url: "https://api.docraptor.com/docs", method: "post", responseType: "arraybuffer", //IMPORTANT! Required to fetch the binary PDF headers: { "Content-Type": "application/json" }, data: { user_credentials: "YOUR_API_KEY_HERE", // this key works in test mode! doc: { test: true, // test documents are free but watermarked document_type: "pdf", // document_content: "<h1>Hello, World!</h1>", document_url: "https://docraptor.com/examples/ebook.html" // javascript: true, // prince_options: { // media: "print", // @media 'screen' or 'print' CSS // baseurl: "https://yoursite.com", // the base URL for any relative URLs // } } } }; axios(config) .then(function(response) { fs.writeFile("example-ebook.pdf", response.data, "binary", function(writeErr) { if (writeErr) throw writeErr; console.log("Saved example-ebook.pdf!"); }); }) .catch(function(error) { // DocRaptor error messages are contained in the response body // Since the response is binary encoded, let's decode var decoder = new TextDecoder("utf-8"); console.log(decoder.decode(error.response.data)); }); // // INSTALLATION // // The Axios package is the only requirement for this example: // $ npm install axios const axios = require("axios"); const fs = require("fs"); config = { url: "https://api.docraptor.com/docs", method: "post", responseType: "arraybuffer", //IMPORTANT! Required to fetch the binary PDF headers: { "Content-Type": "application/json" }, data: { user_credentials: "YOUR_API_KEY_HERE", // this key works in test mode! doc: { test: true, // test documents are free but watermarked document_type: "xls", // document_content: "<h1>Hello, World!</h1>", document_url: "https://docraptor.com/examples/report.html" // javascript: true, // prince_options: { // media: "print", // @media 'screen' or 'print' CSS // baseurl: "https://yoursite.com", // the base URL for any relative URLs // } } } }; axios(config) .then(function(response) { fs.writeFile("example-report.xls", response.data, "binary", function(writeErr) { if (writeErr) throw writeErr; console.log("Saved example-report.xls!"); }); }) .catch(function(error) { // DocRaptor error messages are contained in the response body // Since the response is binary encoded, let's decode var decoder = new TextDecoder("utf-8"); console.log(decoder.decode(error.response.data)); });
  5. <?php # # INSTALLATION # # Add the docraptor package to your project: # $ composer require docraptor/docraptor require_once __DIR__ . "/vendor/autoload.php"; $docraptor = new DocRaptor\DocApi(); # this key works in test mode! $docraptor->getConfig()->setUsername("YOUR_API_KEY_HERE"); try { $doc = new DocRaptor\Doc(); $doc->setTest(true); # test documents are free but watermarked $doc->setDocumentType("pdf"); # $doc->setDocumentContent("<h1>Hello, World!</h1>"); $doc->setDocumentUrl("https://docraptor.com/examples/invoice.html"); # $doc->setJavascript(true); # $prince_options = new DocRaptor\PrinceOptions(); # $doc->setPrinceOptions($prince_options); # $prince_options->setMedia("print"); # @media 'screen' or 'print' CSS # $prince_options->setBaseurl("https://yoursite.com"); # the base URL for any relative URLs $response = $docraptor->createDoc($doc); # createDoc() returns a binary string file_put_contents("example-invoice.pdf", $response); echo "Successfully created example-invoice.pdf!"; } catch (DocRaptor\ApiException $error) { echo $error . "\n"; echo $error->getMessage() . "\n"; echo $error->getCode() . "\n"; echo $error->getResponseBody() . "\n"; } <?php # # INSTALLATION # # Add the docraptor package to your project: # $ composer require docraptor/docraptor require_once __DIR__ . "/vendor/autoload.php"; $docraptor = new DocRaptor\DocApi(); # this key works in test mode! $docraptor->getConfig()->setUsername("YOUR_API_KEY_HERE"); try { $doc = new DocRaptor\Doc(); $doc->setTest(true); # test documents are free but watermarked $doc->setDocumentType("xls"); # $doc->setDocumentContent("<h1>Hello, World!</h1>"); $doc->setDocumentUrl("https://docraptor.com/examples/cohort_analysis.html"); # $doc->setJavascript(true); # $prince_options = new DocRaptor\PrinceOptions(); # $doc->setPrinceOptions($prince_options); # $prince_options->setMedia("print"); # @media 'screen' or 'print' CSS # $prince_options->setBaseurl("https://yoursite.com"); # the base URL for any relative URLs $response = $docraptor->createDoc($doc); # createDoc() returns a binary string file_put_contents("example-cohort-analysis.xls", $response); echo "Successfully created example-cohort-analysis.xls!"; } catch (DocRaptor\ApiException $error) { echo $error . "\n"; echo $error->getMessage() . "\n"; echo $error->getCode() . "\n"; echo $error->getResponseBody() . "\n"; } <?php # # INSTALLATION # # Add the docraptor package to your project: # $ composer require docraptor/docraptor require_once __DIR__ . "/vendor/autoload.php"; $docraptor = new DocRaptor\DocApi(); # this key works in test mode! $docraptor->getConfig()->setUsername("YOUR_API_KEY_HERE"); try { $doc = new DocRaptor\Doc(); $doc->setTest(true); # test documents are free but watermarked $doc->setDocumentType("pdf"); # $doc->setDocumentContent("<h1>Hello, World!</h1>"); $doc->setDocumentUrl("https://docraptor.com/examples/ebook.html"); # $doc->setJavascript(true); # $prince_options = new DocRaptor\PrinceOptions(); # $doc->setPrinceOptions($prince_options); # $prince_options->setMedia("print"); # @media 'screen' or 'print' CSS # $prince_options->setBaseurl("https://yoursite.com"); # the base URL for any relative URLs $response = $docraptor->createDoc($doc); # createDoc() returns a binary string file_put_contents("example-ebook.pdf", $response); echo "Successfully created example-ebook.pdf!"; } catch (DocRaptor\ApiException $error) { echo $error . "\n"; echo $error->getMessage() . "\n"; echo $error->getCode() . "\n"; echo $error->getResponseBody() . "\n"; } <?php # # INSTALLATION # # Add the docraptor package to your project: # $ composer require docraptor/docraptor require_once __DIR__ . "/vendor/autoload.php"; $docraptor = new DocRaptor\DocApi(); # this key works in test mode! $docraptor->getConfig()->setUsername("YOUR_API_KEY_HERE"); try { $doc = new DocRaptor\Doc(); $doc->setTest(true); # test documents are free but watermarked $doc->setDocumentType("xls"); # $doc->setDocumentContent("<h1>Hello, World!</h1>"); $doc->setDocumentUrl("https://docraptor.com/examples/report.html"); # $doc->setJavascript(true); # $prince_options = new DocRaptor\PrinceOptions(); # $doc->setPrinceOptions($prince_options); # $prince_options->setMedia("print"); # @media 'screen' or 'print' CSS # $prince_options->setBaseurl("https://yoursite.com"); # the base URL for any relative URLs $response = $docraptor->createDoc($doc); # createDoc() returns a binary string file_put_contents("example-report.xls", $response); echo "Successfully created example-report.xls!"; } catch (DocRaptor\ApiException $error) { echo $error . "\n"; echo $error->getMessage() . "\n"; echo $error->getCode() . "\n"; echo $error->getResponseBody() . "\n"; }
  6. // // INSTALLATION // // Add the com.docraptor package to your project or pom.xml and install it: // $ mvn install com.docraptor import com.docraptor.*; import java.io.*; import java.net.*; import java.nio.file.*; public class DocRaptorExample { public static void main(String[] args) throws Exception { DocApi docraptor = new DocApi(); ApiClient client = docraptor.getApiClient(); client.setUsername("YOUR_API_KEY_HERE"); // this key works in test mode! try { Doc doc = new Doc(); doc.setTest(true); // test documents are free but watermarked doc.setDocumentType(Doc.DocumentTypeEnum.PDF); // doc.setDocumentContent( // "<h1>Hello, World!</h1>" // ); doc.setDocumentUrl("https://docraptor.com/examples/invoice.html"); // doc.setJavascript(true); // PrinceOptions princeOptions = new PrinceOptions(); // princeOptions.setMedia("print"); // @media 'screen' or 'print' CSS // princeOptions.setBaseurl("https://yoursite.com"); // the base URL for any relative URLs // doc.setPrinceOptions(princeOptions); byte[] document = docraptor.createDoc(doc); // createDoc() returns a binary string FileOutputStream file = new FileOutputStream("example-invoice.pdf"); file.write(document); file.close(); System.out.println("Successfully created example-invoice.pdf!"); } catch (ApiException error) { System.err.println(error); System.err.println(error.getCode()); System.err.println(error.getMessage()); System.err.println(error.getResponseBody()); } } } // // INSTALLATION // // Add the com.docraptor package to your project or pom.xml and install it: // $ mvn install com.docraptor import com.docraptor.*; import java.io.*; import java.net.*; import java.nio.file.*; public class DocRaptorExample { public static void main(String[] args) throws Exception { DocApi docraptor = new DocApi(); ApiClient client = docraptor.getApiClient(); client.setUsername("YOUR_API_KEY_HERE"); // this key works in test mode! try { Doc doc = new Doc(); doc.setTest(true); // test documents are free but watermarked doc.setDocumentType(Doc.DocumentTypeEnum.XLS); // doc.setDocumentContent( // "<h1>Hello, World!</h1>" // ); doc.setDocumentUrl("https://docraptor.com/examples/cohort_analysis.html"); // doc.setJavascript(true); // PrinceOptions princeOptions = new PrinceOptions(); // princeOptions.setMedia("print"); // @media 'screen' or 'print' CSS // princeOptions.setBaseurl("https://yoursite.com"); // the base URL for any relative URLs // doc.setPrinceOptions(princeOptions); byte[] document = docraptor.createDoc(doc); // createDoc() returns a binary string FileOutputStream file = new FileOutputStream( "example-cohort-analysis.xls" ); file.write(document); file.close(); System.out.println( "Successfully created example-cohort-analysis.xls!" ); } catch (ApiException error) { System.err.println(error); System.err.println(error.getCode()); System.err.println(error.getMessage()); System.err.println(error.getResponseBody()); } } } // // INSTALLATION // // Add the com.docraptor package to your project or pom.xml and install it: // $ mvn install com.docraptor import com.docraptor.*; import java.io.*; import java.net.*; import java.nio.file.*; public class DocRaptorExample { public static void main(String[] args) throws Exception { DocApi docraptor = new DocApi(); ApiClient client = docraptor.getApiClient(); client.setUsername("YOUR_API_KEY_HERE"); // this key works in test mode! try { Doc doc = new Doc(); doc.setTest(true); // test documents are free but watermarked doc.setDocumentType(Doc.DocumentTypeEnum.PDF); // doc.setDocumentContent( // "<h1>Hello, World!</h1>" // ); doc.setDocumentUrl("https://docraptor.com/examples/ebook.html"); // doc.setJavascript(true); // PrinceOptions princeOptions = new PrinceOptions(); // princeOptions.setMedia("print"); // @media 'screen' or 'print' CSS // princeOptions.setBaseurl("https://yoursite.com"); // the base URL for any relative URLs // doc.setPrinceOptions(princeOptions); byte[] document = docraptor.createDoc(doc); // createDoc() returns a binary string FileOutputStream file = new FileOutputStream("example-ebook.pdf"); file.write(document); file.close(); System.out.println("Successfully created example-ebook.pdf!"); } catch (ApiException error) { System.err.println(error); System.err.println(error.getCode()); System.err.println(error.getMessage()); System.err.println(error.getResponseBody()); } } } // // INSTALLATION // // Add the com.docraptor package to your project or pom.xml and install it: // $ mvn install com.docraptor import com.docraptor.*; import java.io.*; import java.net.*; import java.nio.file.*; public class DocRaptorExample { public static void main(String[] args) throws Exception { DocApi docraptor = new DocApi(); ApiClient client = docraptor.getApiClient(); client.setUsername("YOUR_API_KEY_HERE"); // this key works in test mode! try { Doc doc = new Doc(); doc.setTest(true); // test documents are free but watermarked doc.setDocumentType(Doc.DocumentTypeEnum.XLS); // doc.setDocumentContent( // "<h1>Hello, World!</h1>" // ); doc.setDocumentUrl("https://docraptor.com/examples/report.html"); // doc.setJavascript(true); // PrinceOptions princeOptions = new PrinceOptions(); // princeOptions.setMedia("print"); // @media 'screen' or 'print' CSS // princeOptions.setBaseurl("https://yoursite.com"); // the base URL for any relative URLs // doc.setPrinceOptions(princeOptions); byte[] document = docraptor.createDoc(doc); // createDoc() returns a binary string FileOutputStream file = new FileOutputStream("example-report.xls"); file.write(document); file.close(); System.out.println("Successfully created example-report.xls!"); } catch (ApiException error) { System.err.println(error); System.err.println(error.getCode()); System.err.println(error.getMessage()); System.err.println(error.getResponseBody()); } } }
  7. // // INSTALLATION // // With Nuget: // > nuget.exe install DocRaptor // // With the Package Manager Console: // > Install-Package DocRaptor // // You can also download the DLL directly from GitHub: // https://github.com/DocRaptor/docraptor-csharp/releases using DocRaptor.Client; using DocRaptor.Model; using DocRaptor.Api; using System; using System.IO; class DocRaptorExample { static void Main(string[] args) { DocApi docraptor = new DocApi(); // this key works in test mode! docraptor.Configuration.Username = "YOUR_API_KEY_HERE"; try { Doc doc = new Doc( name: "example-invoice", test: true, // test documents are free but watermarked documentType: Doc.DocumentTypeEnum.Pdf, documentContent: "", // the .NET agent requires documentContent be set documentUrl: "https://docraptor.com/examples/invoice.html" // javascript: true, // princeOptions: new PrinceOptions( // media: "print", // @media 'screen' or 'print' CSS // baseurl: "https://yoursite.com" // the base URL for any relative URLs // ) ); byte[] document = docraptor.CreateDoc(doc); File.WriteAllBytes("example-invoice.pdf", document); Console.WriteLine("Successfully created example-invoice.pdf!"); } catch (DocRaptor.Client.ApiException error) { Console.Write(error.ErrorContent); } } }// // INSTALLATION // // With Nuget: // > nuget.exe install DocRaptor // // With the Package Manager Console: // > Install-Package DocRaptor // // You can also download the DLL directly from GitHub: // https://github.com/DocRaptor/docraptor-csharp/releases using DocRaptor.Client; using DocRaptor.Model; using DocRaptor.Api; using System; using System.IO; class DocRaptorExample { static void Main(string[] args) { DocApi docraptor = new DocApi(); // this key works in test mode! docraptor.Configuration.Username = "YOUR_API_KEY_HERE"; try { Doc doc = new Doc( name: "example-cohort-analysis", test: true, // test documents are free but watermarked documentType: Doc.DocumentTypeEnum.Xls, documentContent: "", // the .NET agent requires documentContent be set documentUrl: "https://docraptor.com/examples/cohort_analysis.html" // javascript: true, // princeOptions: new PrinceOptions( // media: "print", // @media 'screen' or 'print' CSS // baseurl: "https://yoursite.com" // the base URL for any relative URLs // ) ); byte[] document = docraptor.CreateDoc(doc); File.WriteAllBytes("example-cohort-analysis.xls", document); Console.WriteLine("Successfully created example-cohort-analysis.xls!"); } catch (DocRaptor.Client.ApiException error) { Console.Write(error.ErrorContent); } } }// // INSTALLATION // // With Nuget: // > nuget.exe install DocRaptor // // With the Package Manager Console: // > Install-Package DocRaptor // // You can also download the DLL directly from GitHub: // https://github.com/DocRaptor/docraptor-csharp/releases using DocRaptor.Client; using DocRaptor.Model; using DocRaptor.Api; using System; using System.IO; class DocRaptorExample { static void Main(string[] args) { DocApi docraptor = new DocApi(); // this key works in test mode! docraptor.Configuration.Username = "YOUR_API_KEY_HERE"; try { Doc doc = new Doc( name: "example-ebook", test: true, // test documents are free but watermarked documentType: Doc.DocumentTypeEnum.Pdf, documentContent: "", // the .NET agent requires documentContent be set documentUrl: "https://docraptor.com/examples/ebook.html" // javascript: true, // princeOptions: new PrinceOptions( // media: "print", // @media 'screen' or 'print' CSS // baseurl: "https://yoursite.com" // the base URL for any relative URLs // ) ); byte[] document = docraptor.CreateDoc(doc); File.WriteAllBytes("example-ebook.pdf", document); Console.WriteLine("Successfully created example-ebook.pdf!"); } catch (DocRaptor.Client.ApiException error) { Console.Write(error.ErrorContent); } } }// // INSTALLATION // // With Nuget: // > nuget.exe install DocRaptor // // With the Package Manager Console: // > Install-Package DocRaptor // // You can also download the DLL directly from GitHub: // https://github.com/DocRaptor/docraptor-csharp/releases using DocRaptor.Client; using DocRaptor.Model; using DocRaptor.Api; using System; using System.IO; class DocRaptorExample { static void Main(string[] args) { DocApi docraptor = new DocApi(); // this key works in test mode! docraptor.Configuration.Username = "YOUR_API_KEY_HERE"; try { Doc doc = new Doc( name: "example-report", test: true, // test documents are free but watermarked documentType: Doc.DocumentTypeEnum.Xls, documentContent: "", // the .NET agent requires documentContent be set documentUrl: "https://docraptor.com/examples/report.html" // javascript: true, // princeOptions: new PrinceOptions( // media: "print", // @media 'screen' or 'print' CSS // baseurl: "https://yoursite.com" // the base URL for any relative URLs // ) ); byte[] document = docraptor.CreateDoc(doc); File.WriteAllBytes("example-report.xls", document); Console.WriteLine("Successfully created example-report.xls!"); } catch (DocRaptor.Client.ApiException error) { Console.Write(error.ErrorContent); } } }
This snippet really works. and give it a go!
Choose a different example:

Try making a PDF or Excel file

Copy and paste in your own HTML, or select and edit one of our sample documents.

  1. Invoice <!DOCTYPE html> <html> <head> <title>DocRaptor Invoice For Super Best Client</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css" /> <script src="https://use.typekit.com/gxo7nof.js" type="text/javascript"></script> <script type="text/javascript">try{Typekit.load();}catch(e){}</script> <style type="text/css"> /* setup the page */ @page { size: US-Letter; margin: 0 0 35mm 0; background: #ffffff; } /* setup the footer */ @page { @bottom { content: flow(footer); } } footer { flow: static(footer); } body { border-top: 10px solid #3877B1; font-family: "myriad-pro-1", "myriad-pro-2", sans-serif; } #container { margin: 0 auto; } header, #main { margin: 15mm; } header { margin-top: 5mm; border-bottom: 1px solid #7E7E7E; padding-bottom: 5mm; } .seller, .status{ float: left; } .buyer { float: right; } .seller { width: 50%; } .buyer { max-width: 30%; } .brand { font-weight: bold; font-size: 30px; color: #333; padding: 10px 0 2px; overflow: auto; } .brand span, .brand img { float: left; } .brand span { display: block; margin: 8px 0 0 5px; } .seller address { clear: both; display: block; padding-left: 65px; ont-size: 10pt; line-height: 12pt; color: #262626; } .seller address span { display: block; } .status.paid { margin: 25pt 0 0 15pt; letter-spacing: -1pt; font-weight: bold; color: #78E400; font-size: 30pt; border: 5px solid #78E400; padding: 1pt 5pt; transform: rotate(-15deg); -ms-transform: rotate(-15deg); /* IE 9 */ -webkit-transform:rotate(-15deg); /* Safari and Chrome */ } .buyer { font-size: 9pt; line-height: 12pt; margin-top: 30pt; color: #262626; } .buyer h2 { font-weight: bold; font-size: 11pt; } .buyer span { display: block; } /* main */ table { width: 100%; } th { font-size: 8pt; color: #919191; line-height: 14pt; text-align: left; padding-left: 10pt; border-bottom: 1px solid #D6D6D6; } th:last-child, td:last-child { width: 20%; } th:last-child { padding-left: 10mm; } td { padding: 10pt; border-bottom: 1px solid #D6D6D6; } td h4 { font-weight: bold; font-size: 12pt; } td .description { font-size: 9pt; line-height: 14pt; } td.price { vertical-align: middle; font-size: 12pt; font-weight: bold; text-align: right; } tr:nth-child(odd) td{ background: #F1F1F1; } #notes { font-size: 9pt; color: #7E7E7E; line-height: 14pt; font-style: italic; margin-top: 4mm; padding: 3mm; float: left; } #totals{ padding: 3mm; float: right; text-align: right; font-size: 12pt; color: #7E7E7E; line-height: 16pt; } /* footer */ footer { text-align: center; } footer p { background: #F3F3F3; color: #888; text-align: center; font-size: 8pt; line-height: 12pt; padding: 7mm 0; margin-top: 2mm; } .clearfix{ clear: both; } </style> </head> <body> <div id="container"> <header> <div class="seller"> <h1 class="brand"> <img src="https://docraptor.com/samples/docraptor-logo.svg" width="60" height="43" /> <span>DocRaptor</span> </h1> <address> 407 Fulton ST STE 103<br /> Indianapolis, IN 46202-3758 <span class="email">support@docraptor.com</span> </address> </div> <div class="status paid">PAID</div> <div class="buyer"> <h2>Billed To</h2> Super Best Client <span class="email">superbestclient@example.com</span> <span class="date">January 20, 2017</span> </div> <div class="clearfix"></div> </header> <div id="main"> <table> <thead> <tr> <th class="title">Summary</th> <th class="price">Price</th> </tr> </thead> <tbody> <tr> <td> <h4>Max Plan</h4> <p class="description">December 20, 2016 - January 20, 2017</p> </td> <td class="price"><span class="price">$149.00 USD</span></td> </tr> <tr> <td> <h4>Document Overage</h4> <p class="description">2 docs @ $.39</p> </td> <td class="price"><span class="price">$0.78 USD</span></td> </tr> </tbody> </table> <p id="notes"> This charge will appear on your credit card statement as "DOCRAPTOR.COM". </p> <div id="totals"> <p>Total: <span class="price">$149.78 USD</span></p> <p>Due: <span class="price">$0.00 USD</span></p> </div> </div> <footer> <img alt="Expected Behavior Logo" height="34" src="https://docraptor.com/samples/expected-behavior-logo.svg" width="150" /> <p>DocRaptor is made and supported by Expected Behavior, LLC<br>1-866-991-3746 | 407 Fulton ST STE 103, Indianapolis, IN 46202-3758 | support@docraptor.com</p> </footer> </body> </html>
  2. eBook <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <base href="https://docraptor.com/"> <title>Five Things You Should Know About HTML5 - Dive Into HTML5</title> <link rel="stylesheet" href="/samples/diveintohtml5.screen.css"> <style> h1:before{content:"Introduction:"} h2{text-align:left;text-transform:inherit} </style> <link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="/samples/diveintohtml5.mobile.css"> </head> <body> <p>You are here: <a href="https://web.archive.org/web/20170614100030/http://diveintohtml5.info/index.html">Home</a> <span class="u triangularBullet"></span> <a href="https://web.archive.org/web/20170614100030/http://diveintohtml5.info/table-of-contents.html#introduction">Dive Into <abbr>HTML5</abbr></a> <span class="u triangularBullet"></span> <h1><br>Five Things You Should Know About HTML5</h1> <p id="toc">&nbsp; <p class="a rotatedFloralHeartBullet"> <h2 id="one">1. It&rsquo;s not one big thing</h2></p> <p style="float:right;margin:0 0 1.75em 1.75em"><img src="http://diveintohtml5.info/i/video.png" alt="[mock video player]" width="226" height="166"></p> <p>You may well ask: &ldquo;How can I start using <abbr>HTML5</abbr> if older browsers don&rsquo;t support it?&rdquo; But the question itself is misleading. <abbr>HTML5</abbr> is not one big thing; it is a collection of individual features. So you can&rsquo;t detect &ldquo;<abbr>HTML5</abbr> support,&rdquo; because that doesn&rsquo;t make any sense. But you <em>can</em> detect support for individual features, like canvas, video, or geolocation.</p> <p>You may think of <abbr>HTML</abbr> as tags and angle brackets. That&rsquo;s an important part of it, but it&rsquo;s not the whole story. The <abbr>HTML5</abbr> specification also defines how those angle brackets interact with JavaScript, through the Document Object Model (<abbr>DOM</abbr>). <abbr>HTML5</abbr> doesn&rsquo;t just define a <code>&lt;video&gt;</code> tag; there is also a corresponding <abbr>DOM</abbr> <abbr>API</abbr> for video objects in the <abbr>DOM</abbr>. You can use this <abbr>API</abbr> to detect support for different video formats, play a video, pause, mute audio, track how much of the video has been downloaded, and everything else you need to build a rich user experience around the <code>&lt;video&gt;</code> tag itself.</p> <p><a href="https://web.archive.org/web/20170614100030/http://diveintohtml5.info/detect.html">Chapter 2</a> and <a href="https://web.archive.org/web/20170614100030/http://diveintohtml5.info/everything.html">Appendix A</a> will teach you how to properly detect support for each new <abbr>HTML5</abbr> feature. <h2 id="two">2. You don&rsquo;t need to throw anything away</h2> <p style="float:left;margin:0 1.75em 1.75em 0"><img src="http://diveintohtml5.info/i/forms.png" alt="[sample form controls]" width="134" height="196"> <p>Love it or hate it, you can&rsquo;t deny that <abbr>HTML</abbr> 4 is the most successful markup format ever. <abbr>HTML5</abbr> builds on that success. You don&rsquo;t need to throw away your existing markup. You don&rsquo;t need to relearn things you already know. If your web application worked yesterday in <abbr>HTML</abbr> 4, it will still work today in <abbr>HTML5</abbr>. Period. <p>Now, if you want to <em>improve</em> your web applications, you&rsquo;ve come to the right place. Here&rsquo;s a concrete example: <abbr>HTML5</abbr> supports all the form controls from <abbr>HTML</abbr> 4, but it also includes new input controls. Some of these are long-overdue additions like sliders and date pickers; others are more subtle. For example, the <code>email</code> input type looks just like a text box, but mobile browsers will customize their onscreen keyboard to make it easier to type email addresses. Older browsers that don&rsquo;t support the <code>email</code> input type will treat it as a regular text field, and the form still works with no markup changes or scripting hacks. This means you can start improving your web forms <em>today</em>, even if some of your visitors are stuck on IE 6. <p>Read all the gory details about <abbr>HTML5</abbr> forms in <a href="https://web.archive.org/web/20170614100030/http://diveintohtml5.info/forms.html">Chapter 9</a>. <h2 id="three">3. It&rsquo;s easy to get started</h2> <p style="float:right;margin:0 0 1.75em 1.75em"><img src="http://diveintohtml5.info/i/markup-with-arrow.png" alt="[sample HTML markup]" width="234" height="202"> <p>&ldquo;Upgrading&rdquo; to <abbr>HTML5</abbr> can be as simple as changing your <i>doctype</i>. The doctype should already be on the first line of every <abbr>HTML</abbr> page. Previous versions of <abbr>HTML</abbr> defined a lot of doctypes, and choosing the right one could be tricky. In <abbr>HTML5</abbr>, there is only one doctype: <blockquote> <p><code>&lt;!DOCTYPE html&gt;</code> </blockquote> <p>Upgrading to the <abbr>HTML5</abbr> doctype won&rsquo;t break your existing markup, because <a rel="external" href="http://www.w3.org/TR/html5-diff/#absent-elements" target="_blank">obsolete elements</a> previously defined in HTML 4 will still render in <abbr>HTML5</abbr>. But it will allow you to use &mdash; and validate &mdash; new semantic elements like <code>&lt;article&gt;</code>, <code>&lt;section&gt;</code>, <code>&lt;header&gt;</code>, and <code>&lt;footer&gt;</code>. You&rsquo;ll learn all about these new elements in <a href="https://web.archive.org/web/20170614100030/http://diveintohtml5.info/semantics.html">Chapter 3</a>. <h2 id="four">4. It already works</h2> <p style="float:left;margin:0 1.75em 1.75em 0"><img src="http://diveintohtml5.info/i/rel-email.png" alt="[form field with onscreen keyboard]" width="227" height="192"> <p>Whether you want to draw on a canvas, play video, design better forms, or build web applications that work offline, you&rsquo;ll find that <abbr>HTML5</abbr> is already well-supported. Firefox, Safari, Chrome, Opera, and mobile browsers already support canvas (<a href="https://web.archive.org/web/20170614100030/http://diveintohtml5.info/canvas.html">Chapter 4</a>), video (<a href="http://diveintohtml5.info/video.html">Chapter 5</a>), geolocation (<a href="https://web.archive.org/web/20170614100030/http://diveintohtml5.info/geolocation.html">Chapter 6</a>), local storage (<a href="http://diveintohtml5.info/storage.html">Chapter 7</a>), and more. Google already supports microdata annotations (<a href="https://web.archive.org/web/20170614100030/http://diveintohtml5.info/extensibility.html">Chapter 10</a>). Even Microsoft &mdash; rarely known for blazing the trail of standards support &mdash; supports most <abbr>HTML5</abbr> features in Internet Explorer 9. <p style="float:right;margin:0 0 1.75em 1.75em"><img src="http://diveintohtml5.info/i/gears.png" alt="[Gears saying &quot;I can help&quot;]" width="125" height="75"> <p>Each chapter of this book includes the all-too-familiar browser compatibility charts. But more importantly, each chapter includes a frank discussion of your options if you need to support older browsers. <abbr>HTML5</abbr> features like geolocation (<a href="https://web.archive.org/web/20170614100030/http://diveintohtml5.info/geolocation.html">Chapter 6</a>) and video (<a href="https://web.archive.org/web/20170614100030/http://diveintohtml5.info/video.html">Chapter 5</a>) were first provided by browser plugins like Gears or Flash. Other features, like canvas (<a href="https://web.archive.org/web/20170614100030/http://diveintohtml5.info/canvas.html">Chapter 4</a>), can be emulated entirely in JavaScript. This book will teach you how to target the native features of modern browsers, without leaving older browsers behind. <h2 id="five">5. It&rsquo;s here to stay</h2> <p>Tim Berners-Lee invented the world wide web in the early 1990s. He later founded the <abbr>W3C</abbr> to act as a steward of web standards, which the organization has done for more than 15 years. Here is what the <abbr>W3C</abbr> had to say about the future of web standards, in July 2009: <blockquote cite="http://www.w3.org/News/2009#item119"> <p>Today the Director announces that when the <abbr>XHTML</abbr> 2 Working Group charter expires as scheduled at the end of 2009, the charter will not be renewed. By doing so, and by increasing resources in the <abbr>HTML</abbr> Working Group, <abbr>W3C</abbr> hopes to accelerate the progress of <abbr>HTML5</abbr> and clarify <abbr>W3C</abbr>&rsquo;s position regarding the future of <abbr>HTML</abbr>. </blockquote> <p><abbr>HTML5</abbr> is here to stay. <a href="https://web.archive.org/web/20170614100030/http://diveintohtml5.info/past.html">Let&rsquo;s dive in</a>. <p class="a rotatedFloralHeartBullet"> <div class="pf"> <h4>Did You Know?</h4> <div class="moneybags"> <blockquote><p>In association with Google Press, O&rsquo;Reilly is distributing this book in a variety of formats, including paper, ePub, Mobi, and <abbr>DRM</abbr>-free <abbr>PDF</abbr>. The paid edition is called &ldquo;HTML5: Up &amp; Running,&rdquo; and it is available now. <p>If you liked this introduction and want to show your appreciation, you can <a href="http://diveintohtml5.info/http://www.amazon.com/HTML5-Up-Running-Mark-Pilgrim/dp/0596806027?ie=UTF8&amp;tag=diveintomark-20&amp;creativeASIN=0596806027">buy &ldquo;HTML5: Up &amp; Running&rdquo; with this affiliate link</a> or <a href="http://diveintohtml5.info/http://oreilly.com/catalog/9780596806033">buy an electronic edition directly from O&rsquo;Reilly</a>. You&rsquo;ll get a book, and I&rsquo;ll get a buck. I do not currently accept direct donations. </blockquote> </div> </div> <p class="c">Copyright MMIX&ndash;MMXI <a href="https://web.archive.org/web/20170614100030/http://diveintohtml5.info/about.html">Mark Pilgrim</a></p> </body> </html>
  3. Analysis <table> <tr> <th>Cohort</th> <th>Acquisition</th> <th>Activation</th> <th>Retention</th> <th>Referral</th> <th>Revenue</th> </tr> <tr> <th>Week 1</th> <td>12</td> <td>10</td> <td>10</td> <td>4</td> <td>$100</td> </tr> <tr> <th>Week 2</th> <td>14</td> <td>10</td> <td>8</td> <td>1</td> <td>$121</td> </tr> <tr> <th>Week 3</th> <td>24</td> <td>17</td> <td>11</td> <td>11</td> <td>$1121</td> </tr> </table>

Ready to get started? Try DocRaptor for free with unlimited test documents.