I love that Apple has lots of frameworks for me to use in my apps and gives me things for free such as PDF viewing and manipulation. This is with PDFKit. The problem with PDFKit is that it isn’t very tolerant of PDFs created from various other applications. I reported a bug with this back in the 10.4 era and it got fixed; I simply added a keyword to a PDF using Preview and it crashed (this is the same thing I do in ReceiptWallet). Now, I was pointed to another PDF that has the same behavior. The steps to reproduce this are quite simple:
- Download the IRS W-9 form
- Open it in Preview (on 10.5.2)
- Choose Tools->Inspector
- Click on the keywords tab
- Click the + button
- Add a keyword
- Do a Save As and give it a name
- Watch Preview crash
Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x00000000dce481a4 Crashed Thread: 0 Thread 0 Crashed: 0 libSystem.B.dylib 0x952773af szone_free + 2101 1 com.apple.CoreFoundation 0x9155c826 _CFRelease + 342 2 ...ple.ApplicationServices.ATS 0x906240d4 FindNameAsCFString + 1432 3 ...ple.ApplicationServices.ATS 0x90623acc ATSFontGetPostScriptName + 76 4 libCGATS.A.dylib 0x9364e8e5 get_name_with_name_code_nl + 250 5 libCGATS.A.dylib 0x9364ea67 ats_name_handler_get_postscript_name + 23 6 libCGATS.A.dylib 0x9364fd48 get_postscript_name + 49 7 com.apple.CoreGraphics 0x924f0cd3 CGFontNameTableCreate + 322 8 com.apple.CoreGraphics 0x924f0b73 CGFontGetPostScriptName + 29 9 libPDFRIP.A.dylib 0x18bd81a9 PDFFontType1EmitDefinition + 57 10 libPDFRIP.A.dylib 0x18bd6674 write_definition + 55 11 libPDFRIP.A.dylib 0x18bd4c38 PDFFontEmitDefinitions + 22 12 libPDFRIP.A.dylib 0x18bd6197 emitFontDefinition + 17 13 com.apple.CoreFoundation 0x9155f1fc CFSetApplyFunction + 140 14 libPDFRIP.A.dylib 0x18bd61db PDFFontSetEmitDefinitions + 60 15 libPDFRIP.A.dylib 0x18bd2f8b PDFDocumentFinalize + 385 16 libPDFRIP.A.dylib 0x18bd1c0e pdf_Finalize + 28 17 com.apple.CoreGraphics 0x925567bf CGContextDelegateFinalize + 55 18 com.apple.CoreFoundation 0x9155c786 _CFRelease + 182 19 com.apple.CoreGraphics 0x925567ac CGContextDelegateFinalize + 36 20 com.apple.PDFKit 0x902a418a -[PDFDocument(PDFDocumentInternal) writeToConsumer:withOptions:] + 1491
Filed as Radar (Apple’s Bug Reporter) bug # 5784122. I don’t even enough a way around this. I could try to re-write the PDF, but if the PDF has filled in information, it will become toast. Do I have to write my own PDF code to handle this? Apple has so many technologies that some of the most useful (at least to me) get neglected; there is so much focus on the glitzy stuff that the basics get ignored.
and there’s one thing about pdfkit that sux even more, it is not available for iphone sdk 🙁