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.

Thu Jan 27, 2022 10:00 am

In our MVC application, we used spire pdf successfully but currently, I am using .Net core 5.0 and I have downloaded a version(7.8.9) of dll, and using this dll I am trying to generate PDF from HTML. But getting below error.
1. The type or namespace name 'PdfHtmlLayoutFormat' could not be found (are you missing a using directive or an assembly reference?)
2. CS1061 'PdfDocument' does not contain a definition for 'LoadFromHTML' and no accessible extension method 'LoadFromHTML' accepting a first argument of type 'PdfDocument' could be found (are you missing a using directive or an assembly reference?)

Can you please guide me?

sajalntoo
 
Posts: 14
Joined: Thu Jan 27, 2022 7:07 am

Thu Jan 27, 2022 10:12 am

Hello,

Thanks for your inquiry!

First, the "PdfHtmlLayoutFormat" class need to import Spire.Pdf.HtmlConverter namespace. Please add "using Spire.Pdf.HtmlConverter;" in your using imports.

For the second issue. Our LoadFromHTML method does not have a first argument of type 'PdfDocument', as the following screenshot shows, you need to pass a string which include HTML code or your HTML URL as the first argument. Hope you can understand.

LoadFormFile.png


Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Thu Jan 27, 2022 10:24 am

Please see the below code.

sajalntoo
 
Posts: 14
Joined: Thu Jan 27, 2022 7:07 am

Thu Jan 27, 2022 10:52 am

Hi,
Should I make any changes?
Or the DLL is right for .net core 5.0?

sajalntoo
 
Posts: 14
Joined: Thu Jan 27, 2022 7:07 am

Fri Jan 28, 2022 6:53 am

Hello,

Thanks for sharing more information!

Sorry that I ignored that you were using .NET 5.0 last post. Kindly note that we have removed "PdfHtmlLayoutFormat" and "LoadFromHTML" from dlls of net core since it is out of supports. And now, only the dlls for .net Framework keep these methods.

If you want to convert the HTML to the PDF in .NET5.0, I just recommend that you can use the New Plugin method to achieve it by referring to the following article: Convert HTML to PDF with New Plugin. Hope you can understand.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Fri Jan 28, 2022 7:04 am

@Marcia.Zhou Does this support web applications?

sajalntoo
 
Posts: 14
Joined: Thu Jan 27, 2022 7:07 am

Fri Jan 28, 2022 8:54 am

Hello,

Yes, this method supports web application. You can put the plugins folder to the path you want, make sure that your application has permission to visit it, and then use Spire.Pdf.HtmlConverter.Qt.HtmlConverter.PluginPath = "your path"; to set path before converting.

If you have any question during your testing, just feel free to contact us.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Fri Jan 28, 2022 12:22 pm

I have followed the way and got the error.

"The type initializer for 'Spire.Pdf.HtmlConverter.Qt.Proxy' threw an exception."

Any suggestion?

sajalntoo
 
Posts: 14
Joined: Thu Jan 27, 2022 7:07 am

Sat Jan 29, 2022 2:25 am

Hello,

I simulate a project but did not reproduce the issue you mentioned. Here I attached my test project, and the code for converting is in HomeController.cs. Please run it on your side, and if the issue did not reproduce with my project, please provide us with a sample project which could reproduce your issue, your system information (E.g. Win7, 64 bit) and region setting (E.g. China, Chinese) for reference. Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon Jan 31, 2022 5:53 am

I was able to generate the PDF. Thanks for your support

sajalntoo
 
Posts: 14
Joined: Thu Jan 27, 2022 7:07 am

Mon Jan 31, 2022 5:55 am

Hello,

You are welcome.

If you encounter other issues related to our products in the future, please feel free to contact us.

Have a nice day!

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Mon Jan 31, 2022 10:17 am

can you guide me how to download the pdf file in the browser

sajalntoo
 
Posts: 14
Joined: Thu Jan 27, 2022 7:07 am

Tue Feb 01, 2022 9:03 am

Hello,

Thank you for your inquiry.
Download the generated PDF file from the browser, save the file as a stream, and then write the stream to the file. Please refer to the code below:
Code: Select all
//save as stream
pdfDocument.SaveToStream(stream, FileFormat.PDF);
//write to file
File.WriteAllBytes(resultFilePath, stream.ToArray());

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Tue Feb 01, 2022 1:34 pm

Though it was working and I have put the folder "plugins" under the same folder of Spire.Pdf.dll getting this error

"The conversion provider cann't be found.
Please make sure the folder "plugins" is under the same folder of Spire.Pdf.dll. For more help, please visit below website.
https://www.e-iceblue.com/Tutorials/Spi ... lugin.html"

sajalntoo
 
Posts: 14
Joined: Thu Jan 27, 2022 7:07 am

Wed Feb 02, 2022 7:43 am

Hello

Thanks for your inquiry.
By default, Visual Studio uses the 32 bit version of IIS Express. And you are using the x64-bit plugin, I suspect your problem should be caused by this.
Please try to enable the “Use the 64 bit version of IIS Express for web sites and projects” option by “Tools->Options->Projects and Solutions->Web projects”, as shown below. If there are still any questions, please feel free to contact us.
screenshot.png


Sincerely,
Brian
E-iceblue sppport team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.PDF

cron