More work on the PDF generation (attempts to fix the image resolution problem).