Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Apr 07, 2016 11:17 am

Hello i have a problem with my html code . i use two table in a panel
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 ?

akindini
 
Posts: 1
Joined: Thu Apr 07, 2016 9:54 am

Fri Apr 08, 2016 7:51 am

Hi,

Thanks for your feedback.
The image problem may be caused by the incorrect image path because I tested a image on my side and it showed. I recommend you to use the absolute path of image.
Regarding the layout interface spoil issue, could you please provide us your result pdf file to help us know it? Thank you.
At present, the latest Spire.Pdf is Spire.PDF Version: 3.6.260. You can have a try.

Sincrely,
Caroline
E-iceblue support team
User avatar

caroline.zhang
 
Posts: 291
Joined: Mon Mar 07, 2016 9:22 am

Tue Apr 12, 2016 9:10 am

Hello,

Have your issues been resolved?
Could you please give us some feedback?

Thank you in advance.
Caroline
E-iceblue support team
User avatar

caroline.zhang
 
Posts: 291
Joined: Mon Mar 07, 2016 9:22 am

Return to Spire.PDF

cron