mandag den 3. juni 2013

Dashed line error in Apple PDF viewer

I had the Apple PDF viewer choke on a PDF document which worked wine in other PDF viewers. I tracked it down to a funny dashed line. As can be seen on page 155 of the PDF specification for the third edition, dashed lines are specified as fx "[1 2] 0", which means 1 unit on, 2 units off. To stop dashing, you should write a dash specification of "[] 0".

I had a pdf which tried to stop dashing by writing "[ 1 0 ] 0" ("[ 1 0 ] 0 d" actually, I haven't looked into what the "d" means). This worked fine in most PDF viewers, but in Apple's viewer the document stopped rendering at that point. I assume that it is the 0-gap (the first "0") which confuses it. Fixing the PDF generator to use the "[] 0 d" from the specification made it work in Apple's PDF viewer.

So now you know, if you come across the same problem :). I would report it to Apple, but they don't seem to let you report bugs if you do not have an Apple ID.