Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

WRAP

Contributor ,
Apr 08, 2009 Apr 08, 2009
WRAP function not working?

I have tried this directky to browser and write this content to PDF , but both has no effect

"

<h3>Wrap Example</h3>
<cfset inputText="This is an example of a text message that we want to wrap. It is rather long and needs to be broken into shorter lines.">
<cfoutput>#Wrap(inputText, 59)#</cfoutput>

Please HELP


"

TOPICS
Getting started
946
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 08, 2009 Apr 08, 2009

Wrap will add line breaks which will NOT render in normal HTML. If you wrap that cfoutput with PRE tags you will see it working correctly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 08, 2009 Apr 08, 2009

Try additionally wrapping it in ParagraphFormat().

<cfoutput>#ParagraphFormat(Wrap(inputText, 59))#</cfoutput>

Dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 08, 2009 Apr 08, 2009

Using paragraphFormat does not seem to work. I'd say replace the line breaks with BR. You can use PRE, but the result is a bit ugly. You could style the PRE tags too though.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 08, 2009 Apr 08, 2009
LATEST

Here is the code I used which worked well for me.

<!--- Text from Flatland, (Edwin A. Abbott 1838-1926)  --->
<cfsavecontent variable="sampletext">
But now, drawing back to the edge of the table, gradually lower your eye (thus bringing yourself more and more into the condition of the inhabitants of Flatland), and you will find the penny becoming more and more oval to your view; and at last when you have placed your eye exactly on the edge of the table (so that you are, as it were, actually a Flatlander) the penny will then have ceased to appear oval at all, and will have become, so far as you can see, a straight line.

The same thing would happen if you were to treat in the same way a Triangle, or Square, or any other figure cut out of pasteboard. As soon as you look at it with your eye on the edge on the table, you will find that it ceases to appear to you a figure, and that it becomes in appearance a straight line. Take for example an equilateral Triangle - who represents with us a Tradesman of the respectable class. Fig. 1 represents the Tradesman as you would see him while you were bending over him from above; figs. 2 and 3 represent the Tradesman, as you would see him if your eye were close to the level, or all but on the level of the table; and if your eye were quite on the level of the table (and that is how we see him in Flatland) you would see nothing but a straight line.
</cfsavecontent>

<cfset newText = wrap(trim(sampleText),40)>
<cfset newText = replace(newText, chr(10), "<br/>", "all")>

<cfoutput>
#newText#
</cfoutput>

<cfdocument format="pdf" name="data">
<cfoutput>
#newText#
</cfoutput>
</cfdocument>

<cfheader name="Content-Disposition" value="inline; filename=test.pdf">
<cfcontent type="application/pdf" reset="true" variable="#data#">

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources