使用 PDFStamper 时缺少单引号
Missing single quote when using PDFStamper
我正在使用 ColdFusion 11 和 Java (com.lowagie.text.pdf.PdfStamper
) 来填写 pdf 但是当我输入一个带有单个撇号的值时,例如 32'
它只会保存在pdf 为 32
而不是 32'
。该值将进入 PDF 中的多行文本区域。我试过启用和不启用富文本。
我尝试用 ';
、''
、'
和 \u0027;
替换 '
,但它们都消失了。我也试过 xmlFormat
但它显示为 '
。
从 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 解决了问题。
我正在使用 ColdFusion 11 和 Java (com.lowagie.text.pdf.PdfStamper
) 来填写 pdf 但是当我输入一个带有单个撇号的值时,例如 32'
它只会保存在pdf 为 32
而不是 32'
。该值将进入 PDF 中的多行文本区域。我试过启用和不启用富文本。
我尝试用 ';
、''
、'
和 \u0027;
替换 '
,但它们都消失了。我也试过 xmlFormat
但它显示为 '
。
从 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 解决了问题。