DocRaptor

Documentation

HTML-to-PDF with .NET

Test API Key: YOUR_API_KEY_HERE

Code Examples

Frameworks supported

  • .NET 4.0 or later
  • Windows Phone 7.1 (Mango)

Dependencies

Installation

Command line:

nuget.exe install DocRaptor

Package Manager Console:

Install-Package DocRaptor

Download DLLs: get DocRaptor.dll from GitHub

Usage

Below is a barebones example, more robust examples with file output and error handling, asynchronous generation, hosted documents, or asynchronous hosted documents are also available.

using DocRaptor.Client;
using DocRaptor.Model;
using DocRaptor.Api;
using System.IO;

class Example {
  static void Main(string[] args) {
    DocApi docraptor = new DocApi();
    docraptor.Configuration.Username = "YOUR_API_KEY_HERE";

    Doc doc = new Doc(
      test: true,                                                    // test documents are free but watermarked
      documentContent: "<html><body>Hello World</body></html>",      // supply content directly
      // documentUrl: "http://docraptor.com/examples/invoice.html",  // or use a url
      name: "docraptor-csharp.pdf",                                  // help you find a document later
      documentType: Doc.DocumentTypeEnum.Pdf                         // pdf or xls or xlsx
      // Javascript: true,                                           // enable javaScript processing
      // princeOptions: new PrinceOptions(
      //   media: "screen",                                          // use screen styles instead of print styles
      //   baseurl: "http://hello.com"                               // pretend URL when using document_content
      // )
    );

    byte[] createResponse = docraptor.CreateDoc(doc);
  }
}

Documents created synchronously like above are limited to 60 seconds of generation time, the asynchronous method allows up to 10 minutes.

Our styling documentation and knowledge base contain tips and guides on creating headers, footers, page numbers, table of contents, and much more.

With DocRaptor, it's fast and painless to convert HTML, CSS, and JavaScript into PDF and XLS documents with .NET. Below are working .NET examples for creating documents. Our API reference lists all the generation options and our style and formatting guide will help make it look perfect.