Hi Jean, thanks for answering. I dont think that the convention is an issue here: internally it is written in C++, but it exposes the API as simple C functions. The calls with NB work (even the callbacks).
What confuses me most is that the call to "wkhtmltopdf_set_global_setting" works while the "wkhtmltopdf_set_object_setting" does not. They have exactly the same signature and are called one after the other. First one returns proper int 1 (success) as in the non-Smalltalk example, the other one 0 which means it failed. There is no magic in the Pharo code, just simple calls. Also the non-Smalltalk example proves that the component is working. Maybe a side effect of NativeBoost itself? Looks like so far I'm lost without the help of Igor here... Thx T. Gesendet: Freitag, 23. Mai 2014 um 11:31 Uhr Von: "Jean Baptiste Arnaud" <jbaptiste.arn...@gmail.com> An: "Pharo Development List" <pharo-dev@lists.pharo.org> Betreff: Re: [Pharo-dev] NativeBoost and WKHTML I think this is because it is a C++ lib. NativeBoost cannot be used with C++ lib. It is a problem of call convention that is not the same from C to C++. As I discuss with some people it seems be a complexe problem, each C++ compiler seems have it own convention. But Igor can maybe be more accurate about that. A C wrapper to call C++, which should work. On 23 May 2014, at 02:36, Torsten Bergmann <asta...@gmx.de> wrote: Hi, as there was no responded so far I tried to track the problem deeper and did a short test client in C/C++ to verify if I can call WKHTMLTOPDF there and generate a PDF and to compare to the Pharo/NativeBoost client. Attached is the according CPP file which works and results in a PDF with the google homepage. I also additionally implemented the callback functions in the Pharo wrapper and using the error handling I noticed that the component returns "Failed loading page http:// ..." With that info I compared the C/C++ calls to the Pharo/NativeBoost calls more deeply and found out that in C/C++ the following call for an object setting works (by returning 1): // this returns 1 in C/C++ which is OK int a = wkhtmltopdf_set_object_setting(os, "page", "http://www.google.de[http://www.google.de]"); printf("object set %i",a); while in Pharo the same call fails (by returning 0): "The following call failed and returns 0 instead of 1" self setObjectSetting: 'page' to: 'http://www.google.de'[http://www.google.de'] in: os. I checked how I wrapped this API call again and again - it is fine from my side: setObjectSetting: aName to: value in: settings <primitive: #primitiveNativeCall module: #NativeBoostPlugin> ^NBFFICallout stdcall: #(int wkhtmltopdf_set_object_setting(wkhtmltopdf_object_settings* settings, char* aName, char* value)) module: 'wkhtmltox.dll' and I still have no idea why it fails. Especially because "wkhtmltopdf_set_object_setting" function is not different from "wkhtmltopdf_set_global_setting" which is exactly the same way wrapped, works and returns 1 in exactly the same example. I would really appreciate if someone could have a second look... To reproduce on Windows: 1. Download the 32 bit version of WKHTML from http://wkhtmltopdf.org[http://wkhtmltopdf.org] and install it 2. Copy the "wkhtmltox.dll" to either the folder of the VM executable or the Windows directory so it can be found 3. Load the package WKHTML2PDF-Core-TorstenBergmann.7 from http://smalltalkhub.com/#!/~TorstenBergmann/WKHTML2PDF[http://smalltalkhub.com/#!/~TorstenBergmann/WKHTML2PDF] into Pharo 3.0#30848 4. Check the Transcript while evaluating: WKPDFLibrary example One can see that within this code #setObjectSetting:to:in: fails while #setGlobalSetting:to:in: works. Maybe I just do not see the obvious. Help is appreciated. Thanks in advance! bye T. <main.cpp> Best Regards Jean Baptiste Arnaud jbaptiste.arn...@gmail.com[jbaptiste.arn...@gmail.com]