Apply max_memory_mb setting to PDF generation

The max_memory_mb setting is only applied to the encryption of PDFs -- This PR applies it to the generation as well