Attempt to encode pdf errors properly.