Does the latest release of Aspose.Pdf support multithreading?

Does Aspose.pdf support multithreading?
Running the code below gives varying exceptions on the pngDevice.Process Method including
"Each key should be Pdf Name"
"Object reference not set to an instance of an object."
Aspose.Pdf.Document doc2 = new Aspose.Pdf.Document(s);
List<KeyValuePair> lstMemory = new List<KeyValuePair>();
System.Threading.Tasks.Parallel.For(1, doc2.Pages.Count + 1, (i) =>
{
image = new MemoryStream();
Aspose.Pdf.Devices.PngDevice pngDevice = new Aspose.Pdf.Devices.PngDevice(new Aspose.Pdf.Devices.Resolution(300));
pngDevice.Process(doc2.Pages[i], image);
System.Drawing.Image img = Bitmap.FromStream(image);
lstMemory.Add(new KeyValuePair(i - 1, image));
});

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

Thank you for sharing the sample code.

I tried to replicate your issue with the latest version of Aspose.Pdf for .NET v6.9 and I am unable to reproduce your mentioned issue with my test PDF document. Please share the template PDF file you are using to help us reproduce your mentioned issue at our end. This will help us identify and rectify the issue soon.

Sorry for the inconvenience,

Hi--
Here is the code to replicate the issue. You will need to include your license and any list of pdfs.
Thanks. -- Randy
class Program
{
static void Main(string[] args)
{
string license = System.Environment.CurrentDirectory + "/Aspose.Total.lic.xml";
var pdfLicense = new Aspose.Pdf.License();
pdfLicense.SetLicense(license);
Aspose.Pdf.Document doc2 = new Aspose.Pdf.Document(System.Environment.CurrentDirectory + "/CA-Hunting-Digest-2012-1.pdf");
List<KeyValuePair> lstMemory = new List<KeyValuePair>();
System.Threading.Tasks.Parallel.For(1, doc2.Pages.Count + 1, (i) =>
{
MemoryStream image = new MemoryStream();
Aspose.Pdf.Devices.PngDevice pngDevice = new Aspose.Pdf.Devices.PngDevice(new Aspose.Pdf.Devices.Resolution(300));
pngDevice.Process(doc2.Pages[i], image);
System.Drawing.Image img = System.Drawing.Bitmap.FromStream(image);
lstMemory.Add(new KeyValuePair(i - 1, image));
});
}
}

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

Thank you for the details.

I used your sample code with my template PDF file and I am afraid I am still not able to reproduce your issue. Please share some details regarding your system information i.e. OS, .NET Framework, 32 bit or 64 bit processor etc. Also, as requested earlier, if possible, please do share your template PDF file with us that will help us identify the cause of the issue sooner.

Sorry for the inconvenience,

Windows 7 Ultimate Service Pack 1

64-bit OS

Processor: Intel® Xeon® CPU E31225 @ 3.10GHz 3.10 GHz (4 CPUs)

8.00 GB RAM

viusal studio 2010

Target Framework .Net 4.0

issue happens processing this pdf

http://nrm.dfg.ca.gov/FileHandler.ashx?DocumentID=44018

Thanks!

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

Thank you for the details and template PDF file.

I am able to generate the issue using your template PDF file. Your issue has been registered in our issue tracking system with issue id: PDFNEWNET-33660. You will be notified via this forum thread regarding any updates against your reported issue.

Sorry for the inconvenience,

Hello,

I can confirm that multithread does in fact crash Aspose. I am quite disapointed that PDF tools for $800 do not support multithreading. In my case I have built a multithreaded parsing system that each thread parses it’s own PDF, but if I configure the system to work on more than 1 thread, I get all kinds of errors from Aspose: NullReferenceException, Dictionary keys already entered, etc. Too bad I cannot help you more. For now I will use the system on single thread, but we’re in 2012.

Edit: There are still problems opening PDF files under single thread, check PDFs below:

http://labraj.uni-mb.si/images/d/d9/Diploma_Saso.pdf
System.ArgumentException: Item has already been added. Key in dictionary: ‘191,3’ Key being added: ‘191,3’ at System.Collections.SortedList.Add(Object key, Object value) at ..(ArrayList ) at .…ctor(ArrayList ) at ..() at Aspose.Pdf.Text.TextAbsorber.( , Boolean ) at Aspose.Pdf.Text.TextAbsorber.Visit(Page page) at Aspose.Pdf.Page.Accept(TextAbsorber visitor) at Aspose.Pdf.PageCollection.Accept(TextAbsorber visitor)

http://labraj.uni-mb.si/images/c/cd/DiplomaDamijan.pdf
System.ArgumentException: Item has already been added. Key in dictionary: ‘214,980060424805’ Key being added: ‘214,980060424805’ at System.Collections.SortedList.Add(Object key, Object value) at ..(ArrayList ) at .…ctor(ArrayList ) at ..() at Aspose.Pdf.Text.TextAbsorber.( , Boolean ) at Aspose.Pdf.Text.TextAbsorber.Visit(Page page) at Aspose.Pdf.Page.Accept(TextAbsorber visitor) at Aspose.Pdf.PageCollection.Accept(TextAbsorber visitor)

http://labraj.uni-mb.si/images/d/de/DiplomaBorko.pdf
System.ArgumentException: Item has already been added. Key in dictionary: ‘124,7799’ Key being added: ‘124,7799’ at System.Collections.SortedList.Add(Object key, Object value) at ..(ArrayList ) at .…ctor(ArrayList ) at ..() at Aspose.Pdf.Text.TextAbsorber.( , Boolean ) at Aspose.Pdf.Text.TextAbsorber.Visit(Page page) at Aspose.Pdf.Page.Accept(TextAbsorber visitor) at Aspose.Pdf.PageCollection.Accept(TextAbsorber visitor)

http://labraj.uni-mb.si/images/3/35/Borko_erk05.pdf
System.ArgumentException: Item has already been added. Key in dictionary: ‘78,5000000000001’ Key being added: ‘78,5000000000001’ at System.Collections.SortedList.Add(Object key, Object value) at ..(ArrayList ) at .…ctor(ArrayList ) at ..() at Aspose.Pdf.Text.TextAbsorber.( , Boolean ) at Aspose.Pdf.Text.TextAbsorber.Visit(Page page) at Aspose.Pdf.Page.Accept(TextAbsorber visitor) at Aspose.Pdf.PageCollection.Accept(TextAbsorber visitor)

http://labraj.uni-mb.si/images/e/e5/Borko_erk06.pdf
System.ArgumentException: Item has already been added. Key in dictionary: ‘110,12’ Key being added: ‘110,12’ at System.Collections.SortedList.Add(Object key, Object value) at ..(ArrayList ) at .…ctor(ArrayList ) at ..() at Aspose.Pdf.Text.TextAbsorber.( , Boolean ) at Aspose.Pdf.Text.TextAbsorber.Visit(Page page) at Aspose.Pdf.Page.Accept(TextAbsorber visitor) at Aspose.Pdf.PageCollection.Accept(TextAbsorber visitor)

If you need more, let me know :wink:

Best Regards,

Legoless

The attached pdf was created with aspose, but when I open it up and save again the new pdf is corrupted.
Aspose.Pdf.Document doc = new Aspose.Pdf.Document((Stream)new FileStream("c:\\HB_2009315.pdf", FileMode.Open));
doc.Save("c:\\convert.pdf", Aspose.Pdf.SaveFormat.Doc);
Please advise.

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

Thank you for the template file and sample code.

Well, you are using the file extension as “pdf” in your code however, you are trying to save the file as “doc” as per Aspose.Pdf.SaveFormat in your code. If you need to save the file as “.doc” file, please change the extension of the output file to “.doc” in your code. I checked it and it works fine. Also, in case you want to save it as PDF, you don’t need to use the SaveFormat in your code.

Please do let us know in case you need any further assistance,

Thank You & Best Regards,

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

Sorry for the inconvenience you are facing due to any issue caused by Aspose.Pdf for .NET and thank you for sharing the template files. Please share your sample code with us to check your template files to identify the cause of the issue. We would also appreciated it if you can create a sample application to show us the issue you are facing regarding the multi-threading. This will help us identify the issue quickly and resolve it soon. Your cooperation is highly appreciated in this regard.

Sorry for the inconvenience,

The issues you have found earlier (filed as PDFNEWNET-33660) have been fixed in this update.


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