Exporting WebPage to PDF...

Updated vishalrane 1 Tallied Votes 334 Views Share

All the webpage data will be converted into PDF file, You can also add details such as ur name etc by using

Chunk chunk1 = new Chunk("By Vishal RAne, vishalrane50@example.com \n",FontFactory.GetFont("Verdana", 8));

The pdf will be saved on desktop....
u can change location by using

PdfWriter.GetInstance(Doc, new FileStream(Environment.GetFolderPath
(Environment.SpecialFolder.Desktop)+ "\\VishalRane.pdf", FileMode.Create));

<%@ Page Language="C#" AutoEventWireup="true"  
CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" 
             AutoGenerateColumns="False" 
             DataSourceID="SqlDataSource1" Width="257px">
        <Columns>
             <asp:BoundField DataField="Name" 
                  HeaderText="Name" 
                  SortExpression="Name" />
             <asp:BoundField DataField="Location" 
                  HeaderText="Location" 
                  SortExpression="Location" />
        </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" 
             runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="SELECT [Name], [Location] FROM [Test]">
        </asp:SqlDataSource>
    
    </div>
        <br />
        <asp:Button ID="btnExport" runat="server" 
             OnClick="btnExport_Click" 
             Text="Export to PDF" />
        
    </form>
</body>
</html>



default.aspx.cs code:


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html;
using System.IO;
using System.Collections;
using System.Net;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnExport_Click(object sender, EventArgs e)
    {
        HtmlForm form = new HtmlForm();
        form.Controls.Add(GridView1);
        StringWriter sw = new StringWriter();
        HtmlTextWriter hTextWriter = new HtmlTextWriter(sw);
        form.Controls[0].RenderControl(hTextWriter);
        string html = sw.ToString();
        Document Doc = new Document();
                
        //PdfWriter.GetInstance
        //(Doc, new FileStream(Request.PhysicalApplicationPath 
        //+ "\\AmitJain.pdf", FileMode.Create));

        PdfWriter.GetInstance(Doc, new FileStream(Environment.GetFolderPath
        (Environment.SpecialFolder.Desktop)+ "\\VishalRane.pdf", FileMode.Create));
        Doc.Open();
        
        Chunk c = new Chunk("Export GridView to PDF Using iTextSharp \n",FontFactory.GetFont("Verdana", 15));
        Paragraph p = new Paragraph();
        p.Alignment = Element.ALIGN_CENTER;
        p.Add(c);
        Chunk chunk1 = new Chunk("By Vishal RAne, vishalrane50@gmail.com \n",FontFactory.GetFont("Verdana", 8));
        Paragraph p1 = new Paragraph();
        p1.Alignment = Element.ALIGN_RIGHT;
        p1.Add(chunk1);
             
        Doc.Add(p);
        Doc.Add(p1);
                
        System.Xml.XmlTextReader xmlReader = 
        new System.Xml.XmlTextReader(new StringReader(html));
        HtmlParser.Parse(Doc, xmlReader);
        
        Doc.Close();
        string Path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)+ "\\AmitJain.pdf";
        
        
        
        ShowPdf(Path);
       
        
    }

    private void ShowPdf(string strS)
    {
        Response.ClearContent();
        Response.ClearHeaders();
        Response.ContentType = "application/pdf";
        Response.AddHeader("Content-Disposition","attachment; filename=" + strS);
        Response.TransmitFile(strS);
        Response.End();
        //Response.WriteFile(strS);
        Response.Flush();
        Response.Clear();
 
    }
    
}
prashantpaw 0 Newbie Poster
<%@ Page Language="C#" AutoEventWireup="true"  
CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" 
             AutoGenerateColumns="False" 
             DataSourceID="SqlDataSource1" Width="257px">
        <Columns>
             <asp:BoundField DataField="Name" 
                  HeaderText="Name" 
                  SortExpression="Name" />
             <asp:BoundField DataField="Location" 
                  HeaderText="Location" 
                  SortExpression="Location" />
        </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" 
             runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="SELECT [Name], [Location] FROM [Test]">
        </asp:SqlDataSource>
    
    </div>
        <br />
        <asp:Button ID="btnExport" runat="server" 
             OnClick="btnExport_Click" 
             Text="Export to PDF" />
        
    </form>
</body>
</html>



default.aspx.cs code:


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html;
using System.IO;
using System.Collections;
using System.Net;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnExport_Click(object sender, EventArgs e)
    {
        HtmlForm form = new HtmlForm();
        form.Controls.Add(GridView1);
        StringWriter sw = new StringWriter();
        HtmlTextWriter hTextWriter = new HtmlTextWriter(sw);
        form.Controls[0].RenderControl(hTextWriter);
        string html = sw.ToString();
        Document Doc = new Document();
                
        //PdfWriter.GetInstance
        //(Doc, new FileStream(Request.PhysicalApplicationPath 
        //+ "\\AmitJain.pdf", FileMode.Create));

        PdfWriter.GetInstance(Doc, new FileStream(Environment.GetFolderPath
        (Environment.SpecialFolder.Desktop)+ "\\VishalRane.pdf", FileMode.Create));
        Doc.Open();
        
        Chunk c = new Chunk("Export GridView to PDF Using iTextSharp \n",FontFactory.GetFont("Verdana", 15));
        Paragraph p = new Paragraph();
        p.Alignment = Element.ALIGN_CENTER;
        p.Add(c);
        Chunk chunk1 = new Chunk("By Vishal RAne, vishalrane50@gmail.com \n",FontFactory.GetFont("Verdana", 8));
        Paragraph p1 = new Paragraph();
        p1.Alignment = Element.ALIGN_RIGHT;
        p1.Add(chunk1);
             
        Doc.Add(p);
        Doc.Add(p1);
                
        System.Xml.XmlTextReader xmlReader = 
        new System.Xml.XmlTextReader(new StringReader(html));
        HtmlParser.Parse(Doc, xmlReader);
        
        Doc.Close();
        string Path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)+ "\\AmitJain.pdf";
        
        
        
        ShowPdf(Path);
       
        
    }

    private void ShowPdf(string strS)
    {
        Response.ClearContent();
        Response.ClearHeaders();
        Response.ContentType = "application/pdf";
        Response.AddHeader("Content-Disposition","attachment; filename=" + strS);
        Response.TransmitFile(strS);
        Response.End();
        //Response.WriteFile(strS);
        Response.Flush();
        Response.Clear();
 
    }
    
}

Hi Vishal,
Using your logic for PDF export I tried to export my html to PDF, the html is an external file that contain the HTML code but I received an error -

Exception Messages:
String was not recognized as a valid Boolean.

HTML - htmltoPDF.html

<DIV id="Div1" class="TabBody" style="Z-INDEX:123;LEFT:14px;WIDTH:99%;POSITION:absolute;TOP:10px;HEIGHT:570px;VISIBILITY:visible;" ms_positioning="GridLayout">
<table width="100%" cellpadding="0" cellspacing="0">
	<tr>
		<th align="center" colspan="4" style="font:14pt verdana;">Stacking Plan</th>
	</tr>
	<tr>
		<th align="center" colspan="4" style="font:10pt verdana;">Pacific View Center prop addr1 (acom6401)</th>
	</tr>
	<tr>
		<td style="font:10pt verdana;font-weight:bold;border-bottom:1px solid black;" width="5%">Floor</td>
		<td width="4.5%" align="right" style="font:10pt verdana;font-weight:bold;border-bottom:1px solid black;">Area</td>
		<td width="0.5%" align="right" style="font:10pt verdana;font-weight:bold;border-bottom:1px solid black;"></td>
		<td width="90%" align="center" style="font:10pt verdana;font-weight:bold;border-bottom:1px solid black;">Tenant</td>
	</tr>
	<tr>
		<td nowrap="nowrap" style="border-right:5px solid white;">F1</td>
		<td align="right">1,000.00</td>
		<td align="right"></td>
		<td><table cellspacing="0" cellpadding="0" border="0">
			<tr>
				<td bgcolor="black" width="989px" align="center" style="border-right:1px solid white;border-bottom:0px;"><div style="width:989px;text-overflow:clip;overflow:hidden;color:white;">
					Vacant
				</div></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td></td>
		<td align="right"></td>
		<td align="right"></td>
		<td><table cellspacing="0" cellpadding="0" border="0">
			<tr>
				<td bgcolor="black" width="989px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:989px;text-overflow:clip;overflow:hidden;color:white;">
					Z1(1,000.00)
				</div></td>
			</tr>
		</table>
		</td>
		<td></td>
	</tr>
	<tr>
		<td></td>
		<td align="right"></td>
		<td align="right"></td>
		<td><table cellspacing="0" cellpadding="0" border="0">
			<tr>
				<td bgcolor="black" width="989px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:989px;text-overflow:clip;overflow:hidden;color:white;">
					Commercial
				</div></td>
			</tr>
		</table>
		</td>
		<td></td>
	</tr>
	<tr>
		<td></td>
		<td align="right"></td>
		<td align="right"></td>
		<td><table cellspacing="0" cellpadding="0" border="0">
			<tr>
				<td bgcolor="black" width="989px" align="center" style="border-right:1px solid white;border-bottom:1px solid white;"><div style="width:989px;text-overflow:clip;overflow:hidden;color:white;">

				</div></td>
			</tr>
		</table>
		</td>
		<td></td>
	</tr>
	<tr>
		<td nowrap="nowrap" style="border-right:5px solid white;">Undefined</td>
		<td align="right">254,285.00</td>
		<td align="right"></td>
		<td><table cellspacing="0" cellpadding="0" border="0">
			<tr>
				<td bgcolor="black" width="55px" align="center" style="border-right:1px solid white;border-bottom:0px;"><div style="width:55px;text-overflow:clip;overflow:hidden;color:white;">
					Vacant - [1]
				</div></td>
				<td bgcolor="black" width="46px" align="center" style="border-right:1px solid white;border-bottom:0px;"><div style="width:46px;text-overflow:clip;overflow:hidden;color:white;">
					Vacant - [2]
				</div></td>
				<td bgcolor="black" width="94px" align="center" style="border-right:1px solid white;border-bottom:0px;"><div style="width:94px;text-overflow:clip;overflow:hidden;color:white;">
					Vacant - [3]
				</div></td>
				<td bgcolor="black" width="77px" align="center" style="border-right:1px solid white;border-bottom:0px;"><div style="width:77px;text-overflow:clip;overflow:hidden;color:white;">
					Vacant - [4]
				</div></td>
				<td bgcolor="black" width="303px" align="center" style="border-right:1px solid white;border-bottom:0px;"><div style="width:303px;text-overflow:clip;overflow:hidden;color:white;">
					Vacant
				</div></td>
				<td bgcolor="black" width="133px" align="center" style="border-right:1px solid white;border-bottom:0px;"><div style="width:133px;text-overflow:clip;overflow:hidden;color:white;">
					Vacant - [5]
				</div></td>
				<td bgcolor="black" width="0px" align="center" style="border-right:1px solid white;border-bottom:0px;"><div style="width:0px;text-overflow:clip;overflow:hidden;color:white;">
					Vacant - [6]
				</div></td>
				<td bgcolor="black" width="167px" align="center" style="border-right:1px solid white;border-bottom:0px;"><div style="width:167px;text-overflow:clip;overflow:hidden;color:white;">
					Vacant - [7]
				</div></td>
				<td bgcolor="black" width="51px" align="center" style="border-right:1px solid white;border-bottom:0px;"><div style="width:51px;text-overflow:clip;overflow:hidden;color:white;">
					Vacant - [8]
				</div></td>
				<td bgcolor="black" width="17px" align="center" style="border-right:1px solid white;border-bottom:0px;"><div style="width:17px;text-overflow:clip;overflow:hidden;color:white;">
					Vacant - [9]
				</div></td>
				<td bgcolor="black" width="21px" align="center" style="border-right:1px solid white;border-bottom:0px;"><div style="width:21px;text-overflow:clip;overflow:hidden;color:white;">
					Vacant - [10]
				</div></td>
				<td bgcolor="black" width="14px" align="center" style="border-right:1px solid white;border-bottom:0px;"><div style="width:14px;text-overflow:clip;overflow:hidden;color:white;">
					Vacant - [11]
				</div></td>
				<td bgcolor="black" width="0px" align="center" style="border-right:1px solid white;border-bottom:0px;"><div style="width:0px;text-overflow:clip;overflow:hidden;color:white;">
					Vacant - [12]
				</div></td>
				<td bgcolor="black" width="0px" align="center" style="border-right:1px solid white;border-bottom:0px;"><div style="width:0px;text-overflow:clip;overflow:hidden;color:white;">
					Vacant - [13]
				</div></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td></td>
		<td align="right"></td>
		<td align="right"></td>
		<td><table cellspacing="0" cellpadding="0" border="0">
			<tr>
				<td bgcolor="black" width="55px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:55px;text-overflow:clip;overflow:hidden;color:white;">
					6401(14,500.00)
				</div></td>
				<td bgcolor="black" width="46px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:46px;text-overflow:clip;overflow:hidden;color:white;">
					6402(12,000.00)
				</div></td>
				<td bgcolor="black" width="94px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:94px;text-overflow:clip;overflow:hidden;color:white;">
					6403(24,500.00)
				</div></td>
				<td bgcolor="black" width="77px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:77px;text-overflow:clip;overflow:hidden;color:white;">
					6404(20,000.00)
				</div></td>
				<td bgcolor="black" width="303px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:303px;text-overflow:clip;overflow:hidden;color:white;">
					6405(78,000.00)
				</div></td>
				<td bgcolor="black" width="133px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:133px;text-overflow:clip;overflow:hidden;color:white;">
					6406(34,500.00)
				</div></td>
				<td bgcolor="black" width="0px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:0px;text-overflow:clip;overflow:hidden;color:white;">
					6407(0.00)
				</div></td>
				<td bgcolor="black" width="167px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:167px;text-overflow:clip;overflow:hidden;color:white;">
					6408(43,200.00)
				</div></td>
				<td bgcolor="black" width="51px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:51px;text-overflow:clip;overflow:hidden;color:white;">
					6409(13,455.00)
				</div></td>
				<td bgcolor="black" width="17px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:17px;text-overflow:clip;overflow:hidden;color:white;">
					6410(4,500.00)
				</div></td>
				<td bgcolor="black" width="21px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:21px;text-overflow:clip;overflow:hidden;color:white;">
					6411(5,750.00)
				</div></td>
				<td bgcolor="black" width="14px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:14px;text-overflow:clip;overflow:hidden;color:white;">
					6412(3,880.00)
				</div></td>
				<td bgcolor="black" width="0px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:0px;text-overflow:clip;overflow:hidden;color:white;">
					6414(0.00)
				</div></td>
				<td bgcolor="black" width="0px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:0px;text-overflow:clip;overflow:hidden;color:white;">
					ANCHOR(0.00)
				</div></td>
			</tr>
		</table>
		</td>
		<td></td>
	</tr>
	<tr>
		<td></td>
		<td align="right"></td>
		<td align="right"></td>
		<td><table cellspacing="0" cellpadding="0" border="0">
			<tr>
				<td bgcolor="black" width="55px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:55px;text-overflow:clip;overflow:hidden;color:white;">
					Association
				</div></td>
				<td bgcolor="black" width="46px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:46px;text-overflow:clip;overflow:hidden;color:white;">
					Commercial
				</div></td>
				<td bgcolor="black" width="94px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:94px;text-overflow:clip;overflow:hidden;color:white;">
					Commercial
				</div></td>
				<td bgcolor="black" width="77px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:77px;text-overflow:clip;overflow:hidden;color:white;">
					Commercial
				</div></td>
				<td bgcolor="black" width="303px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:303px;text-overflow:clip;overflow:hidden;color:white;">
					Commercial
				</div></td>
				<td bgcolor="black" width="133px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:133px;text-overflow:clip;overflow:hidden;color:white;">
					Commercial
				</div></td>
				<td bgcolor="black" width="0px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:0px;text-overflow:clip;overflow:hidden;color:white;">
					Commercial
				</div></td>
				<td bgcolor="black" width="167px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:167px;text-overflow:clip;overflow:hidden;color:white;">
					Commercial
				</div></td>
				<td bgcolor="black" width="51px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:51px;text-overflow:clip;overflow:hidden;color:white;">
					Commercial
				</div></td>
				<td bgcolor="black" width="17px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:17px;text-overflow:clip;overflow:hidden;color:white;">
					Commercial
				</div></td>
				<td bgcolor="black" width="21px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:21px;text-overflow:clip;overflow:hidden;color:white;">
					Commercial
				</div></td>
				<td bgcolor="black" width="14px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:14px;text-overflow:clip;overflow:hidden;color:white;">
					Commercial
				</div></td>
				<td bgcolor="black" width="0px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:0px;text-overflow:clip;overflow:hidden;color:white;">
					Commercial
				</div></td>
				<td bgcolor="black" width="0px" align="center" style="border-right:1px solid white;border-bottom:0px;border-top:0px;"><div style="width:0px;text-overflow:clip;overflow:hidden;color:white;">
					Commercial
				</div></td>
			</tr>
		</table>
		</td>
		<td></td>
	</tr>
	<tr>
		<td></td>
		<td align="right"></td>
		<td align="right"></td>
		<td><table cellspacing="0" cellpadding="0" border="0">
			<tr>
				<td bgcolor="black" width="55px" align="center" style="border-right:1px solid white;border-bottom:1px solid white;"><div style="width:55px;text-overflow:clip;overflow:hidden;color:white;">

				</div></td>
				<td bgcolor="black" width="46px" align="center" style="border-right:1px solid white;border-bottom:1px solid white;"><div style="width:46px;text-overflow:clip;overflow:hidden;color:white;">

				</div></td>
				<td bgcolor="black" width="94px" align="center" style="border-right:1px solid white;border-bottom:1px solid white;"><div style="width:94px;text-overflow:clip;overflow:hidden;color:white;">

				</div></td>
				<td bgcolor="black" width="77px" align="center" style="border-right:1px solid white;border-bottom:1px solid white;"><div style="width:77px;text-overflow:clip;overflow:hidden;color:white;">

				</div></td>
				<td bgcolor="black" width="303px" align="center" style="border-right:1px solid white;border-bottom:1px solid white;"><div style="width:303px;text-overflow:clip;overflow:hidden;color:white;">

				</div></td>
				<td bgcolor="black" width="133px" align="center" style="border-right:1px solid white;border-bottom:1px solid white;"><div style="width:133px;text-overflow:clip;overflow:hidden;color:white;">

				</div></td>
				<td bgcolor="black" width="0px" align="center" style="border-right:1px solid white;border-bottom:1px solid white;"><div style="width:0px;text-overflow:clip;overflow:hidden;color:white;">

				</div></td>
				<td bgcolor="black" width="167px" align="center" style="border-right:1px solid white;border-bottom:1px solid white;"><div style="width:167px;text-overflow:clip;overflow:hidden;color:white;">

				</div></td>
				<td bgcolor="black" width="51px" align="center" style="border-right:1px solid white;border-bottom:1px solid white;"><div style="width:51px;text-overflow:clip;overflow:hidden;color:white;">

				</div></td>
				<td bgcolor="black" width="17px" align="center" style="border-right:1px solid white;border-bottom:1px solid white;"><div style="width:17px;text-overflow:clip;overflow:hidden;color:white;">

				</div></td>
				<td bgcolor="black" width="21px" align="center" style="border-right:1px solid white;border-bottom:1px solid white;"><div style="width:21px;text-overflow:clip;overflow:hidden;color:white;">

				</div></td>
				<td bgcolor="black" width="14px" align="center" style="border-right:1px solid white;border-bottom:1px solid white;"><div style="width:14px;text-overflow:clip;overflow:hidden;color:white;">

				</div></td>
				<td bgcolor="black" width="0px" align="center" style="border-right:1px solid white;border-bottom:1px solid white;"><div style="width:0px;text-overflow:clip;overflow:hidden;color:white;">

				</div></td>
				<td bgcolor="black" width="0px" align="center" style="border-right:1px solid white;border-bottom:1px solid white;"><div style="width:0px;text-overflow:clip;overflow:hidden;color:white;">

				</div></td>
			</tr>
		</table>
		</td>
		<td></td>
	</tr>
	<tr>
		<td>  </td>
	</tr>
</table>
<table width="80%" height="15%">
	<tr style="font:10pt verdana;" align="center" height="25%">
		<td width="13%"></td>
		<td width="2.5%">  </td>
		<td width="6.5%">Vacant</td>
		<td width="6.5%">M to M</td>
		<td width="6.5%">2011</td>
		<td width="6.5%">2012</td>
		<td width="6.5%">2013</td>
		<td width="6.5%">2014</td>
		<td width="6.5%">2015</td>
		<td width="6.5%">2016</td>
		<td width="6.5%">2017</td>
		<td width="6.5%">2018</td>
		<td width="6.5%">2019</td>
		<td width="6.5%">2020</td>
		<td width="6.5%">&gt; 2020</td>
	</tr>
	<tr height="25%%" align="center">
		<td width="13%"></td>
		<td width="2.5%">  </td>
		<td width="6.5%" bgcolor="black"></td>
		<td width="6.5%" bgcolor="brown"></td>
		<td width="6.5%" bgcolor="Orange"></td>
		<td width="6.5%" bgcolor="Green"></td>
		<td width="6.5%" bgcolor="LightBlue"></td>
		<td width="6.5%" bgcolor="lightpink"></td>
		<td width="6.5%" bgcolor="lightslategray"></td>
		<td width="6.5%" bgcolor="gray"></td>
		<td width="6.5%" bgcolor="lime"></td>
		<td width="6.5%" bgcolor="Aqua"></td>
		<td width="6.5%" bgcolor="HotPink"></td>
		<td width="6.5%" bgcolor="Tan"></td>
		<td width="6.5%" bgcolor="Gold"></td>
	</tr>
	<tr height="25%" align="center">
		<td width="13%">Area Expiring</td>
		<td width="2.5%">  </td>
		<td width="6.5%">255,285.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
	</tr>
	<tr height="25%" align="center">
		<td width="13%">% Expiring</td>
		<td width="2.5%">  </td>
		<td width="6.5%">100.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
		<td width="6.5%">0.00</td>
	</tr>
	<tr>
		<td>  </td>
	</tr>
</table>
<table align="center" width="80%">
	<tr>
		<th align="center" colspan="4" style="font:12pt verdana;">Legend for Small Segments</th>
	</tr>
	<tr>
		<th align="center" style="font:10pt verdana;">Segment</th>
		<th align="center" style="font:10pt verdana;">Tenant</th>
		<th align="center" style="font:10pt verdana;">Area</th>
		<th align="center" style="font:10pt verdana;">Lease Exp</th>
	</tr>
	<tr style="font:14pt verdana;" align="center">
		<td>1</td>
		<td align="left">Vacant - 6401</td>
		<td align="right">14,500.00</td>
		<td>--</td>
	</tr>
	<tr style="font:14pt verdana;" align="center">
		<td>2</td>
		<td align="left">Vacant - 6402</td>
		<td align="right">12,000.00</td>
		<td>--</td>
	</tr>
	<tr style="font:14pt verdana;" align="center">
		<td>3</td>
		<td align="left">Vacant - 6403</td>
		<td align="right">24,500.00</td>
		<td>--</td>
	</tr>
	<tr style="font:14pt verdana;" align="center">
		<td>4</td>
		<td align="left">Vacant - 6404</td>
		<td align="right">20,000.00</td>
		<td>--</td>
	</tr>
	<tr style="font:14pt verdana;" align="center">
		<td>5</td>
		<td align="left">Vacant - 6406</td>
		<td align="right">34,500.00</td>
		<td>--</td>
	</tr>
	<tr style="font:14pt verdana;" align="center">
		<td>6</td>
		<td align="left">Vacant - 6407</td>
		<td align="right">0.00</td>
		<td>--</td>
	</tr>
	<tr style="font:14pt verdana;" align="center">
		<td>7</td>
		<td align="left">Vacant - 6408</td>
		<td align="right">43,200.00</td>
		<td>--</td>
	</tr>
	<tr style="font:14pt verdana;" align="center">
		<td>8</td>
		<td align="left">Vacant - 6409</td>
		<td align="right">13,455.00</td>
		<td>--</td>
	</tr>
	<tr style="font:14pt verdana;" align="center">
		<td>9</td>
		<td align="left">Vacant - 6410</td>
		<td align="right">4,500.00</td>
		<td>--</td>
	</tr>
	<tr style="font:14pt verdana;" align="center">
		<td>10</td>
		<td align="left">Vacant - 6411</td>
		<td align="right">5,750.00</td>
		<td>--</td>
	</tr>
	<tr style="font:14pt verdana;" align="center">
		<td>11</td>
		<td align="left">Vacant - 6412</td>
		<td align="right">3,880.00</td>
		<td>--</td>
	</tr>
	<tr style="font:14pt verdana;" align="center">
		<td>12</td>
		<td align="left">Vacant - 6414</td>
		<td align="right">0.00</td>
		<td>--</td>
	</tr>
	<tr style="font:14pt verdana;" align="center">
		<td>13</td>
		<td align="left">Vacant - ANCHOR</td>
		<td align="right">0.00</td>
		<td>--</td>
	</tr>
</table>
</DIV>

Please can you help me out in resolving the error.

vishalrane 0 Junior Poster in Training

Do You want to save source code in pdf file????????

vishalrane 0 Junior Poster in Training

Is your problem regarding asp.net

prashantpaw 0 Newbie Poster

Hi Vishal,
The above HTML is in external file, I need to parse it and print the outcome in PDF. to see the output of the html please copy the code in notepad and SAVE it as html file and browse it in the explorer.

vishalrane 0 Junior Poster in Training

I know what you are saying but my question is dat is the html page will have button or so on which after clicking the resulted design will be saved in pdf file......

vishalrane 0 Junior Poster in Training

see your pdf file here
is it correct.

http://www.badongo.com/file/25621160

prashantpaw 0 Newbie Poster

Hi vishal,
no the HTML file will not have any button, we are reading the content of that file through our code behind page and creating a PDF out of it.

Please can you sned the PDF on my gmail id - [removed] and let me know which version of iTexsharp are you using and from where I can get that.

Thanks,
prashant.

SummiRS 0 Newbie Poster

Hello,

The following blog post introduces a simple method to convert html to pdf. I hope that it can be helpful for you.

http://janewdaisy.wordpress.com/2012/01/12/create-pdf-document-from-html-cvb-net/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.