locked
Using PDFSharp - PDF content inside panel - does not output RRS feed

  • Question

  • User364480375 posted

    here is my code adapted from: http://www.aspsnippets.com/Articles/Export-ASPNet-Panel-contents-to-PDF-using-iTextSharp.aspx

            <asp:Panel ID="Panel1" runat="server">
        <div  style="overflow-x: auto; overflow-y: hidden;padding: 0 0 17px; width: 100%;">
        <table  border="1" style="background-color: #FFFFCC; border-collapse: collapse; border: 1px solid #FFCC00;color: #000000; width: 100%" cellpadding="3" cellspacing="3">
            
            <tr align="center" style="height: 40px;">
                <td rowspan="3">
                    <strong>अंचल</strong>
                </td>        
                 </tr>
            <tr align="center" style="height: 40px;">
                <td colspan="5" align="center">
                    <strong>2010-2011</strong></td>
                <td colspan="5" align="center">
                    <strong>2011-2012</strong></td>
                <td colspan="5">
                    <strong>2012-2013</strong></td>
                <td colspan="5">
                    <strong>2013-2014</strong></td>
                <td colspan="5">
                    <strong>2014-2015</strong></td>  
                     <td colspan="5">
                    <strong>2015-2016</strong></td>       
                    <td colspan="1">
                    <strong>प्रतिवेदित माह तक लंबित योजनायें </strong></td>                      
            </tr>
            <tr align="center" style="height: 40px;">
            <td>
                    <strong>स्वीकृत संख्या</strong></td>
                <td>
                    <strong>कार्य प्रारम्भ संख्या</strong> </td>
                <td>
                     <strong>कार्य संपन्न&nbsp; संख्या</strong></td>
                  <td>
                      <strong>लंबित संख्या</strong><td>
                    <strong>इस वर्ष में पूर्ण संख्या</strong></td>
                 <td>
                    <strong>स्वीकृत संख्या</strong></td>
                <td>
                    <strong>कार्य प्रारम्भ संख्या</strong> </td>
                <td>
                     <strong>कार्य संपन्न&nbsp; संख्या</strong></td>
                  <td>
                      <strong>लंबित संख्या</strong><td>
                    <strong>इस वर्ष में पूर्ण संख्या</strong></td>
                     <td>
                    <strong>स्वीकृत संख्या</strong></td>
                <td>
                    <strong>कार्य प्रारम्भ संख्या</strong> </td>
                <td>
                     <strong>कार्य संपन्न&nbsp; संख्या</strong></td>
                  <td>
                      <strong>लंबित संख्या</strong><td>
                    <strong>इस वर्ष में पूर्ण संख्या</strong></td>
                     <td>
                    <strong>स्वीकृत संख्या</strong></td>
                <td>
                    <strong>कार्य प्रारम्भ संख्या</strong> </td>
                <td>
                     <strong>कार्य संपन्न&nbsp; संख्या</strong></td>
                  <td>
                      <strong>लंबित संख्या</strong><td>
                    <strong>इस वर्ष में पूर्ण संख्या</strong></td>
                     <td>
                    <strong>स्वीकृत संख्या</strong></td>
                <td>
                    <strong>कार्य प्रारम्भ संख्या</strong> </td>
                <td>
                     <strong>कार्य संपन्न&nbsp; संख्या</strong></td>
                  <td>
                      <strong>लंबित संख्या</strong><td>
                    <strong>इस वर्ष में पूर्ण संख्या</strong></td>
                 <td>
                    <strong>स्वीकृत संख्या</strong></td>
                <td>
                    <strong>कार्य प्रारम्भ संख्या</strong> </td>
                <td>
                     <strong>कार्य संपन्न&nbsp; संख्या</strong></td>
                  <td>
                      <strong>लंबित संख्या</strong><td>
                    <strong>इस वर्ष में पूर्ण संख्या</strong></td>
                      <td>
                     </td>
            </tr>
            <tr align="center" style="height: 30px;">
                <td>
                    1
                </td>
                <td>
                    2
                </td>
                <td>
                    3
                </td>
                <td>
                    4
                </td>
                <td>
                    5
                </td>
                <td>
                    6
                </td>
                <td>
                    7
                </td>
                <td>
                    8
                </td>
                <td>
                    9
                </td>
                <td>
                    10
                </td>
                <td>
                    11
                </td>
                <td>
                    12
                </td>
                <td>
                    13
                </td>
                <td>
                    14
                </td>
                <td>
                    15
                </td>
                <td>
                    16
                </td>   
                 <td>
                    17
                </td>   
                    <td>
                    18
                </td>  
                   <td>
                    19
                </td>   
                 <td>
                    20
                </td>   
                    <td>
                    21
                </td>   
                
                    <td>
                    22
                </td>   
            
                    <td>
                    23
                </td>   
             
                    <td>
                    24
                </td>   
                
                    <td>
                    25
                </td>  
      
                    <td>
                    26
                </td>   
                
                    <td>
                    27
                </td> 
                    <td>
                    28
                </td>   
                 
                    <td>
                    29
                </td>
                    <td>
                    30
                </td>   
                
                    <td>
                    31
                </td>    
                   <td>
                    32
                </td>    
                
            </tr>
            <asp:Repeater ID="Repeater1" runat="server">
                       <ItemTemplate>
            <tr style="height: 40px;" align="center">
                <td width="100px">
                   <%# Eval("CircleHName")%>
                </td>           
                <td width="75px">
                    <%# Eval("cell_02")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_03")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_04")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_05")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_06")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_07")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_08")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_09")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_10")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_11")%>
                </td>     
                    <td width="50px">
                    <%# Eval("cell_12")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_13")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_14")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_15")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_16")%>
                    </td>
                    <td width="50px">
                    <%# Eval("cell_17")%>
                </td>
                 <td width="50px">
                    <%# Eval("cell_18")%>
                    </td>
                    <td width="50px">
                    <%# Eval("cell_19")%>
                </td>
                 <td width="50px">
                    <%# Eval("cell_20")%>
                    </td>
                    <td width="50px">
                    <%# Eval("cell_21")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_22")%>
                    </td>
                    <td width="50px">
                    <%# Eval("cell_23")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_24")%>
                    </td>
                    <td width="50px">
                    <%# Eval("cell_25")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_26")%>
                    </td>
                    <td width="50px">
                    <%# Eval("cell_27")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_28")%>
                    </td>
                    <td width="50px">
                    <%# Eval("cell_29")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_30")%>
                    </td>
                    <td width="50px">
                    <%# Eval("cell_31")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_32")%>
                    </td>    
                
            </tr>  
              </ItemTemplate>
                        </asp:Repeater>  
            <asp:Repeater ID="Repeater2" runat="server">
                       <ItemTemplate>
            <tr style="height: 40px;  font-weight:bold;" align="center">
                <td width="100px">
                    Total
    
                </td>           
                <td width="75px">
                    <%# Eval("cell_02")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_03")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_04")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_05")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_06")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_07")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_08")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_09")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_10")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_11")%>
                </td>
                 <td width="50px">
                    <%# Eval("cell_12")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_13")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_14")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_15")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_16")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_17")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_18")%>
                
                <td width="50px">
                    <%# Eval("cell_19")%>
                </td>
                 <td width="50px">
                    <%# Eval("cell_20")%>
                    </td>
                    <td width="50px">
                    <%# Eval("cell_21")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_22")%>
                    </td>
                    <td width="50px">
                    <%# Eval("cell_23")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_24")%>
                    </td>
                    <td width="50px">
                    <%# Eval("cell_25")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_26")%>
                    </td>
                    <td width="50px">
                    <%# Eval("cell_27")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_28")%>
                    </td>
                    <td width="50px">
                    <%# Eval("cell_29")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_30")%>
                    </td>
                    <td width="50px">
                    <%# Eval("cell_31")%>
                </td>
                <td width="50px">
                    <%# Eval("cell_32")%>
                    </td>
            </tr>  
              </ItemTemplate>
                        </asp:Repeater>
                 
        </table>  
        </asp:Panel>    
    
    using System.IO;
    using System.Data;
    using iTextSharp.text;
    using iTextSharp.text.pdf;
    using iTextSharp.text.html.simpleparser;
    


    protected void btnExport_Click(object sender, EventArgs e)
    {
    Response.ContentType = "application/pdf";
    Response.AddHeader("content-disposition", "attachment;filename=Panel.pdf");
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    StringWriter sw = new StringWriter();
    HtmlTextWriter hw = new HtmlTextWriter(sw);
    Panel1.RenderControl(hw);
    StringReader sr = new StringReader(sw.ToString());
    Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
    HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
    PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
    pdfDoc.Open();
    htmlparser.Parse(sr);
    pdfDoc.Close();
    Response.Write(pdfDoc);
    Response.End();
    }

     

    I am not able to get  design in my pdf. so plz assist.

    Wednesday, April 13, 2016 10:22 AM

All replies