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 Aug 30, 2024 9:34 am

Hi,

I want to evaluate Spire PDF for HTML to PDF. I followed the instructions on the C#/VB.NET: Convert HTML to PDF page.

and downloaded the Nuget Package SpirePDF (version 10.8.1), the x64 plugin, changed the path to plugin and set the target to x64.

When I try to run the "Convert a URL to PDF with QT Plugin" example it I get the error:
QCoreApplication::applicationDirPath: Please instantiate the QApplication object first
QObject::startTimer: Timers can only be used with threads started with QThread

So, I tried switching to the example "Convert a URL to PDF Without Plugin" and got a build error:
Spire.Pdf.HtmlConverter does not exist in the namespace Spire.PDF

I'm running .NET8.

Any ideas to why I'm getting these errors?

TheMegaLoser
 
Posts: 2
Joined: Wed Jun 01, 2016 11:25 am

Mon Sep 02, 2024 8:06 am

Hello,

Thanks for your inquiry.I tested the same version and found that the same warning message as yours did appear when using the plugin. Please note that although there are warning messages, they do not affect the normal generation of PDF documents. Additionally, the error build messages that occur when testing without using plugins are due to the old methods no longer being used and maintained in the new version.

Meanwhile, we suggest using the following new method to convert HTML to PDF. You can install our Spire.PDFfor.NETStandard 10.8.1(https://www.nuget.org/packages/Spire.PDFfor.NETStandard/10.8.1). to test on your NET 8.0. If you have any other questions, please feel free to write to me.

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 164
Joined: Mon Jul 15, 2024 5:40 am

Tue Sep 03, 2024 9:40 am

Hi,

thanks for the reply.

I am using 10.8.1 already. I am unsure what the new method is though.

If I click on you link below, then HTML to PDF lower on the page it takes me to the code that's writes the error build messages.

If I click on you link below, then on examples, CS, Conversion, then HTMLToPDFWithNewPlugin.cs I get a build error as well as that references the Spire.Pdf.HtmlConverter namespace that doesn't exist.

Where can I find a working example of the new method?

Thanks in advance,
Andreas

TheMegaLoser
 
Posts: 2
Joined: Wed Jun 01, 2016 11:25 am

Wed Sep 04, 2024 1:29 am

Hello,

Thanks for your inquiry.You can refer to the following code or click here to use the new method.If you have any other questions, please feel free to write to me.
Code: Select all
//The installation location of your Chrome browser
string chromeLocation = baseDirectory +"chrome.exe";
ChromeHtmlConverter converter = new ChromeHtmlConverter(chromeLocation);
ConvertOptions options = new ConvertOptions();
options.Timeout = 10 * 1000;
options.PageSettings = new PageSettings()
{ PaperWidth = 8.77, PaperHeight = 6.20, MarginBottom = 0, MarginTop = 0, MarginLeft = 0, MarginRight = 0 }
;
converter.ConvertToPdf("https://www.e-iceblue.cn/", "HtmlToPdf.pdf", options);

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 164
Joined: Mon Jul 15, 2024 5:40 am

Return to Spire.PDF

cron