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 May 04, 2018 3:58 pm

Hi
I am currently evaluating product and so far so good, however..

I am trying to convert HTML to PDF.

I am unable to use the Thread as its saying "The type or namespace name 'Thread' could not be found.

I am using

using Spire.Pdf;
using Spire.Pdf.HtmlToPdf;
using Spire.Pdf.HtmlConverter;
using Spire.Pdf.Functions;
using Spire.Pdf.Graphics;

if(bd.Extension.ToLower() == ".html")
{
PdfDocument doc = new PdfDocument();
String url = bd.FullName;
Thread thread = new Thread(() =>
{ doc.LoadFromHTML(url, false, true, true); });
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
//Save pdf file.
doc.SaveToFile("sample.pdf");
doc.Close();
//Launching the Pdf file.
System.Diagnostics.Process.Start("sample.pdf");
}

Can you help?

Thanks

alexgladstones
 
Posts: 2
Joined: Fri Apr 27, 2018 10:55 am

Mon May 07, 2018 3:22 am

Dear alexgladstones,

Sorry for late reply as weekend.
The class Thread is in the namespace System.Threading, please add following reference in your project.
Code: Select all
using System.Threading;

If there is any question, welcome to get it back to us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue May 08, 2018 9:31 am

Thank you, I realise my mistake now, i was using using System.Threading.Tasks;

Thanks again

alexgladstones
 
Posts: 2
Joined: Fri Apr 27, 2018 10:55 am

Tue May 08, 2018 9:53 am

Dear alexgladstones,

Thanks for your feedback.
If there is any question, please feel free to contact us.
Have a nice day.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF