如何在使用itextpdf将HTML转换为PDF时使用border-radius。

huangapple go评论87阅读模式
英文:

How to use border-radius while converting html to pdf using itextpdf

问题

<table style="border-radius:20px; border:1px solid;">
    <tbody>
        <tr>
            <td style="padding-left: 16px; padding-top: 11px; padding-bottom: 11px;border: 1px solid #909090; -webkit-border-radius: 20px; -moz-border-radius: 20px; border-radius:20px;">
                <div>
                    <p>$text1</p>
                </div>
            </td>
            <td style="padding-left: 16px; padding-top: 11px; padding-bottom: 11px; border-right: 1px solid #909090;">
                <div>
                    <p>$text2</p>
                </div>
            </td>
            <td style="padding-left: 16px; padding-top: 11px; padding-bottom: 11px;">
                <div>
                    <p>$text3</p>
                </div>
            </td>
        </tr>
    </tbody>
</table>
XMLWorkerHelper xmlWorkerHelper = XMLWorkerHelper.getInstance();
xmlWorkerHelper.getDefaultCssResolver(true);
xmlWorkerHelper.parseXHtml(pdfWriter, document, new StringReader(template));
英文:

I am trying to round the corners of my table, border-radius doen't seem to work when I convert the below HTML to PDF using Itext pdf generator. Below is the HTML written for table:

&lt;table style=&quot;border-radius:20px; border:1px solid&quot;&gt;
		&lt;tbody&gt;
			&lt;tr&gt;
			&lt;td style=&quot;padding-left: 16px; padding-top: 11px;  padding-bottom: 11px;border: 1px solid #909090; -webkit-border-radius: 20px; -moz-border-radius: 20px; border-radius:20px;&quot;&gt;
			&lt;div&gt;
			&lt;p &gt;$text1
            &lt;/p&gt;
		    &lt;/div&gt;
			&lt;/td&gt;
			&lt;td style=&quot;padding-left: 16px; padding-top: 11px;  padding-bottom: 11px; border-right: 1px solid #909090;&quot;&gt;
			&lt;div&gt;
			&lt;p &gt; $text2
            &lt;/p&gt;
		    &lt;/div&gt;
			&lt;/td&gt;
			&lt;td style=&quot;padding-left: 16px; padding-top: 11px;  padding-bottom: 11px;&quot;&gt;
			&lt;div&gt;
			&lt;p&gt;$text3
            &lt;/p&gt;
		    &lt;/div&gt;
			&lt;/td&gt;
			&lt;/tr&gt;
		&lt;/tbody&gt;
	&lt;/table&gt;

ITEXT PDF CODE:

XMLWorkerHelper xmlWorkerHelper = XMLWorkerHelper.getInstance();
			xmlWorkerHelper.getDefaultCssResolver(true);
			xmlWorkerHelper.parseXHtml(pdfWriter, document, new StringReader(template));

答案1

得分: 2

我之前在使用Itext5,升级到Itext7后,border-radius属性开始起效。

英文:

I was using Itext5 , After upgrading to Itext7, border-radius property started working

huangapple
  • 本文由 发表于 2020年9月29日 19:57:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/64119146.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定