using wkhtmltopdf with D

Nicholas Wilson iamthewilsonator at hotmail.com
Mon May 28 02:26:37 UTC 2018


On Monday, 28 May 2018 at 01:28:10 UTC, Dr.No wrote:
> I'm trying to use wkhtmltopdf[1] with D. I converted this 
> header[2] with little modification using htod tool which 
> resulted in this[3].
> The libray is passed to link using:
>
> pragma(lib, "wkhtmltox.lib");
> (that file is in wkhtmltopdf\lib folder)
>
>
> and the module imported with:
> import pdf;
>
> but it crashes right upon the start with a SEGFAULT:
>
> void main()
> {
> 	
> 	wkhtmltopdf_global_settings * gs;
> 	wkhtmltopdf_object_settings * os;
> 	wkhtmltopdf_converter * c;
> 	
> 	/* Init wkhtmltopdf in graphics less mode */
> 	wkhtmltopdf_init(0);
> }
>
> toolset I'm using:
>
> DUB version 1.8.1, built on Apr 29 2018
> LDC - the LLVM D compiler (1.9.0):
>   based on DMD v2.079.1 and LLVM 5.0.1
>   built with LDC - the LLVM D compiler (1.9.0)
>   Default target: i686-pc-windows-msvc
>   Host CPU: skylake
>   http://dlang.org - http://wiki.dlang.org/LDC
>
> What's likely the reason of the crash? mismatch between D and C 
> memory alignment?
>
> [1]: https://wkhtmltopdf.org/index.html
> [2]: 
> https://github.com/clowder/wkhtmltopdf/blob/master/src/lib/pdf.h
> [3]: https://pastebin.com/SrtDUhPf

You're missing const on a couple of the pointer parameters, but 
if it segfaults on calling a function then my question is: is 
wkhtmltox.lib a library that was generated to link to a dynamic 
library (is there an associated .dll)? If so you need to ensure 
that it is loaded and the function pointers are initialised.


More information about the Digitalmars-d-learn mailing list