To whom it may concern, I recently came across a PDF form that causes PdfCheckBox::IsChecked() to crash. After some investigation it turns out that this file, produced by Adobe PDF Library 10, is creating slightly different objects and values than expected.
Some check-boxes are created with a dictionary item called "V" (expected), but sometimes the key is "AS". I noticed that ::SetChecked(bool) sets both, but ::IsChecked() only checks one. Additionally, instead of setting true to "Yes", Adobe PDF Library is setting the value to "On". Both issues have been handled in the minor patch which has been attached. I have also attached the originating PDF which sent me down this path. Please let me know if I can provide anything else for this to get merged in. Thank you, ~ Matthew
Index: src/doc/PdfField.cpp =================================================================== --- src/doc/PdfField.cpp (revision 1561) +++ src/doc/PdfField.cpp (working copy) @@ -647,9 +647,17 @@ bool PdfCheckBox::IsChecked() const { - PdfName name = m_pObject->GetDictionary().GetKey( PdfName("V") )->GetName(); + PdfDictionary dic = m_pObject->GetDictionary(); - return name == PdfName("Yes"); + if (dic.HasKey(PdfName("V"))) { + PdfName name = dic.GetKey( PdfName("V") )->GetName(); + return (name == PdfName("Yes") || name == PdfName("On")); + } else if (dic.HasKey(PdfName("AS"))) { + PdfName name = dic.GetKey( PdfName("AS") )->GetName(); + return (name == PdfName("Yes") || name == PdfName("On")); + } + + return false; } /////////////////////////////////////////////////////////////////////////////
DHR Checklist.R6.Filliable Test.pdf
Description: Adobe PDF document
------------------------------------------------------------------------------ Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! Discover the easy way to master current and previous Microsoft technologies and advance your career. Get an incredible 1,500+ hours of step-by-step tutorial videos with LearnDevNow. Subscribe today and save! http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________ Podofo-users mailing list Podofo-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/podofo-users