Hi,
I’m using the Aspose.pdf for .Net version 19.2 when I go to generate a pdf from an Html using the Aspose.Pdf.Document constructor I am getting the following exception.
System.ArgumentOutOfRangeException
Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index
I have worked out that this exception is caused by the table in the HTML having too many columns. I also have included an example of the code and a test file which causes the exception above.
TestFile.zip (4.1 KB)
public void TestPdfGeneration (string sHtml, string sPath)
{
itErrorStore oErrors = new itErrorStore();
try
{
Aspose.Pdf.HtmlLoadOptions oOptions = new Aspose.Pdf.HtmlLoadOptions(sPath);
using (Stream oStream = GenerateStreamFromString(sHtml))
{
Aspose.Pdf.Document oDocument = new Aspose.Pdf.Document(oStream, oOptions);
}
}
catch (Exception oException)
{
itErrorStore.Add(oErrors, oException);
}
}
public static Stream GenerateStreamFromString(string sString)
{
MemoryStream oStream = new MemoryStream();
StreamWriter oWriter = new StreamWriter(oStream);
oWriter.Write(sString);
oWriter.Flush();
oStream.Position = 0;
return oStream;
}