Martin Schröder wrote: > Hi, > I'm debugging a faulty PDF generated by pdfTeX with podofobrowser. It > would be nice if the browser would detect duplicate keys and warn > about them...
This would have to be done at the PoDoFo library level, though PoDoFo's logging infrastructure. By the time PoDoFoBrowser sees the PDF the duplicate keys are long gone. PdfDictionary uses a std::map to store its key/value pairs, and it just clobbers any old key when AddKey is called for the second time. PdfDictionary already makes the check to see whether a key already exists when adding a key, as it releases the old value before replacing it. Arguably AddKey should instead reject duplicate keys, or at least warn about this - but really, as presently used AddKey should be called SetKey instead, to match it's behaviour. I certainly agree that during PDF parsing PoDoFo should detect duplicate dictionary keys. Since we're paying the map lookup cost anyway this might just be a matter of renaming AddKey to SetKey (Yep, API breakage, but nice sed-friendly API breakage) and making the new AddKey throw on duplicate keys. PdfParserObject can then be prepared to catch the exception, log a warning including useful context like the byte offset and object number being processed, and keep on parsing. It'd be 0.7.0 material, of course, but does that sound reasonable? P.S: Hooray for dual-boot. My Windows environment unexpectedly turned up its toes and died for no apparent reason, so it's Ubuntu to the rescue. This might make testing PoDoFoBrowser on win32 a bit hard, though, so given the successful tests on Linux I'm inclined to release now. If something turns out to be broken a 0.6.1 isn't an unforgivable offense. -- Craig Ringer ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Podofo-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/podofo-users
