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.

Wed Mar 22, 2023 11:46 am

1.Symbol £
2.code
using Spire.Pdf;
using Spire.Pdf.HtmlConverter;
using System.IO;
using System.Threading;
using System.Drawing;

namespace ConvertHtmlStringToPdfWithoutPlugin
{
class Program
{
static void Main(string[] args)
{
//Create a PdfDocument object
PdfDocument doc = new PdfDocument();

//Create a PdfPageSettings object
PdfPageSettings setting = new PdfPageSettings();

//Save page size and margins through the object
setting.Size = new SizeF(1000, 1000);
setting.Margins = new Spire.Pdf.Graphics.PdfMargins(20);

//Create a PdfHtmlLayoutFormat object
PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat();

//Set IsWaiting property to true
htmlLayoutFormat.IsWaiting = true;

//Read html string from a .html file
string htmlString = File.ReadAllText(@"C:\Users\Administrator\Desktop\Document\Html\Sample.html");

//Load HTML from html string using LoadFromHTML method
Thread thread = new Thread(() =>
{ doc.LoadFromHTML(htmlString, true, setting, htmlLayoutFormat); });
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();

//Save to a PDF file
doc.SaveToFile("HtmlStringToPdf.pdf");
}
}
}
3.FreeSpire.Pdf .Net 8.6.0
4.Windows 10 64 bit English
5..Net core Web App 2.1

tuleshkubde
 
Posts: 8
Joined: Tue Sep 06, 2022 5:35 pm

Thu Mar 23, 2023 6:23 am

Hi,

Thank you for your message.
At present the PdfHtmlLayoutFormat class is unavailable in the .Net core environment. But you refer to this tutorial (C #: Convert HTML to PDF) to do the conversion with the plugin. Meanwhile, kindly note that our Spire.PDF for .NET free Edition has some limitations, including a page limit of 10 pages for creating and loading PDF documents, and when converting PDF documents to images, only the first 3 pages will be converted successfully. If your document exceeds the limitation, you could upgrade to use our Spire.PDF Pack(Hot Fix) Version:9.3.4. We are willing to provide a temporary license (one month free) to help you remove the warning message and evaluate our commercial version better. If you need it, just feel free to write back.

Best Regards,
Herman
E-iceblue support team
User avatar

Herman.Yan
 
Posts: 115
Joined: Wed Mar 08, 2023 2:00 am

Thu Mar 23, 2023 10:42 am

Can you please update FreeSpire.pdf as when converting pound symbol (£) from html to pdf gets some unexpected characters (ã‚â£)

tuleshkubde
 
Posts: 8
Joined: Tue Sep 06, 2022 5:35 pm

Fri Mar 24, 2023 9:05 am

Hi,

Thank you for your message.
I created an html containing (£) symbols and converted it to pdf with the Plugin method, but I did not reproduce the "gets some unexpected characters (ã‚â£)" issue. You can provide with your input file as well as the final saved file for further testing. You can upload them here or via email (support@e-iceblue.com). Meanwhile, kindly note that we only upgrade our free version irregularly. The bug fixes and new features are only updated in our commercial version.

Best Regards,
Herman
E-iceblue support team
User avatar

Herman.Yan
 
Posts: 115
Joined: Wed Mar 08, 2023 2:00 am

Return to Spire.PDF

cron