我已将代码添加到itext sharp以包装连续文本。这里例如一个网址。 这些css在Web浏览器中工作时工作正常,但是当我导出到pdf时,url不会换行。
我无法确定究竟是什么问题。
在线和pdf视图的参考行为图片:
有没有办法用css
包装url
.background-color-dark-blue {
background-color: #485679;
}
.color-light {
color: #fff !important;
}
.white-space-pre-wrap a {
word-break: break-all !important;
word-wrap: break-word;
word-wrap: break-word !important;
}
.break-all {
word-break: break-all;
word-wrap: break-word;
}
.url-style a {
/*font-size: 14px;*/
line-height: 1.3;
color: #2a99d4;
font-weight: 700;
text-decoration: none;
margin-top: 0px !important;
}
<table>
<colgroup>
<col class="col-3">
<col class="col-4">
<col class="col-5">
</colgroup>
<thead>
<tr class="background-color-dark-blue ">
<th class="color-light">
Document Name</th>
<th class="color-light">
Document Description</th>
<th class="color-light">
Location/Link</th>
</tr>
</thead>
<tbody>
<tr class="bg-color-lighter">
<td class="va-top">FATF 40 Recommendations</td>
<td class="va-top">Global standard for AML/CFT published by the Financial Action Task Force </td>
<td class="review-report-url-fix padding-left-5 break-all va-top">
<div class="break-all va-top">
<a id="SiteContentPlaceHolder_AppendicesReviewControl_ReferenceDocumentListView_ReferenceDocumentLink_0" title="http://www.fatf-gafi.org/publications/fatfrecommendations/
http://www.fatf-gafi.org/publications/fatfrecommendations/documents/risk-based-approach-banking-sector.html" class="url-style white-space-pre-wrap" href="http://www.fatf-gafi.org/publications/fatfrecommendations/%0d%0a%20http://www.fatf-gafi.org/publications/fatfrecommendations/documents/risk-based-approach-banking-sector.html" target="_blank">http://www.fatf-gafi.org/publications/fatfrecommendations/
http://www.fatf-gafi.org/publications/fatfrecommendations/documents/risk-based-approach-banking-sector.html</a>
</div>
</td>
</tr>
<tr class="bg-color-dashboard-table">
<td class="va-top">Risk Based Approach Guidance for Legal Professionals</td>
<td class="va-top">Guidance on the AML/CFT Risk Based Approach for lawyers and the legal profession</td>
<td class="review-report-url-fix padding-left-5 va-top">
<div class="break-all va-top">
<a id="SiteContentPlaceHolder_AppendicesReviewControl_ReferenceDocumentListView_ReferenceDocumentLink_1" title="http://www.fatf-gafi.org/publications/fatfrecommendations/documents/riskbasedapproachguidanceforlegalprofessionals.html" class="url-style white-space-pre-wrap" href="http://www.fatf-gafi.org/publications/fatfrecommendations/documents/riskbasedapproachguidanceforlegalprofessionals.html" target="_blank">http://www.fatf-gafi.org/publications/fatfrecommendations/documents/riskbasedapproachguidanceforlegalprofessionals.html</a>
</div>
</td>
</tr>
</tbody>
</table>
答案 0 :(得分:0)
Itext 7.0版具有内置库函数
SetSplitCharacters(ISplitCharacters splitCharacters);
因此,要在Itext 7中拆分字符,请使用代码
public string SplitChars { get; set; } = ".+-/";
var document = new Document(pdf, PageSize.LETTER, false)
document.SetSplitCharacters(new CustomSplitCharacters(SplitChars));
所以现在一个连续的url会在每个。+ - /当它位于表格单元格的末尾时断开
提供库函数的URL
http://itextsupport.com/apidocs/itext7/7.0.4/com/itextpdf/layout/ElementPropertyContainer.html