- Code: Select all
var templateFile = "<SomePath>/temp.html";
var template = string.Empty;
using (var sw = new StreamReader(templateFile.OpenReadStream()))
{
//sw.BaseStream.Seek(0, SeekOrigin.End);
template = sw.ReadToEnd();
}
var ms = new MemoryStream();
Spire.Pdf.HtmlConverter.Qt.HtmlConverter.Convert(template, ms, true, 10000, Spire.Pdf.PdfPageSize.A4, new Spire.Pdf.Graphics.PdfMargins(0), Spire.Pdf.HtmlConverter.LoadHtmlType.SourceCode);
var pdf = new Spire.Pdf.PdfDocument(ms);
Trial 2 :
- Code: Select all
var templateFile = "<SomePath>/temp.html";
Spire.Pdf.HtmlConverter.Qt.HtmlConverter.Convert(templateFile,"<OutputPath>/temp.pdf", true, 10000, Spire.Pdf.PdfPageSize.A4, new Spire.Pdf.Graphics.PdfMargins(0), Spire.Pdf.HtmlConverter.LoadHtmlType.URL);
var pdf = new Spire.Pdf.PdfDocument("<OutputPath>/temp.pdf");
Both new Spire.Pdf.PdfDocument() giving error :
Trial 1 : index was outside the bounds of the array
Trial 2 : File doesnt exist (the pdf file never generated after calling HtmlConverter.Convert
**Both trial working fine in windows laptop and server without latest patching (8th Feb 2025)
**Tried with latest plugins download from E-Iceblue
**Unable try with latest spire.pdf version (11.2.4) as it not longer support HtmlConverter class
**From Windows logs, the error are throwing from Html2Pdf.exe
OS : Windows Server 2019
Spire.pdf version 9.3.4
Hi,
Would like to get advise for issue above, or is there any alternative solution for converting HTML to PDF?
*Since 11.2.4 version not longer support HtmlConverter, is there any new approach for this conversion?