Click here to Skip to main content
16,021,004 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
PdfReader reader = new PdfReader(@"C:\Users\Public\Documents\RMA.pdf");
            int n = reader.NumberOfPages;
            Rectangle psize = reader.GetPageSize(1);
            float width = psize.Width;
            float height = psize.Height;
            Console.WriteLine("Size of page 1 of {0} => {1} × {2}", n, width, height);
            Dictionary<string, string> infodict = reader.Info;
            foreach (KeyValuePair<string, string> kvp in infodict)
                Console.WriteLine(kvp.Key + " => " + kvp.Value);

on the above code i got error

Cannot implicitly convert type 'System.Collections.Hashtable' to 'System.Collections.Generic.Dictionary<string,string

any solution please suggest.
Posted
Comments
Manfred Rudolf Bihy 27-Jul-11 6:40am    
You posted code that has neither to do with Hashtable nor Dictionary, please show the line of code that throws the specified exception.

Thanks for your cooperation.
rajjosh 27-Jul-11 6:53am    
Dictionary<string,> infodict = reader.Info;

foreach (KeyValuePair<string,> kvp in infodict)
Console.WriteLine(kvp.Key + " => " + kvp.Value);
on above line i got error

.

Where did you get the PdfReader class from? Most probably, either the PdfReader constructor or the GetPageSize method is throwing the error. If you have the source code for the PdfReader class, you can try debugging the error.
 
Share this answer
 
Honestly, the error message tells you exactly what is wrong. Something is returning a Hashtable, and you are trying to assign it to a typed Dictionary. You are wasting your time and ours by asking this type of question here – a little knowledge and you could solve this kind of thing in far less than 25 minutes.

From your comment it appears this is quite an old reader class that returns Info as a Hashtable. So don't try to assign it to a type it isn't compatible with!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900