We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert PDF to HTML in C# using Aspose.PDF for .NET - System.ArgumentException: Item has already been added

Using Aspose PDF 8.5.0 I'm getting different results on my local to PC to the production server !!

The code couldn't be simpler

Aspose.Pdf.Document pdf = new Aspose.Pdf.Document(@"c:\temp\test.pdf");
pdf.Save(@"c:\temp\test.html", Aspose.Pdf.SaveFormat.Html);Aspose.Pdf.Document pdf = new Aspose.Pdf.Document(@"c:\temp\test.pdf");
pdf.Save(@"c:\temp\test.html", Aspose.Pdf.SaveFormat.Html);

Running the on my local PC the conversion is performed correctly.

Running the same code ( all copied from a console application's bin to the server ) I get the error

Unhandled Exception: System.ArgumentException: Item has already been added. Key
in dictionary: 'arial narrow' Key being added: 'arial narrow'
at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add
at☻.?.?☻(String , String )
at☻.?.☺(String , ↑ , Color , Int32 )
at ?.‼☻.?☻(§☻ )
at ?.☼☻.?☻(§☻ )
at ?.◄☻.?☻(§☻ )
at ?.►☻.?☻(§☻ )
at ?☻.?☻(§☻ )
at ?.?.?☻(ArrayList , §☻ , ? )
at☻.▲.?☻(String , ⌂ , ArrayList , ♦☻ )
at ¶.‼.?☻(Document , String , HtmlSaveOptions )
at TestConsole.Program.Main(String[] args)

Is there a dependency that I need to update ?

Hi Mark,

Thanks for using our product.

Can you please share the source PDF file and share some details regarding your working environment (Operating System version, .NET Framework version etc). We are sorry for this inconvenience.

Nayyer, I have uploaded the PDF causing the issue.

The PC that performs the conversion correctly is windows 7 pro sp 1 ,net framework 4.

The PC that is failing with the duplicate key in dictionary is windows server 2008 R2 enterprise sp1 ,net framework 4.

The aspose conversion is normally performed in a web application, and we spotted the duplicate key error after recently upgrading to the latest PDF conversion DLL. Confusingly trying to replicate the problem locally was not possible !

So as you can see from the code previously posted i’ve stripped it back as far as possible, literally two lines in a console program. Running this exe locally from the bin folder works copying the bin folder to the server and running it produces the duplicate key error.

Thanks in advance Mark.

Hi Mark,

Thanks for sharing the resource file.

We are working over this query and will get back to you soon. Meanwhile, during our testing over Windows 7, the problem does not seem to be occurring. So we are working on testing the scenario over Windows Server 2008.

Hi Mark,

Thanks for your patience. I’m afraid we are unable to replicate issue on Windows Server 2008 R2 Sp1 by both ways, copying Bin folder from Windows 7 project to server and creating a new console project over Server. Can you please share you sample console project here? So we will try to replicate the issue and will provide you more information accordingly.

We are truly sorry for the inconvenience caused.

Best Regards,

Hi ,

I have reproduced both the success on windows 7 and failure on windows server 2008 using the 8.5.00 dll, and taken screen shots ( see attached word doc )

I’ve attached the zipped console solution that i used for the test it’s as simple as i can make it.

Then to prove the issue is introduced with the new version of the DLL i’ve repeated the test using the same solution just changing the referenced Aspose.PDF to the older version this works successfully on botht the windows 7 and windows server machines !

( see last page in the attached doc for a screen shot of success on the server )

Please let me know if i can provide you with anything else that will help …

Regards Mark.

Hi Mark,

Thanks for sharing the details. We are working on replicating this issue and will get back to you soon.