.Net Pdf Generator

Methods

Configuration

pdfGenerator.Config.SetErrorMode(Utils.Enumerators.ErrorMode.Default);

By default the generator will fail silently, set the error mode to ErrorMode.Verbose to throw exceptions.

 

These methods are used to pass through command line arguments/switches to the tool:

pdfGenerator.Config.AddOption("[key]")

Include a single key such as AddOption("-g") or AddOption("--greyscale")

pdfGenerator.Config.AddOption("[key]", "[value]")

Include a key value pair such as AddOption("-s", "A4"")

pdfGenerator.Config.SetOptions("[list of WkHTML arguments]")

Pass in a full list of command arguments, SetOptions("-g -s A4 --quiet")

A full list of arguments can be found here http://wkhtmltopdf.org/usage/wkhtmltopdf.txt

 

Setting a source

These methods allow you to add URL's or direct HTML/Text input as the source of the PDF, the methods can be chained to add multiple sources.

pdfGenerator.AddHTMLSource("[source text/html]")

pdfGenerator.AddSource("[url]")

 

Generating a PDF

These methods generate a PDF from the supplied sources and return the results.

GeneratePDF("[filename.pdf]")

By default the result will be returned as a byte array.

GeneratePDF<PdfResult>("[filename.pdf]")

This will return the results as a PdfResult which contains additional information such as the time taken to generate the PDF

comments powered by Disqus