I use ColdFusion 11 and Java ( com.lowagie.text.pdf.PdfStamper ) to populate pdf, but when I enter a value with one apostrophe, for example 32' , it only saves in pdf format as 32 instead of 32' , The value goes into multi-line text area in PDF. I tried with and without rich text included.
I tried replacing ' with '; , '' , ' and \u0027; but they all disappear. I also tried xmlFormat , but it displays as ' .
Copy and paste from MS Word did not work 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 );
Aaron source share