Java 使用PDFStamper时缺少单引号

Java 使用PDFStamper时缺少单引号,java,pdf,coldfusion,Java,Pdf,Coldfusion,我正在使用ColdFusion 11和Java(com.lowagie.text.pdf.PdfStamper)来填充pdf,但是当我用单个撇号(如32')输入值时,它只会在pdf中保存为32,而不是32'。该值将进入PDF中的多行文本区域。我尝试过启用和不启用富文本 我试着用';,“,',和\u0027

我正在使用ColdFusion 11和Java(
com.lowagie.text.pdf.PdfStamper
)来填充pdf,但是当我用单个撇号(如
32'
)输入值时,它只会在pdf中保存为
32
,而不是
32'
。该值将进入PDF中的多行文本区域。我尝试过启用和不启用富文本

我试着用
';
',和
\u0027xmlFormat
,但它显示为
'

从MS Word复制和粘贴
也不能作为替换值

这是我正在使用的代码

this.pdfFile = this.pdfService.read( source=infile );
this.pdfReader = createObject("java","com.lowagie.text.pdf.PdfReader").init( tobinary( this.pdffile ) );
this.pdfWriter = createObject( "java", "java.io.FileOutputStream").init( CreateObject( "java", "java.io.File" ).init( this.outfile ));
this.pdfStamper = createObject( "java", "com.lowagie.text.pdf.PdfStamper").init( this.pdfReader, this.PdfWriter );
this.acroForm = this.pdfStamper.getAcroFields();
//this.misc.text = replace( this.misc.text, "'", "&##39;", "all");
//this.misc.text = replace( this.misc.text, "'", "\u0027;", "all");
//this.misc.text = replace( this.misc.text, "'", "’", "all");
//this.misc.text = replace( this.misc.text, "'", "'", "all");
//this.misc.text = PreserveSingleQuotes( this.misc.text );
this.acroForm.setField("text", this.misc.text );

问题是,选择作为输入框字体的Times字体没有撇号字符。将字体更改为Arial或Verdana解决了此问题。

您可以手动执行
转换字符串(this.misc.text,PdfObject.text\u PDFDOCENCODING)
并检查引号是否在此时消失?@Jongware我尝试了以下操作,但无效。this.misc.text=this.PdfEncodings.convertToBytes(this.misc.text,this.PdfObject.text\u PDFDOCENCODING);this.misc.text=this.PdfEncodings.convertToString(this.misc.text,this.PdfObject.text\u PDFDOCENCODING);convertToString需要的是字节[],而不是字符串。