hello,
I want to convert from html to pdf with images.Images are showing
perfect in html but they are not in pdf.The pdf file will show by
clicking a button.
My code is here:
protected void btnExport_Click(object sender, EventArgs e)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition",
"attachment;filename=TestPage.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
divToConvert.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();
}
here is my div:
<div id="divToConvert" runat="server">
<div style="width: 641px; margin-top: 210px;">
<div>
<div style="float: left; width: 641px; height: 20px;">
<img
src="http://localhost:49168/sumangal/gui/images/top_curv.png"
width="641"
height="20" /></div>
<div style="float: left; width: 635px;
border-left: solid 3px #5c5042; border-right: solid 3px #5c5042;">
<div style="float: left; color: #6a6363;
font-family: Arial; width: 635px; text-align: center;
font-weight: bold;">
<asp:Label ID="lblSchemeDisplayName"
runat="server" ></asp:Label>
</div>
</div>
<div style="float: left; width: 641px; height: 20px;">
<img
src="http://localhost:49168/sumangal/gui/images/bottom_curv.png"
width="641"
height="20" /></div>
</div>
<div style="width: 641px; float: left; margin-top: 10px;">
<div style="float: left; width: 641px; height: 20px;">
<img
src="http://localhost:49168/sumangal/gui/images/top_curv.png"
width="641"
height="20" /></div>
<div style="float: left; width: 635px;
border-left: solid 3px #5c5042; border-right: solid 3px #5c5042;">
<div style="float: left; width: 635px;
margin-top: 0px;">
<asp:Repeater ID="rp1" runat="server">
<HeaderTemplate>
<table width="100%">
<tr>
</HeaderTemplate>
<ItemTemplate>
<td style="width:50%" align="left">
<table width="100%">
<tr>
<td style="width:50%" align="left">
<span style="font-family: Arial;
color: #49493f; font-size: 11px;">
Serial No:
<asp:Label ID="lblSlNo" runat="server"
Text='<%#Eval("FormNo")%>'></asp:Label>
</span>
</td>
</tr>
<tr>
<td style="width:50%" align="left">
<span style="font-family: Arial;
color: #49493f; font-size: 11px;">
Customer Name: <asp:Label
ID="lblName" runat="server"
Text='<%#Eval("CustomerName")%>'></asp:Label>
</span>
</td>
</tr>
<tr>
<td>
<span style="font-family: Arial;
color: #49493f; font-size: 11px;">
Father Name: <asp:Label
ID="lblFaName" runat="server"
Text='<%#Eval("FatherName")%>'></asp:Label>
</span>
</td>
</tr>
<tr>
<td>
<span style="font-family: Arial;
color: #49493f; font-size: 11px;">
Nominee Name: <asp:Label
ID="lblNominee" runat="server"
Text='<%#Eval("NomineeName")%>'></asp:Label>
</span>
</td>
</tr>
<tr>
<td>
</td>
<td>
<span style="font-family: Arial;
color: #49493f; font-size: 11px;">
<asp:Label ID="lblAgentCode"
runat="server" Text='<%#Eval("CustomerName")%>'></asp:Label>(<asp:Label
ID="lblAgentName"
runat="server" Text='<%#Eval("CustomerName")%>'></asp:Label>)
</span>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<span style="font-family: Arial;
color: #49493f; font-size: 11px;">
<asp:Label ID="lblAddress"
runat="server" Text='<%#Eval("CustomerName")%>'></asp:Label>
</span>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<span style="font-family: Arial;
color: #49493f; font-size: 11px;">
<asp:Label ID="lblPolicyNo"
runat="server" Text='<%#Eval("CustomerName")%>'></asp:Label>
</span>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<span style="font-family: Arial;
color: #49493f; font-size: 11px;">
<asp:Label
ID="lblPurchaseDate" runat="server"
Text='<%#Eval("CustomerName")%>'></asp:Label>
</span>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<span style="font-family: Arial;
color: #49493f; font-size: 11px;">
<asp:Label ID="lblSaleDate"
runat="server" Text='<%#Eval("CustomerName")%>'></asp:Label>
</span>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<span style="font-family: Arial;
color: #49493f; font-size: 11px;">
<asp:Label
ID="lblPurchasePerMonth" runat="server"
Text='<%#Eval("CustomerName")%>'></asp:Label> /-
</span>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<span style="font-family: Arial;
color: #49493f; font-size: 11px;">
Sale Price: <asp:Label
ID="lblSalePrice" runat="server"
Text='<%#Eval("RedemptionValue")%>'></asp:Label> /-
</span>
</td>
<td>
</td>
</tr>
</table>
</td>
</ItemTemplate>
<FooterTemplate>
</tr></table></FooterTemplate>
</asp:Repeater>
</div>
</div>
<div style="float: left; width: 641px; height: 20px;">
<img
src="http://localhost:49168/sumangal/gui/images/bottom_curv.png"
width="641"
height="20" /></div>
</div>
<div style="float: left; width: 641px; text-align:
right; font-family: Arial; color: #594b4b;
font-size: 12px; padding-top: 30px;
padding-bottom: 30px; font-weight: bold;">
Director 1
Director 2
<br>
<br>
Secretary / Authorised Signatory<br>
</div>
</div>
</div>
<asp:Button ID="btnExport" runat="server"
Text="Create PDF" onclick="btnExport_Click" />
Please give me the solution by today.
Thanks,
Ss
------------------------------------------------------------------------------
Keep yourself connected to Go Parallel:
INSIGHTS What's next for parallel hardware, programming and related areas?
Interviews and blogs by thought leaders keep you ahead of the curve.
http://goparallel.sourceforge.net
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php