Making Documents with .NET
James Paden avatar
Written by James Paden
Updated over a week ago

Frameworks supported

  • .NET 4.0 or later

  • Windows Phone 7.1 (Mango)

Dependencies

Installation

Command line:

nuget.exe install DocRaptor
Install-Package DocRaptor

NuGet Package Manager (UI):

Go to Tools —> NuGet Package Manager —> Manage NuGet Packages for Solution...

Search for DocRaptor, and select and install "DocRaptor by Expected Behavior".

Download DLLs: get DocRaptor.dll from GitHub

Usage

See examples for runnable examples with file output, error handling, etc.

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

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

    Doc doc = new Doc(
      Test: true,                                                    // test documents are free but watermarked
      DocumentContent: "<html><body>Hello World</body></html>",      // supply content directly (note: this field is currently required, so just provide an empty string if URL is provided)
      // 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 - http or https prefix is required
      // )
    );

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

Docs created like this are limited to 60 seconds to render, check out the async example which allows 10 minutes.

Did this answer your question?