Word document to PDF conversion throws exception "Operation is not valid due to the current state of the object." using .NET

Getting an error when converting the attached Word document to PDF. Below is the stack trace.

Operation is not valid due to the current state of the object.
at x4adf554d20d941a6.x5c28fdcd27dee7d9.x91f68097aef9038e(x56410a8dd70087c5& x
62584df2cb5d40dd, x56410a8dd70087c5& x2aa5114a5da7d6c8)
at x4adf554d20d941a6.x5c28fdcd27dee7d9.x295cb4a1df7a5add(Field xe01ae93d9fe5a
880)
at Aspose.Words.Fields.Field.x7ff30deb4e281744()
at Aspose.Words.Fields.Field.x42a25ae95099edb8(x5e36356bc92c609b x0f7b23d1c39
3aed9)
at Aspose.Words.Fields.Field.x295cb4a1df7a5add(x5e36356bc92c609b x0f7b23d1c39
3aed9)
at xfbd1009a0cbb9842.xfedf115fd9c03862.x4e3cfc222c92cda7(Field xe01ae93d9fe5a
880, x5e36356bc92c609b x0f7b23d1c393aed9)
at xfbd1009a0cbb9842.xbf9ddf72e1283af9.x18dfca7c5fd2402f()
at xfbd1009a0cbb9842.xfedf115fd9c03862.xdd6cf0348a23f220(xcf417e2db4fe9ed3 xe
00c282e1a49fcfb)
at xfbd1009a0cbb9842.xfedf115fd9c03862.x384c03e4298b53bf()
at Aspose.Words.Range.UpdateFields()
at Aspose.Words.Document.UpdateFields()
at Com.Crawfordtech.Conversions.MetaDataExtractor.GetPageStartOfSections(Docu
ment doc)
at Com.Crawfordtech.Conversions.MetaDataExtractor.GetPrintCommands(Document d
oc)
at Com.Crawfordtech.Conversions.Program.ShowPrintCommands(String fullPath)
at Com.Crawfordtech.Conversions.Program.Main(String[] args)

Hi John,

Thanks for your query. I have tested the scenario and have not found any issue while using latest version of Aspose.Words for .NET. Please use the latest version of Aspose.Words for .NET . I have attache the output PDF file with this post.

Please let us know if you have nay more queries.

Forgot to mention we are also extracting OLE or print commands from the word document. Attached is the code we use.
John

Hi John,

Thanks for your query. I have checked your code and it seems that you want to convert Docx to Pdf file. Please share your document file along with some more information about your query.

Yes, you can extract OLE embedded objects using Aspose.Words. Please use the shared code at following forum links.

https://forum.aspose.com/t/122142
https://forum.aspose.com/t/98398

Attached is the document. We are already pulling OLE values from the documents using your code. This one is throwing an error. It looks like an Aspose error.
So far this is the only document causing errors with our code to extract OLE values.
John

Hi
Thanks for your inquiry. unfortunately, I cannot reproduce the problem on my side. Please make sure you are using the latest version of Aspose.Words.
Also, in your test console application MetaDataExtractor class is missed, so I cannot test with your code.
Best regards,

please try the attached.

Hi John,

I have tested the scenario at my end and have not found any issue. I have attached the output PDF file with this post. Please let us know if you have any more queries.

Have you successfully tested our code? Did you get the same results with our code, or have you not tested our code yet?

Hi John,

I generated the output PDF file by using your code and attached output pdf file in my previous post. The only error I faced with your code is related to .SNK file. Please see the attached image file. I removed WordToPdf.snk from shared project and had successfully build your project.

It looks like you only converted the pdf and did not extract the print commands. Did you also try extracting the OLE objects and writing them to the PDF? Thats what we are having an issue with.

Hi John,

I have tested again ShowPrintCommands method and have not found any issue while using latest version of Aspose.Words for .NET. Please see the results of ShowPrintCommands method in attached image file.

ShowPrintCommands(@"d:\930575.doc");

if(!Settings.Default.ConvertToPdf ) 
     return;

ConvertToPdf(@"d:\930575.doc");

Thanks. Were you able to get the same results using our code? We had to use another example supplied by Aspose to get print commands becuase the simple approach did not work for ther word documents we had to convert.

Hi John,

I used your code to get results of print commands. In you first post, you posted that you are getting exception while convert Word to PDF. Unfortunately, I have not completely understood your query. It would be great if you please explain what you want to achieve by using Aspose.Words? We are really keen to help you but need some more details from your side.

We had to use another example supplied by Aspose to get print commands
becuase the simple approach did not work for ther word documents we had
to convert.

Hi there,

Thanks for your inquiry.

I too have tried running your application and the print commands method with that document and it completed successfully. Can you please try the application again on your side just incase the project you attached doesn’t reproduce the issue.

Thanks,

thanks for your help. Isn’t the error listed an Aspose error?
I will try the same project and see if it works.
John

What environment have you compiled and run it on? Have you tested it on a 32/64bit Win7 machine?

I just recompiled it (Visual Studio 2010) on another machine with the newest Aspose.Words 11.6.1 running Win 7 32bit and still got the same error. We have not found a single environment where we do not get this error.

We are running windows 7 on a 64 bit machine. What is your environment?
Is there anything else that may be different?
John

Hi John,

Thanks for this additional information.

I’m afraid I can’t reproduce the issue on Windows 7 32 bit (this was all on hand that I could test quickly). Just to clarify, you are attempting to run the exact same application with the same document that you uploaded here to the site?

Could you double check the version number of Aspose.Words being used in the application on your side?

Thanks,

Yes I am attempting to run the exact same application with the same document that I uploaded to the support forums. I double checked the version of Aspose.Words that I am using. It is 11.6.1.0 modified on August 17th 2012. See attached screen shot.