简体   繁体   English

生成的PDF中的HTML内容存在问题

[英]Problems with HTML content in generated PDF

我从HTML生成PDF,但是与其将其解释为普通文本,不如将我的PDF页面填充为html标签,例如<p><li>等。

You'll need to remove all tags and unescape special chars. 您需要删除所有标签并取消转义特殊字符。

PHP example: PHP示例:

$text = preg_replace($html, '<[^>]*>', '');
$text = html_entity_decode($text);

VB.NET example: VB.NET示例:

Dim text As String = Regex.Replace(html, "<[^>]*>", "")
text = System.Web.WebUtility.HtmlDecode(text)

Java example: Java示例:

text = html.replaceAll("<[^>]*>", "");

For the html entity decoding you'll find a good answer here: Java: How to unescape HTML character entities in Java? 对于html实体解码,您将在这里找到一个很好的答案: Java:如何在Java中取消对HTML字符实体的转义? . Otherwise you could just replace them if you know all of them ( &nbsp; , &quot; , ...). 否则,如果您都知道它们,就可以替换它们( &nbsp;&quot; ,...)。

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

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