• Stars
    star
    239
  • Rank 168,763 (Top 4 %)
  • Language
    C#
  • Created almost 14 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

C# wrapper wrapper (using P/Invoke) for the excelent Html to PDF conversion library wkhtmltopdf library.

This is a C# wrapper (using P/Invoke) for the excellent Html to PDF conversion library wkhtmltopdf.

Build status

PREREQUISITES

The embedded wkhtmltopdf project project requires Visual C++ 2015 Redistributable (x86) to be installed on the machine at runtime. You can grab it here from the Microsoft website.

CURRENT STATUS & LIMITATIONS

I've been using it in production since Q4/2010, and it has worked fine so far, so we might say it's almost 'production ready'..

The way I'm using the component is from a back office windows service which handles html->pdf conversion as part of some workflows initiated by users from a web application, so, the web application does not directly call WkHtmlToXSharp, but instead sends a message thru NServiceBus to an independent service which handles (among other tasks) generation of a PDF from Html, a Pdf document which it's later made available to our user thru the web application..

As I said, it is working quite nicely, however, I think I should advise you about the current limitations of the API:

  • Concurrent conversions: The component exposes two main conversion classes 'WkHtmlToPdfConverter' & 'MultiplexingConverter', both serving as a mean to convert from html to pdf, WkHtmlToPdfConverter it's a plain OO wrapper against wkhtmltox.dll's API, but, due to an wkhtmltox.dll's limitation, all calls to it's API should be made from the same thread, which can be a problem on a web application. To somewhat avoid such a limitation I have defined a class named 'MultiplexingConverter' which uses and internally created thread to perform conversions serializing calls to the underlaying C library within such thread.

The API it's exactly the same one as WkHtmlToPdfConverter exposes, it is just a wrapper which handles (and hides) complexities involved in using the same thread for all calls. Also, this imposes a performance hit (as conversions are not really run concurrently, but serialized under a single 'proxy' thread), so if your application is in the need of massive concurrent conversions, this might be a problem.

  • No html to image conversions yet: Currently the API only supports Html->Pdf conversions, although wkhtmltox.dll supports html->image too.. While implementing WkHtmlToImage should be pretty easy, it's still on TODO due to time constraints.

  • No 64bits on windows: No native 64bit windows dll is available from the wkhtmltopdf project, and even I tried and built it by myself, the produced component worked pretty flawlessly, probably due to limitations on current gnu toolchain (or even qt) on windows 64.. so all this means there's no support for running on 64bit-only .Net environments.

    Currently there are two possible workarounds:

    1. Build your projects linking with WkHtmlToXSharp.dll as 'x86' instead of 'AnyCpu'.

    2. Or run your application on a 32bit-only application pool on IIS.

  • Normal P/Invoke restrictions: This assembly uses P/Invoke to call wkhtmltox.dll, so normal restrictions deriving from using P/Invoke apply..

As a final note, I should note that when using this component there's no need to download nor install wkhtmltox.dll, as native .dll/.so files needed are embedded into WkHtmlToXSharp.dll and they are deployed automatically the first time a conversion is performed.

This makes the dll bigger (even if native dll's are embedded as gzipped resources), but this makes things much more fun & easier.. ;) As the embedded dll is written to disk, your project will need write permissions to the directory it's installed in.

  • No ASP.NET/IIS Support: This has to do with the way IIS manages underlaying threads, and application pools. IIS instantiates & re-cycles pools and AppDomains from time to time, and this causes non-managed resources used by this library to not be released properly.

More Repositories

1

LumiSoft.Net

LumiSoft.Net clone repo with mainly mono (and other minor issues) bug fixes. (Original project's url: http://www.lumisoft.ee)
C#
80
star
2

Topshelf.Linux

Topshelf extensions allowing compatibility with mono/linux.
C#
42
star
3

kannel

kannel SMS/WAP Gateway
C
37
star
4

EPPlus

EPPlus fork fixing mono problems.
C#
29
star
5

AberrantSMPP

An SMPP client library for Mono/.Net (Based originally on RoamingSMPP, which is not maintained anymore)
C#
21
star
6

kannel-opensmppbox

kannel OpenSMPP Proxy
Shell
20
star
7

kannel-sqlbox

DB-Based Kannel Box for message queueing.
Shell
8
star
8

signserver

svn2git clone of signserver's source repository
Java
6
star
9

zfs-cluster

Scripts & Resources to setup a ZFS storage cluster using RedHat Cluster services.
Shell
4
star
10

BasicAuthDotNet

A simple HTTP Basic authentication module (IHttpModule) for ASP.NET/Mono.
C#
4
star
11

FreeSwitchSharp

FreeSwitch's ESL & Managed libraries for .Net
C#
4
star
12

yada

Fork of yada (yet another database abstraction)
2
star
13

igb

Intel IGB Linux Driver custom changes & workarounds.
C
2
star
14

Owin.OAuthGeneric

A generic OAuth provider for Microsoft.Owin
C#
2
star
15

openbsd-src

OpenBSD src mirror
C
2
star
16

debian11-aufs

Addon of aufs kernel module for debian 11 (bullseye)
C
2
star
17

cdr_yada

Fork of cdr_yada: A call detail recording (CDR) module for asterisk and is used to store records to any database yada supports (currently MySQL, Oracle, PostgreSQL, SQLite3). If the database is not available, it can queue records to both memory and disc for later playback without worry of losing records.
2
star
18

nojava-ipmi-kvm-dockers

JavaScript
1
star
19

SafeHtmlSharp

A simple library to validate HTML against un-safe code, xss, etc.
1
star
20

Mono.CairoWarp

Extensions to Mono.Cairo to perform image/path warping.
C#
1
star
21

homer

Clone of http://www.sipcapture.org/ with my own fixes and improvements.
PHP
1
star
22

ScreenPostDemo

ScreenShot POST-ing demo
C#
1
star
23

svnrevisionlabeller

Fork of CruiseControl.Net's svnrevisionlabeller plugin.
C#
1
star
24

OpenBoot

OpenBoot clone
Forth
1
star
25

wkhtmltopdf-qt

Clone of https://git.gitorious.org/qt/antializes-qt.git
C++
1
star
26

EFLinqSplitDemo

A demo for different options to handle lookups by an array of values using EF/Linq reducing the amount of different queries/plans in use.
TSQL
1
star
27

debian9-aic94xx

Machinery in order to build an AIC94xx hotfix driver package for Debian-9.x
Shell
1
star
28

AsteriskDotNet

My own asterisk-dotnet.sf.net git clone..
C#
1
star