Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Fri Jun 09, 2017 1:19 pm

I am currently trying to write a process that takes thousands of small word documents and turn them into PDF. Because speed is something I am concerned about I am trying to thread the process. Right now I have 3 threads running that do a document merge in a word document and then save that word document to a disk. Consistently I have been getting the following error.

Exception thrown: 'System.InvalidOperationException' in System.Drawing.dll ("Object is currently in use elsewhere.")

I get this error whether using .NET or WPF object. The error happens on the following piece of code:

document.SaveToFile(@"c:\FolderName\pdf\documentName_" + IncrementedNumber + "_1.pdf", Spire.Doc.FileFormat.PDF);

I am using the .NET Task object to assign the tasks out.

I currently own the .NET version of the office controls but I have noticed that the WPF version seems to be quicker. I would be willing to buy those controls also if this can be fixed otherwise I have to look for a different solution. I like these controls because I don't want to have to install office on any of our servers which many other controls require. Could you please help me find a way to make this work. Limiting the pdf conversion to one thread does not help me since this is the longest part of my process and one of my main requirements is speed.

Thank you,

Eric Cooperider

Talsbard
 
Posts: 14
Joined: Wed Oct 12, 2016 9:27 pm

Mon Jun 12, 2017 2:02 am

Dear Eric,

Sorry for late reply as weekend.
For the exception issue, please provide us with following information for investigation.
1)the inputs files which have that issue.
2)the complete code showing the issue, the better to provide a sample project.
In addition, you could send it to us(support@e-iceblue.com) via email.

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.Doc