本文介绍了该文件没有页面。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从数据集 file   code-keyword> 首先时间我可以创建 pdf,但 for  secnd  time 它给我这个错误

这里 我的代码

首先将改为







 公开 无效电子邮件()
{
尝试
{
emaildata();
string userMail = emailname + @ ksmc .med.sa;
使用(StringWriter sw = new StringWriter())
{
使用(HtmlTextWriter hw = new HtmlTextWriter(sw))
{
DetailsView1 .RenderControl(HW);
StringReader sr = new StringReader(sw.ToString());
文件pdfDoc = 文件(PageSize.A4,10f,10f,10f,0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
使用(MemoryStream memoryStream = new MemoryStream())
{
PdfWriter.GetInstance(pdfDoc,memoryStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
byte [] bytes = memoryStream.ToArray();
memoryStream.Close();
}
}
}
}
}





  public   void  emaildata()
{
SqlCommand cmnd = new SqlCommand( SELECT dbo.Tbl_TechRequest.R_RequestNumber, dbo.Tbl_TechRequest.R_name,FROM _TechRequest WHERE(dbo.Tbl_TechRequest.R_RequestNumber +
= @ R_RequestNumber));
cmnd.Connection = con;
cmnd.Parameters.Add( @ R_RequestNumber,SqlDbType.Int).Value = ID;
SqlDataAdapter da = new SqlDataAdapter(cmnd);

da.Fill(ds);
DetailsView1.DataSource = ds;
DetailsView1.DataBind();
}
解决方案

I am creating Pdf file from dataset for first time i can create pdf but for the secnd time its giving me this error

here is my code

for first tim its going to rendercontrol and for the secnd time its giving me this error




public void Email()
    {
        try
        {
            emaildata();
            string userMail = emailname + "@ksmc.med.sa";
            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter hw = new HtmlTextWriter(sw))
                {
                    DetailsView1.RenderControl(hw);
                    StringReader sr = new StringReader(sw.ToString());
                    Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
                    HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
                    using (MemoryStream memoryStream = new MemoryStream())
                    {
                        PdfWriter.GetInstance(pdfDoc, memoryStream);
                        pdfDoc.Open();
                        htmlparser.Parse(sr);
                        pdfDoc.Close();
                        byte[] bytes = memoryStream.ToArray();
                        memoryStream.Close();
                     }
                 }
           }
        }
}



public void emaildata()
   {
       SqlCommand cmnd = new SqlCommand("SELECT dbo.Tbl_TechRequest.R_RequestNumber, dbo.Tbl_TechRequest.R_name, FROM _TechRequest WHERE  (dbo.Tbl_TechRequest.R_RequestNumber" +
            "   =@R_RequestNumber)");
       cmnd.Connection = con;
       cmnd.Parameters.Add("@R_RequestNumber", SqlDbType.Int).Value = id;
       SqlDataAdapter da = new SqlDataAdapter(cmnd);

       da.Fill(ds);
       DetailsView1.DataSource = ds;
       DetailsView1.DataBind();
   }
解决方案


这篇关于该文件没有页面。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 16:50