Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: HTML to PDF Conversion using WkHtmlToXSharp and wwDotNetBridge

$
0
0
Re: HTML to PDF Conversion using WkHtmlToXSharp and wwDotNetBridge
VFP and .NET Interop
Re: HTML to PDF Conversion using WkHtmlToXSharp and wwDotNetBridge
May. 20, 2013
03:33 am
3SF07MDR7Show this entire thread in new window
Gratar Image based on email address
From:Rick Strahl
To:Abhay Sobti

ILMerge is rarely a good idea. It has all sorts of side effects. You should try to get things working without ILMerge to rule out that possibility that it's causing the problems.

+++ Rick ---


I agree with you. But strangely, WkHtmlToXSharp.dll is a famous library. Could the problem have anything to do with ILM?

Abhay

That sounds like a resource leak somewhere in the library rather than a problem in wwDotnetBridge. wwDotnetBridge just reports ANY errors that occur in any COM call whether they occur in the wwDotnetBridge code itself OR the code that runs in the component you're calling.

This error seems to emanate from from the actual component (especially since it appears to be pointing at some native code which that library calls).

+++ Rick ---



Hi everyone,

I am using the wkHtmlToXSharp Dotnet library to convert HTML pages to PDF files. The DLL is used using the wwDotNetBridge code. All works well for the first few conversions, but randomly, the DLL crashes with the following error, when the InvokeMethod :

"OLE iDispach exception code 0 from wwDotNetBridge attempted to read or write protected memory. This is often an undication that memory corrupt"

Just to brief everyone, we use a ssWkHtmlToXSharp.dll file for the conversion which is created using the following ilmerge command.

"D:\Program Files\Microsoft\ILMerge\ilmerge.exe" /keyfile:WkHtmlToXSharp.Snk /target:library /out:ssWkHtmlToXSharp.dll Common.Logging.dll WkHtmlToXSharp.dll

The fox Code for the object that calls the wwDotNetBridge object is :

DEFINECLASS html2Pdf AS Relation oBridge = null oConvertor = null cErrorMsg = "" lNoInterface = .F. && If set to .T., user-interface, like messages are not shown.FUNCTIONInit()IFISNULL(App.oBRidge)App.oBridge = NEWOBJECT("wwDotNetBridge","\shcommon\wconnect\classes\wwDotNetBridge.prg","",[V4])ENDIFTHIS.oBridge = App.oBridge*-------------------------------------------------------------------------------------------------- THIS.oBridge.LoadAssembly("ssWkHtmlToXSharp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a62b1b93e623d45b")THIS.oConvertor = THIS.oBridge.CreateInstance("WkHtmlToXSharp.WkHtmlToPdfConverter")IFISNULL(THIS.oConvertor)THIS.cErrorMsg = "Error: Reported from Html2Pdf object:;;" + THIS.oBridge.cErrorMsgIF NOT THIS.lNoInterface =WMESS(THIS.cErrorMsg)ENDIFENDIFENDFUNCFUNCTION GenPdf(m.cSourceHtml , m.cTargetPdf)PRIVATE ALL EXCEPT APP*THIS.cErrorMsg = ""* Does the source file Exist?IF !FILE(m.cSourceHtml)THIS.cErrorMsg = "File " + ALLTRIM(m.cSourceHtml) + " does not exist."RETURN .F.ENDIF* If PdfFile not specified the Html source file path and name will be the PDF file NameIFVARTYPE(m.cTargetPdf)="L" m.cTargetPdf = FORCEEXT(m.cSourceHtml,"pdf")ENDIFERASE (m.cTargetPdf) =STRTOFILE(THIS.oBridge.InvokeMethod(THIS.oConvertor, "Convert", FILETOSTR(m.cSourceHtml)), m.cTargetPdf)ENDFUNCENDDEFINE

I am scratching my head for a long time and just cannot figure out the reason for this. Any help will be eternally appreciated.

Thanks a Ton

Abhay






Rick Strahl
West Wind Technologies


from Maui, Hawaii

Making waves on the Web


Viewing all articles
Browse latest Browse all 10393

Trending Articles