changed pdf generation to fix #1