简体   繁体   中英

Gembox.Document: Convert HTML to Pdf, border css does not work

I am using to Gembox.Document to convert HTML to PDF. This is my HTML:

<div style="border-top:5px solid black;border-left:5px solid black;padding:2px 15px;font-size:18px;font-weight:bold;line-height:22px; background-color:aquamarine;width:230px">
    Test
</div>

But in PDF, the border is lost.

Do you know how to fix this problem?

Edit: I add sample code: (test HTML link: https://www.gemboxsoftware.com/document/examples/c-sharp-convert-html-to-pdf/307 )

<!DOCTYPE html>
<html>
  <body>   
   <table style="width:100%;" cellpadding="0" cellspacing="0">
            <tr>
                <td style="width:50%;">
                    <div style="border-top:5px solid black;border-left:5px solid black;padding:2px 15px;font-size:18px;font-weight:bold;line-height:22px; background-color:aquamarine;width:230px">
                        Test
                    </div>
                </td>
                <td style="width:50%;font-size:18px;font-weight:bold;line-height:22px;">Number</td>
            </tr>            
        </table>

   <div style="border-top:5px solid black;border-left:5px solid black;padding:2px 15px;font-size:18px;font-weight:bold;line-height:22px; background-color:aquamarine;width:230px">
                        Test
                    </div>

  </body>
</html>

Edit 2: I found out a solution to fix, it is really not beautiful but at least it worked for me

<table style="width:100%;" cellpadding="0" cellspacing="0">
        <tr>
            <td style="width:50%;">
                <table style="width:150px;margin:0px" cellpadding="0" cellspacing="0">
                    <tr>
                        <td style="border-top:1px solid black;border-left:1px solid black;">
                            <div style="padding:2px 15px;font-size:18px;font-weight:bold;line-height:22px;">
                                Test
                            </div>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width:50%;font-size:18px;font-weight:bold;line-height:22px;">Number</td>
        </tr>
    </table>

What version are you using? Perhaps you should try again with the current latest bugfix version,from here .

I tried converting this HTML:

输入 HTML

And I get this PDF:

输出PDF

As you may notice, the top and left borders are there. Also, all other CSS except "width" are there.
Last, I also tried "display" and "visibility" and it seems that both work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM