Попробуйте этот подход:
public override string GenerateReport()
{
string sFileLocation = m_sFileName == null ? (Path.GetTempFileName() + ".pdf") : (Path.GetTempPath() + m_sFileName);
FileStream aNewFileStream = new FileStream(sFileLocation, FileMode.Create);
Byte[] bytes;
using (var ms = new MemoryStream())
{
using (Document document = new Document(PageSize.A4, PdfEventsBase.PAGE_MARGIN_LEFT, PdfEventsBase.PAGE_MARGIN_RIGHT, PdfEventsBase.PAGE_MARGIN_TOP, PdfEventsBase.PAGE_MARGIN_BOTTOM))
{
using (PdfWriter aPdfWriter = PdfWriter.GetInstance(document, aNewFileStream))
{
aPdfWriter.PageEvent = new PdfEventsPageTemplate(null, Sites.PAA, null);
document.Open();
using (var msCss = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(m_sCSS)))
{
using (var msHtml = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(m_sHTML)))
{
//Parse the HTML
iTextSharp.tool.xml.XMLWorkerHelper.GetInstance().ParseXHtml(aPdfWriter, document, msHtml, msCss);
}
}
document.Close();
}
}
bytes = ms.ToArray();
}
//System.IO.File.WriteAllBytes(sFileLocation, bytes);
return sFileLocation;
}