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
- RestSharp - 105.2.3 or later
- Json.NET - 7.0.0 or later
- JsonSubTypes - 1.2.0 or later
Installation
Command line:
nuget.exe install DocRaptor
Install-Package DocRaptor
Download DLLs: get DocRaptor.dll
from GitHub
Basic Usage
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);
}
}
Next Steps
- Optionally store and get a URL for your converted document with document hosting
- View more code examples with error handling, asynchronous creation, file saving, and document hosting.
- Perfect your document styling with our knowledge base, style and formatting reference, and API reference. Easily add headers and footers, page breaks, 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.