Spire.pdf.dll v6.8.5.2330
Qt5Core.dll v5.9.8.0
The Html to pdf works fine except when we include an image in the html file.
Attached are
c# code
image file
html file
output pdf file.
// Create a new PdfDocument object
PdfDocument doc = new PdfDocument();
// Create a new PdfPageSettings object
PdfPageSettings setting = new PdfPageSettings();
// Set the size of the page to 1000x1000
setting.Size = new SizeF(1000, 1000);
// Set the margins of the page to 20 units
setting.Margins = new Spire.Pdf.Graphics.PdfMargins(20);
// Create a new PdfHtmlLayoutFormat object
PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat();
// Set the IsWaiting property of the layout format to true
htmlLayoutFormat.IsWaiting = true;
// Read the HTML content from a file and store it in a string variable
string htmlString = File.ReadAllText(@"..\TBR.HTML");
// Create a new thread and start it
Thread thread = new Thread(() =>
{
// Load the HTML content into the PdfDocument object
doc.LoadFromHTML(htmlString, true, setting, htmlLayoutFormat);
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
// Save the PdfDocument object to a file
doc.SaveToFile(@"..\result2.pdf");<img src=". \ barbSignature. png"/>// Specify the URL address
string url = @"..\ConvertToPDF\TBR.HTML";
// Specify the output file path
string fileName = @"..\Url转Pdf11.pdf";
// Specify the plugin path
string pluginPath = @"..\\plugins-windows-x64\\plugins";
// Set the plugin path
HtmlConverter.PluginPath = pluginPath;
// Convert the URL to PDF
HtmlConverter.Convert(url, fileName, true, 100000, new Size(1080, 1000), new PdfMargins(0));