Hi,
I downloaded iTextSharp 5.1.3 source and compiled it for .NET Framework 4.0. I tried to use the PdfStamper.GetPdfLayers() method and got an exception: The given key was not present in the dictionary. I found and fixed the bug in \Core\iTextSharp\text\pdf\PdfStamperImp.cs, AddOrder() method Code Before if (obj.IsIndirect()) { layer = ocgmap[key]; <-- Exception layer.OnPanel = true; RegisterLayer(layer); if (parent != null) { parent.AddChild(layer); } if (arr.Size > i + 1 && arr[i + 1].IsArray()) { i++; AddOrder(layer, (PdfArray)arr[i], ocgmap); } } Code Fix if (obj.IsIndirect()) { //Ivan Farkas of 3D HD Soft, LLC 2012/01/17 - Check for existing key of dictionary before using it, otherwise an exception is thrown string key = obj.ToString(); layer = ocgmap.ContainsKey(key) ? ocgmap[key] : null; if (layer != null) { layer.OnPanel = true; RegisterLayer(layer); if (parent != null) { parent.AddChild(layer); } if (arr.Size > i + 1 && arr[i + 1].IsArray()) { i++; AddOrder(layer, (PdfArray)arr[i], ocgmap); } } } I hope this helps. I find iText extremely useful. Sincerely Yours, Ivan Farkas 3D HD Soft, LLC 13371 SW 45th Dr, Miramar, FL 33027 (954) 364-7925; Fax: (866) 740-4296 i...@3dhdsoft.com<mailto:i...@3dhdsoft.com> www.3DHDSoft.com<http://www.3dhdsoft.com/> [Description: Description: Description: cid:image006.jpg@01CC8D4D.43861280]<http://www.3dhdsoft.com/> [Description: Description: Description: Description: Description: Description: LinkedIn_Btn_MyProfile_160x33.gif]<http://www.linkedin.com/companies/3d-hd-consulting-llc>[Description: Description: Description: Description: Description: Description: Friend me on Facebook]<http://www.facebook.com/pages/Miramar/3D-HD-Soft/136672453010397>[Description: Description: Description: Description: Description: Description: Tweet me on Twitter]<http://twitter.com/3DHDSoft>
<<inline: image001.jpg>>
<<inline: image002.gif>>
<<inline: image003.png>>
<<inline: image004.png>>
------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions iText(R) is a registered trademark of 1T3XT BVBA. Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php