- Code: Select all
<asp:Panel ID="Panel1" runat="server">
..
<div class="col-sm-4 text-left mt-md mb-md">
<div class="ib">
<img src="../img/logos/logo.png" />
</div>
...
<div class="row col-md-12">
<div class="col-md-8">
<div class="row">
<div class="col-sm-12 ">
<div class="table-responsive">
<table class="table h5 text-dark" style="border: solid; border-color: #808080">
<tbody>
<tr class="h4" style="background-color: #DADADA; border-bottom: solid; border-color: #808080">
<td colspan="2"></td>
<td class="text-left"></td>
</tr>
<tr>
<th id="Th1" class="text-weight-semibold"></th>
<th id="Th2" class="text-weight-semibold"></th>
<th id="Th3" class="text-weight-semibold"></th>
</tr>
.....
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="invoice-summary">
<div class="row">
<div class="col-sm-12 ">
<table class="table h5 text-dark" style="border: solid; border-color: #808080">
<tbody>
<tr class="h4" style="background-color: #DADADA; border-bottom: solid; border-top: solid; border-color: #808080">
<td colspan="2"></td>
<td class="text-left" id="ts1" runat="server"></td>
</tr>
<tr>
<td colspan="2"></td>
<td class="text-left" id="ts2" runat="server"></td>
</tr>
..
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
..
</asp:Panel>
<asp:Button ID="Button1" CssClass="no-print" runat="server" Text="Button" OnClick="Button1_Click" />
when i click the button for convert the html to pdf
- Code: Select all
protected void Button1_Click(object sender, EventArgs e)
{
PdfDocument pdf = new PdfDocument();
PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat();
//webBrowser load html whether Waiting
htmlLayoutFormat.IsWaiting = true;
//page setting
PdfPageSettings setting = new PdfPageSettings();
setting.Size = PdfPageSize.A4;
var sb_htmlCode = new StringBuilder();
Panel1.RenderControl(new HtmlTextWriter(new StringWriter(sb_htmlCode)));
string htmlCode = sb_htmlCode.ToString();
Thread thread = new Thread(() =>
{ pdf.LoadFromHTML(htmlCode, false, setting, htmlLayoutFormat); });
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
pdf.SaveToFile("output.pdf");
System.Diagnostics.Process.Start("output.pdf");
}
1. the image is not showed
2. the layout interface spoil
can you please help me on this ?