简体   繁体   English

在飞碟中使用与号

[英]Using an ampersand in flying saucer

I get the error below when converting to PDF with flying saucer. 使用飞碟转换为PDF时出现以下错误。 I've removed the ampersand charector and it worked, so this seems to be the problem. 我已经删除了&符,并且它起作用了,所以这似乎是个问题。 How do I include ampersand's in my PDF documents? 如何在我的PDF文档中包括“&”符号? Thanks in advance. 提前致谢。

ERROR: 'The entity name must immediately follow the '&' in the entity reference.' 错误:“实体名称必须紧随实体引用中的“&”之后。”

Just replace & with & 只需将&替换为&

NOTE:That won't work for filenames, just content. 注意:这不适用于文件名,仅适用于内容。

Flying saucer parses only valid xhtml. 飞碟仅解析有效的xhtml。 With XML you would have to define your & entity. 使用XML,您必须定义&实体。 However, I've stopped trying to use & and have started using: 但是,我已经停止尝试使用&并开始使用:

&

That is your ampersand that will work with xhtml, and it will work with Flying saucer to get the ampersand into the PDF. 那是您的&符,将与xhtml一起使用,并且将与飞碟一起使用,以将&符添加到PDF中。

Useful Reference: http://www.elizabethcastro.com/html/extras/entities.html 有用的参考: http : //www.elizabethcastro.com/html/extras/entities.html

I had also this problem, but I solved it by surrounding the conflict characters (like &) with the 我也遇到了这个问题,但是我通过将冲突字符(如&)与

<![CDATA['&']]>

notation. 符号。 Hope it helps as well, because the previous answers did not work for me. 希望它也有帮助,因为先前的答案对我不起作用。

You need to escape any XML entities (gt, lt, quot, amp, apos). 您需要转义任何XML实体(gt,lt,quot,amp,apos)。 An easy and effective way to do this is by using the Apache Commons Lang library function StringEscapeUtils.escapeXML . 一种简单有效的方法是使用Apache Commons Lang库函数StringEscapeUtils.escapeXML

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

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