Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Jul 03, 2015 10:29 pm

Hi there,
I'm using Spire.PDf 3.4.26 for html to pdf conversion. It seems to be working fine on my local azure cloud service emulator as worker role. However, when I publish it to staging server it does not work:

It would always throw an exception saying Microsoft.smhtml dll is missing. I had to include that dll in my project as Local Copy dll. After that it does not seem to throw any exceptions. However, now spire.pdf generates an empty pdf file with evaluation warning message at the top. Doesn't matter what html string I pass to it, always generates empty file. What am I doing wrong?

dmishchenko
 
Posts: 5
Joined: Mon May 11, 2015 11:11 pm

Mon Jul 06, 2015 1:42 am

Hello,

Thanks for your inquiry.
Please try the latest version ( Spire.PDF Pack(Hot Fix) Version:3.4.27) and the new override method.
Code: Select all
LoadFromHTML(string htmlSourceCode, bool autoDetectPageBreak, PdfPageSettings setting, PdfHtmlLayoutFormat layoutFormat, bool isLoadComplete);

If you still have issue, please offer us your sample file and your code.
Please kindly note that firstly you need to compress it and upload.

Sincerely,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Mon Jul 06, 2015 6:14 pm

Thanks for a quick reply.

I'm am using the latest dll. Here is my code:

Code: Select all
...
PdfDocument doc = new PdfDocument();

var htmlLayout = new PdfHtmlLayoutFormat() { };
var pdfPageSettings = new PdfPageSettings() { };

Thread thread = new Thread(() =>
{
doc.LoadFromHTML(hmtl, true, pdfPageSettings, htmlLayout, false);                   
});

thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();

MemoryStream stream = new MemoryStream();
doc.SaveToStream(stream);

var data = Convert.ToBase64String(stream.ToArray());
..


html sample is attached. In my case, any html string produces a blank screen with word "black".

Thanks,

dmishchenko
 
Posts: 5
Joined: Mon May 11, 2015 11:11 pm

Tue Jul 07, 2015 6:50 am

Hello,

Thanks for your reply.
Please try to change the code:
Code: Select all
doc.LoadFromHTML(hmtl, true, pdfPageSettings, htmlLayout, false);

to the code below:
Code: Select all
doc.LoadFromHTML(hmtl, true, pdfPageSettings, htmlLayout, true);

If there are any questions, welcome to get it back to us.

Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Tue Jul 07, 2015 8:09 pm

I tried changing IsLoadComplete parameter to true but it cases my worker role to restart at line: thread.Join();

Unfortunately I'm unable to track the exception as my it just stops and doesn't throw any exceptions. Crashes both in local simulator and in the cloud.

Is there any specific configuration settings I need to do to make it work in azure cloud? The only thing I've done so far was setting referencing "Microsoft.mshtml" dll and setting it to "Copy Local". Anything else I need to do?

dmishchenko
 
Posts: 5
Joined: Mon May 11, 2015 11:11 pm

Wed Jul 08, 2015 9:13 am

Hello,

Thanks for your reply.
We will look into it and let you know ASAP.

Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Thu Jul 09, 2015 9:45 am

Hello,

Please try to increase the time of loading html.
htmlLayout.LoadHtmlTimeout = 200000;
In addition, please firstly delete the the far-end of the link in your txt file and try it in your cloud service, then please tell us how it goes.

Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Thu Jul 09, 2015 10:46 pm

Since i'm trying to convert email html to pdf, it contains quite a few 'trackers' like

Code: Select all
<img height="1" width="1" src="https://102.112.2O7.net/b/ss/paypalglobal/1/G.4--NS/123456?pageName=system_email_PP1469" border="0" alt="">
<img src="http://t.sidekickopen01.com/e1t/o/5/f18dQhb0S7ks8dDMPbW2n=0x6l2B9gXrN7sKj6v5dy_nW1qfXk-3LjyG0W4Xb2743LvrVvW12TrMC1k1H6H0?si=3D5704547=603316736&amp;pi=3Db3bafe70-b2e8-4006-df00-4c1dcb0fc0ef" style="display:none!important" height="1" width="1">
<img src="https://via.intercom.io/o?h=3Def32bba207362cda6ff48e4530fa23a=03d9f1ddf-1007487475" width="1" height="1" style="display: block;" alt="intercom">
<img width="0" height="0" class="mailtrack-img" src="https://mailtrack.io/trace/mail/a3e312877e1d3f7a4c7cc413cf572af5941ac4ed.png">


Those tags seem to break the conversion.

Deleting those tags didn't solve my problem thou. I've tried to set htmlLayout.LoadHtmlTimeout = 200000; and it is still stopping the service, however if I add a timeout to thread (thread.Join(60000)), it seems to not break it however still produces a blank page (no evaluation message, no "black" word either).

dmishchenko
 
Posts: 5
Joined: Mon May 11, 2015 11:11 pm

Fri Jul 10, 2015 9:03 am

Hello,

Thanks for your information.
I have noticed your issue. And I have posted the issue to our dev team. We will inform you when it is fixed. Sorry for the inconvenience.

Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Tue Aug 18, 2015 9:14 am

Hello,

Sorry to keep you waiting.
The new version of Spire.Pdf( Spire.PDF Pack Version:3.5 ) solved your issue has been released. Please download it via link below and have a try.
http://www.e-iceblue.com/Download/download-pdf-for-net-now.html

Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Thu Aug 20, 2015 9:11 am

Hello,

Have you tried the Spire.PDF Pack Version:3.5?
Has your issue been resolved?
Thanks for your feedback.

Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Mon Aug 24, 2015 4:38 pm

Hi Sweety,
I didn't have a chance to try it. Ended up using a different library for my project. Thanks for the help!

dmishchenko
 
Posts: 5
Joined: Mon May 11, 2015 11:11 pm

Tue Aug 25, 2015 3:06 am

Hello,

Please feel free to contact us, if you have any questions or needs. We are here for help.

Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Return to Spire.PDF