Hi, please help, we are using Aspose.PDF for HTML to PDF conversions and encountering a blocking error when upgrading to .NET 8 or .NET 9, I have tried various versions of Aspose.PDF and the latest stable version 25.2.0. Here is the code that I’ve isolated into a c# unit test:
[Fact]
public void Convert_html_to_pdf_2()
{
// Arrange
var html = @"<html xmlns=""http://www.w3.org/1999/xhtml"">
Stock |
// Act
var input = new MemoryStream(Encoding.UTF8.GetBytes(html));
var document = new Document(input, new HtmlLoadOptions());
var memoryStream = new MemoryStream();
document.Save(memoryStream);
var actualPdfBytes = memoryStream.GetBuffer();
Array.Resize(ref actualPdfBytes, (int)memoryStream.Length);
// Assert
}
The error is as follows:
Message:
System.InvalidOperationException : Enumeration already finished.
Stack Trace:
SZGenericArrayEnumerator1.get_Current() #=zC4yhBn3BqnQVChWlWuWNI4DFpUuURiwCgg==.#=zlA$DyJrO6UuY[T](IEnumerable
1 #=zT9mrLC0=)
#=zmozd3_4zqqTvo$lqQEkp9cE=.#=zkZTPIm8PbnyurcrMIIiR7U4=(#=zUC9n57FvIxd1Eh9jSJJra77YOXHWl4OmLw== #=zN1KS4XoesKNh)
#=zBryqA2LICvawk62h_x_poVc=.#=zplDeB4clgyInMQwTlQkVh5g=(#=zQ7Q8eeBLfKm4pIi$snx962ceHg9m1fd0nw== #=zgYFraDw=)
SelectManySingleSelectorIterator2.MoveNext() SelectManySingleSelectorIterator
2.MoveNext()
SelectManySingleSelectorIterator2.MoveNext() ConcatIterator
1.MoveNext()
SelectManySingleSelectorIterator2.MoveNext() IteratorSelectIterator
2.MoveNext()
<11 more frames…>
#=zejvkYdH9Dk5Ufbi25DsIdPPxW0Pu.Render(#=zsAHVwSk6metEmZCZ8xcWcyBX0OTb #=zP9SjuMo=, #=zSevFJJE= #=z2XFwSls=, TimeSpan #=zyEe2MVY=)
#=zejvkYdH9Dk5Ufbi25DsIdPPxW0Pu.Render(#=zsAHVwSk6metEmZCZ8xcWcyBX0OTb #=zP9SjuMo=, #=zSevFJJE= #=z2XFwSls=)
#=ztr1iySQAPSE3wwXTaDP8XIY9ibzr.#=z2C8rXfN98FTy(Stream #=z$G$Uv7mc4slX, Document #=z6X5TU2TE48IL, HtmlLoadOptions #=z8XWl92SxULqa, String #=z0lC$unjcSOyy)
#=ztr1iySQAPSE3wwXTaDP8XIY9ibzr.#=znlwNvPM=(Stream #=z$G$Uv7mc4slX, Document #=z6X5TU2TE48IL, HtmlLoadOptions #=z8XWl92SxULqa, String #=z0lC$unjcSOyy)
#=ztr1iySQAPSE3wwXTaDP8XIY9ibzr.#=znlwNvPM=(Stream #=z$G$Uv7mc4slX, Document #=z6X5TU2TE48IL, HtmlLoadOptions #=z8XWl92SxULqa)
Document.#=z_IIvKXU=(Stream #=z$A1ps7Y=, LoadOptions #=ze_om$e0=)
Document.ctor(Stream input, LoadOptions options)
AsposePdfGeneratorTests.Convert_html_to_pdf_2() line 65
RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Is this a known issues and/or is there any workaround that can be suggested because this is unfortuntely blocking us from upgrading our version of .NET
Thanks
ALSO NOTE: The following unit test passes and so it seems related to the handling of preserving whitespace:
[Fact]
public void Convert_html_to_pdf_1()
{
// Arrange
var html = @"<html xmlns=""http://www.w3.org/1999/xhtml"">
Stock |
// Act
var input = new MemoryStream(Encoding.UTF8.GetBytes(html));
var document = new Document(input, new HtmlLoadOptions());
var memoryStream = new MemoryStream();
document.Save(memoryStream);
var actualPdfBytes = memoryStream.GetBuffer();
Array.Resize(ref actualPdfBytes, (int)memoryStream.Length);
// Assert
}