> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Jason Frank > Sent: Friday, January 20, 2006 4:44 PM > To: [email protected] > Subject: [iText-questions] Re: Exception on document.Close() > when doc is empty (iTextSharp v3.0.9) > > Paulo Soares <psoares <at> consiste.pt> writes: > > > > > There's nothing to fix and never was. If you want to check > for an empty > > doc: > > > > doc.NewPage(); > > if (writer.PageNumber == 1) //empty > > Thanks for the quick reply. > > I suppose the reason that you can't close an empty document > is that such a > document would be an invalid PDF doc. > > So, a follow-up question is, what can I do with an empty > document to get rid > of it? Right now I'm adding dummy content just so I can > close it and delete > the associated file. Is there a better way to clean up the > doc once I've > realized that it's empty? If I do not successfully close the > doc, it seems > that I cannot delete the associated file because it is > locked. Again, my > solution is to add dummy content, which works, but seems a > bit of a hack. >
You can close the FileStream directly and then delete the file. > > > > > -----Original Message----- > > > From: itext-questions-admin <at> lists.sourceforge.net > > > [mailto:itext-questions-admin <at> lists.sourceforge.net] On > > > Behalf Of Jason Frank > > > Sent: Friday, January 20, 2006 3:06 PM > > > To: itext-questions <at> lists.sourceforge.net > > > Subject: [iText-questions] Exception on document.Close() when > > > doc is empty (iTextSharp v3.0.9) > > > > > > I'm using iTextSharp, version 3.0.9. > > > > > > Sometimes I create a document, and through some combination > > > of factors nothing > > > ever gets added to that document. When I try do call > > > doc.Close(), I get an > > > exception that the document has no pages. > > > > > > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep > through log files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. > DOWNLOAD SPLUNK! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486& > dat=121642 > _______________________________________________ > iText-questions mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/itext-questions > ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642 _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
