Multithreading issue - TextFragmentAbsorber

Hi,

I get an application exception while using TextFragmentAbsorber.

Using this code:

[TestCase(@"TestData\Sample1.pdf", @"TestData\Sample2.pdf")]
public void ShouldExtractTextFragmentsInParallel(params string[] paths)
{
bool exceptionOccured = false;
Parallel.ForEach(paths, path =>
{
try
{
Document document = new Document(path);
foreach (Page page in document.Pages)
{
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber();
page.Accept(textFragmentAbsorber);
}
}
catch (ApplicationException ex)
{
exceptionOccured = true;
Assert.AreEqual("Font Helvetica was not found", ex.Message);
}
});

Assert.IsTrue(exceptionOccured);
}

I get following stack trace:

{System.ApplicationException: Font Helvetica was not found
at Aspose.Pdf.Text.FontRepository.FindFont(String fontName)
at Aspose.Pdf.TextStamp.()
at Aspose.Pdf.Text.TextState.(TextState , ˜ )
at Aspose.Pdf.Text.TextState.(– )
at Aspose.Pdf.Text.TextState..ctor(TextSegment )
at Aspose.Pdf.Text.TextSegment.(– , Int32 , Int32 , TextEditOptions )
at Aspose.Pdf.Text.TextSegment..ctor(– , Int32 , Int32 )
at Aspose.Pdf.Text.TextFragmentAbsorber.( , [] )
at Aspose.Pdf.Text.TextFragmentAbsorber.Visit(Page page)
at Aspose.Pdf.Page.Accept(TextFragmentAbsorber visitor)
at ePublisher.Engine.Tests.Services.Processors.BlueLinksServiceTest.<>c__DisplayClass1.b__0(String path) in ...... cs :line 135}

Exception occurs only on first run of the code. If I add another test case, the later one runs fine.
I attached two sample files, but it occurs on every doc I tried.

Version of Aspose.PDF.dll I'm using is 6.8.0.0 (2012.03.01).

Hi Wojciech,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for sharing the sample code and template files.

I am able to generate your mentioned issue after an initial test. Your issue has been registered in our issue tracking system with issue id: PDFNEWNET-33453. You will be notified via this forum thread regarding any update against your reported issue.

Sorry for the inconvenience,

The issues you have found earlier (filed as PDFNEWNET-33453) have been fixed in Aspose.Pdf for .NET 7.2.0.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.