简体   繁体   English

Gembox.Document:将 HTML 转换为 Pdf,边框 css 不起作用

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

I am using to Gembox.Document to convert HTML to PDF.我正在使用Gembox.Document将 HTML 转换为 PDF。 This is my HTML:这是我的 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.但是在 PDF 中,边框丢失了。

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 )编辑:我添加示例代码:(测试 HTML 链接: 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编辑 2:我找到了一个解决方案来修复,它确实不漂亮,但至少对我有用

<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:

输入 HTML

And I get this PDF:我得到了这个 PDF:

输出PDF

As you may notice, the top and left borders are there.您可能会注意到,顶部和左侧边框都在那里。 Also, all other CSS except "width" are there.此外,除“宽度”之外的所有其他 CSS 都在那里。
Last, I also tried "display" and "visibility" and it seems that both work.最后,我还尝试了“显示”和“可见性”,似乎两者都有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用GemBox.Document编辑PDF中的文件属性 - Edit file properties in PDF with GemBox.Document 使用GemBox.Document在所有方向绘制ShapeType.Line对象 - Draw ShapeType.Line objects in all directions with GemBox.Document 使用 gembox 文档拆分 Doc 文件页面并转换为 PDF - Split Doc file Pages And Convert To PDF with gembox Document 使用 Gembox.Document 的 azure 函数中出现“无法加载文件或程序集‘PresentationCore’”错误 - "Could not load file or assembly 'PresentationCore'" error in azure function using Gembox.Document C#:如何将HTML5 / CSS3转换为PDF文档? - C#: How to convert HTML5/CSS3 into PDF document? 使用Gembox.Spreadsheets将.Xlsx转换为PDF - Using Gembox.Spreadsheets to convert .Xlsx to PDF 当我在C#Winforms中使用itextsharp将html转换为PDF时,bootstrap css文件使我的文档更小 - bootstrap css file makes smaller my document when i convert html to PDF with itextsharp in c# Winforms GemBox-表格以PDF格式切割 - GemBox - Tables are cut on PDF 在 C# 中使用 Gembox.Pdf 打印 pdf 时,打印队列中的 documentName 始终为“XPS Document” - When printing a pdf with Gembox.Pdf in C# the documentName in the print queue is always 'XPS Document' 使用iTextSharp将带有CSS的HTML转换为PDF - Convert HTML with CSS to PDF using iTextSharp
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM