I'm using ColdFusion 11 and Java (com.lowagie.text.pdf.PdfStamper
) to fill in pdf but when I enter a value with a single apostrophe such as 32'
it only saves in the pdf as 32
instead of 32'
. The value is going into a multi-line text area in the PDF. I've tried with and without rich-text enabled.
I've tried replacing '
with ';
, ''
, '
, and \u0027;
but all of them disappear. I've also tried xmlFormat
but it shows up as '
.
Copying and pasting the ’
from MS Word didn't work either as a replacement value.
Here is the code I'm using
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 );
The problem ended up being that the Times font that was selected as the font for the input boxes did not have the apostrophe character. Changing the font to Arial or Verdana fixed the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With