|
Rank: Member Groups: Member
Joined: 10/10/2011 Posts: 19
|
Greetings! I'm trying to use EO.pdf in SQL server 2008 using SQL CLR but so far no good... I inserted the assemblies it relies on (System.Drawing.dll and System.Windows.Forms.dll) and after that I created the assembly EO.Pdf.dll. Up until here everything went smooth but the problem started when I tried to make a simple assembly to test if it was working where I get the following EO.Pdf.HtmlToPdfException: Convertion failed. Failed to initialize conversion. Am I missing something? Does it not support SQL CLR? Sample code I used to test:
Code: C#
MemoryStream ms = new MemoryStream();
HtmlToPdf.ConvertHtml(@"<html><body>hello<br/><b>hello</b></body></html>", ms);
Thanks for your time, Ricardo Mendes
|
|
Rank: Member Groups: Member
Joined: 10/10/2011 Posts: 19
|
Update: I tried the 3.0.78.2 you sent me some days ago that gave me a different message: Quote:Convertion failed. can not be loaded from a byte array. And I also got the stack trace: Quote: at EO.Pdf.HtmlToPdfException.b(Exception A_0) at EO.Pdf.Internal.kl.a() at EO.Pdf.HtmlToPdf.a(kl A_0) at EO.Pdf.HtmlToPdf.ConvertHtml(String html, PdfDocument doc, HtmlToPdfOptions options) at EO.Pdf.HtmlToPdf.ConvertHtml(String html, Stream stream, HtmlToPdfOptions options) at EO.Pdf.HtmlToPdf.ConvertHtml(String html, Stream stream) at Pdftester.test() Hope it helps
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, Thanks for the update. You should be able to run it fine inside SQL CLR as soon as you have sufficient permissions. That is usually a problem when impersonating is enabled. I’ve sent you a newer build, you can try to update to that build and see if it gives you a different error message about permissions. If it does, then try to off load the actual conversion to a service to bypass the permission restrictions on the hosting process (SQL server in your case): http://doc.essentialobjects.com/library/4/htmltopdf/eopdfsp.aspxIf you still get the same problem, then please try to get the whole stack trace (there should be more in InnerException) and we will see what we can find. Having that said, I would not recommend you to call HtmlToPdf inside SQL Server CLR. The reason is because ConvertHtml and ConvertUrl can potentially take a long time and you don’t want anything to run blocking for long inside SQL Server since you do not have explicitly control over SQL Server’s internal locks. For example, if SQL Server decides to keep a write lock on one of your table while calling ConvertUrl which takes 10 seconds, then that table is being locked for 10 seconds, which may cause other problems for your server. To avoid such problems, you can create another “server” process that sits there listen to conversion request and return immediately so it won’t block your SQL server. Thanks!
|
|
Rank: Member Groups: Member
Joined: 10/10/2011 Posts: 19
|
Just tried the new build but it gives me the same result: Quote: EO.Pdf.HtmlToPdfException Message:Convertion failed. can not be loaded from a byte array.
stack: at EO.Pdf.HtmlToPdfException.b(Exception A_0) at EO.Pdf.Internal.km.a() at EO.Pdf.HtmlToPdf.a(km A_0) at EO.Pdf.HtmlToPdf.ConvertHtml(String html, PdfDocument doc, HtmlToPdfOptions options) at EO.Pdf.HtmlToPdf.ConvertHtml(String html, Stream stream, HtmlToPdfOptions options) at EO.Pdf.HtmlToPdf.ConvertHtml(String html, Stream stream) at Pdftester.test()
The inner exception gives me: Quote: System.Exception Message: can not be loaded from a byte array.
stack: at EO.Pdf.Internal.ca.a(Type A_0) at EO.Pdf.Internal.ca.a(eo A_0, String A_1) at EO.Pdf.Internal.kh..ctor() at EO.Pdf.Internal.kh.a(kh A_0, List`1 A_1) at EO.Pdf.Internal.kh.b(Byte[] A_0, Int32 A_1) at EO.Pdf.Internal.kh.c(Byte[] A_0, Int32 A_1) at EO.Pdf.Internal.kh.d(Byte[] A_0, Int32 A_1) at EO.Pdf.Internal.km.a(String A_0, Boolean A_1, String A_2) at EO.Pdf.Internal.km.a()
As for the service mode it's a no go for now for security and stability reasons (aka a sysadmin being stubborn). Regarding the performance issues I agree with you but I don't have many options... I'm still figuring out other ways to do what is needed but for now this has to be a lesser evil.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
If you watch typeof(EO.Pdf.HtmlToPdf).Assembly.Location, what do you get?
Thanks!
|
|
Rank: Member Groups: Member
Joined: 10/10/2011 Posts: 19
|
An empty string...
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
That's a problem. ; ) I don't know where SQL Server is loading the DLL from, but it cannot be a ghost DLL. It has to be a real DLL with a file path.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 10/10/2011 Posts: 19
|
eo_support wrote:That's a problem. ; ) I don't know where SQL Server is loading the DLL from, but it cannot be a ghost DLL. It has to be a real DLL with a file path.
Thanks! The DLL file is stored inside the database and not in an external file ;)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
That will not work. EO.Pdf must be a physical file on disk. If you have to store you code in your database, then you can create another small DLL that calls our DLL and store that DLL in database. As long as EO.Pdf does not have a file path, you will get that "can not load from byte array" error.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 10/10/2011 Posts: 19
|
OK.
Tomorrow I'll try that.
|
|