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.

Tue Jan 05, 2016 1:47 pm

Hi,
I am using Free pdf library for .NET v3.2. I am using it to convert a html page to pdf. But in the pdf the HTML styles are lost. These styles are applied to the HTML using a css file.

I am using the .NET 2.0 dlls in my project and this is the code that I am using

Dim doc As New PdfDocument
Dim url = "my URL"
doc.LoadFromHTML(url, False, True, True)
Dim path As String = Server.MapPath("Test.pdf")
doc.SaveToFile(path)
doc.Close()

I also attaching the screenshot of the HTML and the generated pdf.

Please let me know if I am missing a setting which will retain the styles in the HTML.

Thank you,
Ashish Pednekar

pednekar
 
Posts: 3
Joined: Wed Oct 28, 2015 3:15 pm

Wed Jan 06, 2016 8:36 am

Dear Ashish,

Thanks for your inquiry.
Please use new method to convert HTML to PDF.
http://www.e-iceblue.com/Tutorials/Spir ... lugin.html
If your issue still happens, please provide us your HTML and css file to help us do an investigation.

Best Regards,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Wed Jan 06, 2016 2:38 pm

Thank you Betsy. So I copied the 'plugins' folder in my bin directory (the directory where my spire.pdf.dll is). When I run the application I get error the plugin was not found. Just to make sure I am using .NET 2.0. Is this plugin only for .NET 4.0?

pednekar
 
Posts: 3
Joined: Wed Oct 28, 2015 3:15 pm

Thu Jan 07, 2016 1:59 am

Dear Pednekar,

Thanks for your feedback.
Please try to use following method to specify the Plugin Path directly.
Code: Select all
Spire.Pdf.HtmlConverter.Qt.HtmlConverter.PluginPath = @"E: \PdfTest\bin\Debug";


Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Thu Jan 07, 2016 3:53 am

Hi Betsy,
Thank you for your reply. I was able to get the plugin to work but the pdf conversion is erratic. The plugin works for 2 out 10 times. I have attached 2 samples of pdf that was generated of the same page. The 'working.pdf' shows when the pdf was successfully generated and the 'not-working.pdf' shows when the plugin fails. I have also attached the html and css file for your perusal.

I will really appreciate if you can help me with this. The plugin generates two different results even when nothing from code side has been changed.

Thank you,
Ashish

pednekar
 
Posts: 3
Joined: Wed Oct 28, 2015 3:15 pm

Thu Jan 07, 2016 8:55 am

Dear Ashish,

Thanks for your feedback.
I have tested your scenario many times, every time it works fine. Please tell me your OS information( e.g. Win7 64bit), and did you use a multi-thread?

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Fri Jan 08, 2016 8:08 am

Dear Ashish,

Has your issue been resolved ? If not, please tell me your OS information( e.g. Win7 64bit), and did you use a multi-thread?

Sincerely,
Betsy
E-iceblue
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Wed Jan 13, 2016 11:53 pm

Try to set your style as !important

example:

color: red !important;

Works for me :)

jfbertrand
 
Posts: 2
Joined: Mon Jan 11, 2016 5:55 pm

Return to Spire.PDF