Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing single quote when using PDFStamper

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 &#39&#59;, '', &apos&#59;, and \u0027; but all of them disappear. I've also tried xmlFormat but it shows up as &apos&#59;.

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 );
like image 266
Aaron Avatar asked Nov 10 '22 16:11

Aaron


1 Answers

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.

like image 166
Aaron Avatar answered Nov 14 '22 22:11

Aaron