Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 696
  • Last Modified:

How can I create vertical columns in a pdf using cfdocument in Coldfusion MX7?

I'm trying to create dynamic reports for printing, but they must be in a particular format. I need three vertical columns per page, where the text reaches the bottom of the first (left column), then wraps to the second, then third and then creates a new page and continues in this loop.

I'm thinking there might be a way to do it using CSS, but I'm not sure.

Any help would be greatly appreciated.
0
hillkiwi
Asked:
hillkiwi
1 Solution
 
SidFishesCommented:
newspaper columns? You might be able to do this if your text is confined to a single page...

cfdoc is horrible when it comes to dealing with page breaks and layouts and I wouldn't even think about

I threw together a quick little script which will at least format a single page into 3 newspaper columns. It does not handle multiple pages or text blocks that are longer then the single page total...
<cfset myText = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc non sem. Curabitur nunc lectus, consequat non, consectetuer non, gravida ut, ante. Integer faucibus molestie risus. Vestibulum consectetuer blandit risus. Pellentesque id nulla. Phasellus sem. Donec sit amet urna ac nunc fringilla aliquam. Nulla venenatis congue felis. Etiam molestie tortor eu risus. In at tortor. Ut eget mauris. In non erat eu urna gravida ornare. Curabitur leo sem, tincidunt sed, suscipit eu, congue eu, sem. Mauris tincidunt nisl sed leo. Nullam eget dolor non mi feugiat vestibulum. Pellentesque orci. Sed purus. Vestibulum tempus, ante pellentesque dapibus blandit, quam felis hendrerit enim, egestas molestie elit magna ut pede. Cras in quam non nulla lobortis rutrum. Nam sollicitudin adipiscing risus. Etiam quis urna. Ut et orci. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aenean arcu mi, aliquam sed, laoreet in, vulputate sed, ante. Suspendisse sagittis ipsum rutrum ipsum. Quisque urna. Maecenas id lectus. Suspendisse lobortis lacus ut tortor. Quisque tincidunt mauris et arcu. Morbi justo nunc, malesuada ac, suscipit in, convallis at, nibh. Morbi accumsan erat ac urna. Sed gravida. Phasellus tristique. Donec volutpat dictum turpis. Nam vel ante. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed eu odio facilisis mi ornare interdum. Curabitur quam mauris, cursus sed, ultrices a, tincidunt eget, enim. Morbi in nunc sed ipsum sagittis commodo. Curabitur augue. In mattis nibh eu arcu. Donec mattis metus non tortor. Nulla et erat. Ut tempor. Aliquam tincidunt urna porttitor augue. Ut elit augue, suscipit a, pulvinar et, porta et, lacus. Proin felis purus, ornare nec, auctor vel, adipiscing ac, ligula. Nam faucibus tristique justo. Nunc tristique metus vel quam. Vestibulum ultrices massa a sapien. Praesent sit amet diam vitae elit vestibulum facilisis. Proin blandit mollis nulla. Maecenas pretium massa a sem. Vestibulum lobortis. Nulla arcu arcu, laoreet eget, scelerisque non, dapibus vitae, sem. Sed tempus, sapien id consectetuer lacinia, dolor elit aliquet diam, in malesuada nulla lacus eget erat. Vestibulum consectetuer sapien a felis. Curabitur et erat a neque laoreet rutrum. Curabitur ac leo ut purus dapibus dignissim. Ut tincidunt, urna eget interdum ultrices, enim urna sollicitudin leo, nec tincidunt ligula mi sed ipsum. Maecenas imperdiet massa quis neque. Ut vel lectus id magna malesuada imperdiet. Ut nec quam. Aliquam enim lorem, luctus at, fermentum et, tempor at, neque. Integer in enim sit amet lorem auctor viverra.Etiam vitae elit. Integer bibendum augue tincidunt dui. Sed semper consectetuer dui. Pellentesque volutpat egestas nunc. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec fermentum facilisis magna. In luctus, purus at consequat vehicula, velit justo posuere nunc, a rutrum arcu orci in turpis. Fusce mi libero, mattis nec, laoreet quis, gravida non, sem. Cras velit augue, tristique nec, viverra vitae, commodo sed, leo. Aliquam erat volutpat.">
 
 
<cfscript>
 
col1 = fullLeft(mytext,950);
col2 = fullleft(replace(mytext,col1,""),950);
col3 = fullleft(replace(mytext,col1 & col2,""),950);
 
//fullLeft function from: http://thelazycoder.com/1/2007/07/53.Full-Left-Word-Count-with-Whole-Words.cfm
function fullLeft(str, count) {
 if (not refind("[[:space:]]", str) or (count gte len(str)))
  return Left(str, count);
 else if(reFind("[[:space:]]",mid(str,count+1,1))) {
    return left(str,count);
 } else {
  if(count-refind("[[:space:]]", reverse(mid(str,1,count)))) return Left(str, (count-refind("[[:space:]]", reverse(mid(str,1,count)))));
  else return(left(str,1));
 }
}
</cfscript>
<cfoutput>
<div style="width:2in;padding:5px;height:7in;overflow:hidden;top:50px;position:absolute;text-align:justify;">
#col1#
</div>
<div style="width:2in;padding:5px;height:7in;overflow:hidden;left:2.5in;position:absolute;top:50px;text-align:justify;">
#col2#
</div>
<div style="width:2in;padding:5px;height:7in;overflow:hidden;left:4.875in;position:absolute;top:50px;text-align:justify;">
#col3#
</div>
</cfoutput>

Open in new window

0
 
hillkiwiAuthor Commented:
Hey thanks - I think this was what I was looking for.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now