Skip to main content



      Home
Home » Archived » BIRT » Carriage returns/line breaks in data
Carriage returns/line breaks in data [message #112018] Thu, 19 January 2006 23:42 Go to next message
Eclipse UserFriend
I have long text data that has carriage returns and line breaks. It is not
putting the right spacing in PDF. Anyone have a work around? I have
tried putting HTML tags and \n \r escape characters in the data, doesn't
work.

Thanks...
Re: Carriage returns/line breaks in data [message #112120 is a reply to message #112018] Fri, 20 January 2006 06:39 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I have the same problem, but I haven't found a solution yet.
But I've seen you visited the Bugzilla entries(123875,124589).
So you already have a walkaround,don't you?

MfU + best regards,
Thomas.
Re: Carriage returns/line breaks in data-its a different problem [message #112173 is a reply to message #112120] Fri, 20 January 2006 08:12 Go to previous messageGo to next message
Eclipse UserFriend
No-different problem. The actual data coming from the database has
carriage returns and line breaks in it, and they won't render in PDF. The
workaround only helps with text I put in the BIRT report.
Re: Carriage returns/line breaks in data [message #112198 is a reply to message #112120] Fri, 20 January 2006 08:34 Go to previous messageGo to next message
Eclipse UserFriend
On Fri, 20 Jan 2006 11:39:20 +0000 (UTC), mebo@gmx.at (Thomas A.
X-Berger) wrote:

>Hi,
>
>I have the same problem, but I haven't found a solution yet.
>But I've seen you visited the Bugzilla entries(123875,124589).
>So you already have a walkaround,don't you?
>
>MfU + best regards,
> Thomas.
I had the problem using long texts coming from a scripted datasource.
If the text contains a \n\r, birt doesn't automatically break the
lines, and a too long line flies out of the text block (which, I must
agree, isn't very readable...!)

I had to use a fixed-length font, and use scripting to parse the text
and insert line feeds in the 'too long' lines...

(code given as example)

var textToSplit= (row["dataLongText"] != null) ? row["dataLongText"] :
"";
res = "";
maxLen = 66;
// split the text in lines
var lines = textToSplit.split("\r\n");
for (i = 0; i < lines.length; i++) {
line = lines[i];
// if line is longer than maxLen, split it
if (line.length > maxLen) {
// split long line in words
var vecWords = line.split(" ");
j = 0;
lenLine = 0;
// for each word (but the last one)
for (j = 0; j < vecWords.length; j++) {
// check length
lenNextWord = vecWords[j].length + 1;
// if the line still is smaller than the max
length when we add the word and a space
if (lenLine + lenNextWord < maxLen+1) {
// add the word and a space
res = res + vecWords[j] + " ";
// increase the line length
lenLine += lenNextWord;
} // else (next word will make line too long)
else {
// we reached the max length for the
line; go to next line and insert word.
res = res + "\r\n" + vecWords[j] + "
";
// current line length = length of
(word + space)
lenLine = lenNextWord;
}
}
// remove last added space and insert line feed
res = res.substr(0, res.length - 1) + "\r\n";
} // else (only one word) add it to the result with a line
feed
else {
res = res + line + "\r\n";
}
// next line
}
// return result, but remove last CR LF
res.substr(0, res.length - 2);
Re: Carriage returns/line breaks in data [message #112452 is a reply to message #112198] Fri, 20 January 2006 13:39 Go to previous messageGo to next message
Eclipse UserFriend
Thanks! Will give this approach a shot-this makes my implementation
easier.
Re: Carriage returns/line breaks in data: \n \r effects [message #112465 is a reply to message #112198] Fri, 20 January 2006 14:17 Go to previous messageGo to next message
Eclipse UserFriend
Looked over your code...the approach makes sense, though for my problem I
would look for the cr/lf in the data and add javascript escapes between
segments. Are you saying that you are not getting row["dataLongText"] to
wrap, when that is the sole entry in the data javascript? Any chance that
the Text Whitespace property is set to no wrap? I haven't had line
overflow problems-just can't get pretty spaces between paragraphs that are
in the original data. But when I split the data into paragraphs and enter
the escapes, I may have your problem, I guess.

I tested using escapes without using variables-and there is trick in RC2
that I had to do to get escapes to work. Basically, I need two line feeds
to get the line between paragraphs. If I put in \r \n \r \n (or \n \r \n
\r), in HTML I get the effect of :

Line one

Line two

In PDF, Line two disappears. However, if I just use \n \n, then you get
the same effect in HTML and PDF.

I'll have to see if I can test for the line feeds/carriage returns in the
original data and use your split technique. If it works, I'll post a
function in bug report 124589...unless they fix it before release
(unlikely, CVS is closed...)

Jett
Re: Carriage returns/line breaks in data: Function Posted [message #112639 is a reply to message #112465] Fri, 20 January 2006 15:48 Go to previous messageGo to next message
Eclipse UserFriend
I've posted a function in bug 124589 that does what I need. Hope this
helps someone else. I'm having no trouble with lines not wrapping.
Re: Carriage returns/line breaks in data: Function Posted [message #113002 is a reply to message #112639] Mon, 23 January 2006 04:16 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I implemented your java-script-function and the call works fine. The only
problem is the result:

in HTML:

there are 2 linebreaks - absolutely accurate

in PDF:

there are none of them

I wrote the function-call in a data-Field, you also did so?!


If I use a Text-field, work with the '<value-of format="html">' tag, and
write '<br/>'-tags instead of line-breaks I nearly works, there is only a
difference between the HTML- and the PDF-output.

Is there any hope/notice that the "\n" will work in the 2.0 Release of
BIRT?!

MfU & best regards
Thomas.
Re: Carriage returns/line breaks in data: Function Posted [message #113135 is a reply to message #113002] Mon, 23 January 2006 07:51 Go to previous messageGo to next message
Eclipse UserFriend
I wonder if we are using the same builds-it is doing the right thing for
me in both PDF and HTML. I'm using RC2, hope to try on Release this week.
I'll also make sure I posted the right version of the function.

Jett
Re: Carriage returns/line breaks in data: Function Posted [message #113837 is a reply to message #113135] Tue, 24 January 2006 02:52 Go to previous message
Eclipse UserFriend
Hi,

I've found out the reason why it didn't work on my machine, but I don't
understand it by now.


formattedText += " \n";
[/working code]



formattedText += "\n";
[/not working code]

It's the blank before the \n.
So if somebody else has problems with the line-break try to make some
spaces
before or after the line-break and hope for the best ;o)

MfU & best regards,
Thomas.
Previous Topic:Can't get 2.0 Releases Preview to Work ... Stumped and Pulling My Hair Out
Next Topic:The output format pdf is not supported!! What's the problem?
Goto Forum:
  


Current Time: Thu Jul 24 17:18:29 EDT 2025

Powered by FUDForum. Page generated in 0.06507 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top