Extended the check if PDF is empty before closing the document.
Merge pull request #359 from B3nRa/issue#346

Extended the check if PDF is empty before closing the document.