I am evaluating Aspose.PDF and I am unable to render 2 separate documents from HTML at once.
I get a NullReferenceException.
I’m using Aspose.PDF 20.11.0 with .NET Core 3.1 on a Windows 10 system (but plan to deploy on a Linux system for production).
Here is some sample code that results in the error:
const int NUMBEROFCONCURRENTRENDERS = 2;
var range = Enumerable.Range(1, NUMBEROFCONCURRENTRENDERS);
var sem = new SemaphoreSlim(1, 1);
var manyDocs = range.Select(x =>
{
var index = x;
return Task.Run(() =>
{
//sem.Wait();
var html = @"<body><div>Hello World!</div></body>";
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(html));
var htmlLoadOptions = new Aspose.Pdf.HtmlLoadOptions();
var doc = new Aspose.Pdf.Document(stream, htmlLoadOptions);
var pdfSaveOptions = new Aspose.Pdf.PdfSaveOptions();
doc.Save($"output{index:D2}.pdf", pdfSaveOptions);
//sem.Release();
});
}).ToArray();
Task.WaitAll(manyDocs);
Set the renders down to 1 or uncomment the semaphore use and the code runs to completion.
I require the performance gains of multi-threaded PDF generation so I consider this a major issue, especially since I’ve seen mention that multithreaded rendering is supported as long as they are separate documents, which is currently not the case.
As I am currently evaluating this, I am interested to know what the lead time is on support requests.
Please keep me informed on the status of this issue.
Thanks!
Randy
Here’s the stacktrace:
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at #=zepv793VfFdij_jw2ujOnTIrSvMl_hKz6jA==.#=ztjNBZ4w=(#=z6ds7JA4= #=zBJTJp2Y=, IList`1 #=zoVmSygI=)
at #=zepv793VfFdij_jw2ujOnTIrSvMl_hKz6jA==.#=ztjNBZ4w=(#=z6ds7JA4= #=zBJTJp2Y=)
at #=zIePKlzyILnw0BL2YWJRbB0hKXHaRId$6v90pD_o=.#=zsq$9RZo=()
at #=zqRBKAMNsGGFYZ22GEe2JGcrfrgn3FbJEFw==.#=zXY_zx7dtz1oL0UdJGJPinH3DU6bMPUPIKiEG8ls=()
at #=zqRBKAMNsGGFYZ22GEe2JGcrfrgn3FbJEFw==.#=zySVIexg=()
at #=zqRB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J12WnTaFRPS5O #=zeJDrXYU=, #=zysH2GpM= #=zanrpBCo=, TimeSpan #=zoGVXzK4=)
at #=zUqrDdB9zAhe3DLPDJprrb9p2OTuz.Render(#=z7bvrcfh_wLzrznNJ12WnTaFRPS5O #=zeJDrXYU=, #=zysH2GpM= #=zanrpBCo=)
at #=z5M2Uv9Zx_eZaKearhVNfgErCMkhV.#=z0evQ6Lg=(Stream #=zuGDa2k4DZhpK, Document #=z$y3AsKbJHdsO, HtmlLoadOptions #=zw7W_PPHV5Yl1, String #=zG5yEyBZdKQQo)
at #=z5M2Uv9Zx_eZaKearhVNfgErCMkhV.#=z0evQ6Lg=(Stream #=zuGDa2k4DZhpK, Document #=z$y3AsKbJHdsO, HtmlLoadOptions #=zw7W_PPHV5Yl1)
at Aspose.Pdf.Document.#=zCP0rBx0=(Stream #=zBE3H15s=, LoadOptions #=z4Gp8a2g=)
at Aspose.Pdf.Document..ctor(Stream input, LoadOptions options)