This is a DLL and NuGet package for using DocRaptor API to convert HTML to PDF and XLSX.
- .NET 4.0 or later
- Windows Phone 7.1 (Mango)
Command line:
nuget.exe install DocRaptor
Install-Package DocRaptor
Download DLLs: get DocRaptor.dll
from GitHub
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"; // this key works for test documents
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
// 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[] 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.
We have guides for doing some of the common things:
- Headers and Footers including page skipping
- CSS Media Selector to make the page look exactly as it does in your browser
- Protect content with HTTP authentication or proxies so only DocRaptor can access them
DocRaptor has a lot of more styling and implementation options.
Stuck? We're experts at using DocRaptor so please email us if you run into trouble.
The majority of the code in this repo is generated using swagger-codegen on docraptor.yaml. You can modify this file and regenerate the client using script/generate_language csharp
.
The generated client needed a few fixes
- Pull latest master
- Merge feature branch(es) into master
script/test
- Increment version in code:
swagger-config.json
DocRaptor.nuspec
src/main/csharp/DocRaptor/Properties/AssemblyInfo.cs
src/main/csharp/DocRaptor/Client/Configuration.cs
(2 places)
- Update CHANGELOG.md
- Commit "Release vX.Y.Z"
- Push to GitHub
- Tag version:
git tag 'vX.Y.Z' && git push --tags
- Build package using
script/build
script/nuget push bin/DocRaptor.X.Y.Z.nupkg
- Verify package release at https://www.nuget.org/packages
- Open https://github.com/DocRaptor/docraptor-csharp/tags and make a new release for the version. Use the git tag as the name, CHANGELOG entries as the description, and attach
bin/*.dll
andbin/*.xml
to the release - Refresh documentation on docraptor.com
This library follows Semantic Versioning 2.0.0.