fix: closes pdf file explicitly. Reason: while generating PDFs in batch mode(with same PDF output filename), the PDF file is sometimes not writable for subsequent generation [Dharamveer Salecha]