1

I'm pushing HTML forms data into PDFs using the <cfpdfform> tag and XML data created from the HTML post with XMLFormat().

For the life of me, I can't preserve carriage returns.

My strategy has been to replace the CRLF ( chr(13) & chr(10) ) in the post with a character string that survives the XMLFormat() and appropriately controls the text layout in the PDF.

I've tried HTML, HTML Entities, \n, etc. The only string that had any affect on the output other than to appear exactly as sent, was this &#x000D;&#x000A;

Unfortunately, that string (or individually either character of it) removes some of the surrounding text. But it was the only string that had any affect.

How do I preserve carriage returns? Does anyone know?

Thanks for any input you may have.

Leigh
  • 28,765
  • 10
  • 55
  • 103
DonCx
  • 53
  • 4
  • When you first submit your form, is the data plain text or xml? What are the relevant ascii values? – Dan Bracuk Feb 17 '17 at 18:59
  • It posts plain text. In the text, that CRLF is a char 13 and a char 10, as you would expect. But these characters do not make it through the XMLFormat() function and are stripped. I can easily replace them prior to XMLFormat but can't find a replacement that carries through to the PDF field as a NEWLINE. – DonCx Feb 17 '17 at 19:15
  • Create a variable with a value of `'1' & chr(13) & chr(10) & '2'` and work with that. For the strings in your question, try doubling up the octopthorps. – Dan Bracuk Feb 17 '17 at 19:38
  • Octothorps! Had to look that up. Actually, I have been doubling them and they do wind up properly in the XML as a single. I think CF would throw an error otherwise. Thanks for your ideas. Unfortunately the CR and LF are still stripped, leaving just the "12" in the PDF form field. – DonCx Feb 17 '17 at 19:54
  • (Edit) The docs usually just call it a pound sign. How did you determine the CF code is removing the new lines? Is it possible they are really being passed to the form field, just not displayed/interpreted properly. Any chance you could post a repro case? – Leigh Feb 17 '17 at 20:25
  • Or "hash"... I'm certain the CR and LF are being stripped by the XMLFormat() function because they are illegal XML and they are not in the output. Also, when I replace them, the replacements show up in the PDF field. Repro case a good idea. I'll put one together. thanks – DonCx Feb 17 '17 at 20:40
  • 1
    Have you tried something silly like wrapping the form data in `<![CDATA[#form.var#]]>`? Just a wild guess. – Jules Feb 18 '17 at 20:46

0 Answers0