Added check for pdf_generation before adding it to the output