Report Design
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Report Design
Message Icon Topic: Count number of lines of text Post Reply Post New Topic
Author Message
OptivaReporter
Newbie
Newbie


Joined: 05 Nov 2012
Location: United States
Online Status: Offline
Posts: 3
Quote OptivaReporter Replybullet Topic: Count number of lines of text
    Posted: 05 Nov 2012 at 6:01am
Hoping someone might have done this:  determine the actual number of lines used in a text field of given width, font, etc. at runtime:
 
Details:
I have a large text field that can have variable contents, i.e. short lines of text:
   the
   quick
   brown
   fox...
 
or more paragraph style text:
   the quick brown fox...
 
I need to determine how many lines are actually generated in the output in order to handle continuation pages.
I can count number of line feeds, I can count characters, but what I need to know is how many actual lines are being used given the design's field width and font type/size rather than guess at how much space the text field needs.
 
The "Can Grow" format feature allows you to select a specific number of lines to allow growth, so I'm hoping there is some way to capture the number of lines the text would result?
 
I don't see any such functions listed in report designer.
Any easy or not-so-easy suggestions appreciated!
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 06 Nov 2012 at 5:26am
There is no way to get that information from within the report.  What are you trying to do that you need it for?  In order to span multiple pages from a single text block, right-click on it and go to Format....  Turn on "Can Grow" and turn OFF "Keep Together".
 
-Dell
IP IP Logged
OptivaReporter
Newbie
Newbie


Joined: 05 Nov 2012
Location: United States
Online Status: Offline
Posts: 3
Quote OptivaReporter Replybullet Posted: 06 Nov 2012 at 5:30am
Thanks, I was afraid of that.
 
The report (it's the USDA FSIS report for food manufacturer's if that helps) is a government form, which has a specific page for "process instructions".  If those instructions spill over, the remainder goes not on the very next page, but on a page much later in the document, so simple automatic line breaking isn't sufficient.
 
Thanks though, figured it was worth an ask!
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 06 Nov 2012 at 6:01am
You could potentially count the number of Carriage Returns (chr(13) or chr(10) - I never remember which...) in the field, but that won't get you the total number of lines because of the word wrap for longer lines.  You might be able to do something using the number of Carriage Returns along with the total number of characters.
 
-Dell
IP IP Logged
OptivaReporter
Newbie
Newbie


Joined: 05 Nov 2012
Location: United States
Online Status: Offline
Posts: 3
Quote OptivaReporter Replybullet Posted: 06 Nov 2012 at 6:17am
That's actually what I've done - calculated "characters per line return", then picked a cutoff point that varies depending on the CPLR value, then some more creative stuff to find the nearest space or line return within 50 characters after that to actually break (so I'm not breaking within a word)
 
But it's a crazy load of duck tape & chicken wire that I was hoping had a better solution.  Glad to know I'm not completely nuts!
 
Thanks again
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.