How to check if a document has no pages
I am trying to use iTextSharp to convert some HTML mail from Outlook to PDF. Some post gives a problem for HTMLWorker
throwing exceptions.
If this happens, I want to catch the exception and refuse to create the PDF. But I can not. What do I need to do to check and close open correctly Document
?
source to share
Just before calling, Close()
you can check the property of PageNumber
yours Document
to see if there are any pages.
if (doc.PageNumber == 0) {
//Do something here
}
doc.Close();
In addition, the class is HTMLWorker
not actively developed . Instead, almost all of the new HTML parsing code runs in a separate library called XMLWorker
. Below is @kuujinbo's sample code.
source to share