RTF Tables

RTF Tables

am 22.03.2007 15:49:11 von Ben Eagle

I am making a rtf file that has multiple tables, which I can easily do,
my problem is I am not sure how to make the cell background color
different than default white, I tried making on in word and seeing if I
could find the RTF code but couldn't find that either. And if it is
possible to round the corners of the table.

Here is what I have thus far for the table script:
#!/usr/bin/perl

use strict;
use RTF::Writer;

my $fh = RTF::Writer->new_to_file("rtfTemplate.rtf");
$fh->prolog(
fonts =>
['Arial', ],
colors => [
undef,
# color 0 == black
[255,0,0],
# color 1 == red
[0,128,0],
# color 2 == green
[0,0,255],
# color 3 == blue
[255,255,0],
# color 4 == yellow

[255,255,255],# color 5 == white

[200,200,200],# color 6 == light gray
],);

my $iMarginLeftInches = my $iMarginRightInches = 500;
my $iMarginTop = 500;
# Need bigger bottom margin for footer to fit:
my $iMarginBottom = 500;
my $iMarginLeft = $iMarginLeftInches;
my $iMarginRight = $iMarginRightInches;
eval "\$fh->Margt$iMarginTop";
eval "\$fh->Margl$iMarginLeft";
eval "\$fh->Margr$iMarginRight";
eval "\$fh->Margb$iMarginBottom";

my $tableVal = [1500,1900,1900, 1500];
my @tableData = (
[\'\cb2 this', "that", 'jhsdfhjsa', 'thing'],
["that", "this", 'kjhsadfh', 'ben'],
["me", "none", 'slhdfjhsf', 'prat'],
);
&table($tableVal, @tableData); ## calls the table function which
uses the array for values


$fh->close;

sub table(){
my($localVal, @localData) = @_;
my $decl = RTF::Writer::TableRowDecl->new('widths' =>
$localVal );
$fh->row($decl, @$_) for @localData;

}


Any help would be great,

Ben Eagle
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: RTF Tables

am 22.03.2007 16:16:27 von Todd Beverly

Ben Eagle wrote:
> I am making a rtf file that has multiple tables, which I can easily do,
> my problem is I am not sure how to make the cell background color
> different than default white, I tried making on in word and seeing if I
> could find the RTF code but couldn't find that either. And if it is
> possible to round the corners of the table.
>
>
The RTF cookbook:
http://search.cpan.org/src/SBURKE/RTF-Writer-1.11/lib/RTF/Co okbook.pod
suggests creating a color table:

A generally optional but sometimes necessary part of the prolog is
a color table. This is a color table:

{\colortbl;\red255\green0\blue0;\red0\green0\blue255;}

That declares three colors: a 0th entry, with null (default) color
(expressed by the zero-length string between "\colortbl" and ";"),
then a 1st entry, which is 100% red, and then a 2nd entry, which is
100% blue. (Note that each entry, whether null or \redN\greenN\blueN, must
be followed by a semicolon.) A color table is necessary only if you need
to change text foreground or background colors -- in that case, you
need to refer to entries in the color table.

and then using
\cfN -- select foreground color #N (from color table)
\cbN -- select background color #N (from color table)

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

RE: RTF Tables

am 22.03.2007 16:26:30 von Ben Eagle

Not quite what I ment, My apologies,

I know how to make a color table, but I am making a actual table in the
rtf document, in which I need one cell of that table to be colored, I
know its possible but I can't figure out exactly how to do that using
rtf code od RTF::Writer, either or.


Ben

-----Original Message-----
From: Todd Beverly [mailto:todd.beverly@kodak.com]
Sent: Thursday, March 22, 2007 11:16 AM
To: Ben Eagle
Cc: activeperl@listserv.ActiveState.com
Subject: Re: RTF Tables

Ben Eagle wrote:
> I am making a rtf file that has multiple tables, which I can easily
do,
> my problem is I am not sure how to make the cell background color
> different than default white, I tried making on in word and seeing if
I
> could find the RTF code but couldn't find that either. And if it is
> possible to round the corners of the table.
>
>
The RTF cookbook:
http://search.cpan.org/src/SBURKE/RTF-Writer-1.11/lib/RTF/Co okbook.pod
suggests creating a color table:

A generally optional but sometimes necessary part of the prolog is
a color table. This is a color table:

{\colortbl;\red255\green0\blue0;\red0\green0\blue255;}

That declares three colors: a 0th entry, with null (default) color
(expressed by the zero-length string between "\colortbl" and ";"),
then a 1st entry, which is 100% red, and then a 2nd entry, which is
100% blue. (Note that each entry, whether null or \redN\greenN\blueN,
must
be followed by a semicolon.) A color table is necessary only if you
need
to change text foreground or background colors -- in that case, you
need to refer to entries in the color table.

and then using
\cfN -- select foreground color #N (from color table)
\cbN -- select background color #N (from color table)

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: RTF Tables

am 22.03.2007 16:35:34 von Todd Beverly

Ben Eagle wrote:
> Not quite what I ment, My apologies,
>
> I know how to make a color table, but I am making a actual table in the
> rtf document, in which I need one cell of that table to be colored, I
> know its possible but I can't figure out exactly how to do that using
> rtf code od RTF::Writer, either or.
>
>
>
There was another section at the bottom of my note: \cbN, where N is the
corresponding number from the color table, does that work?
> and then using
> \cfN -- select foreground color #N (from color table)
> \cbN -- select background color #N (from color table)
>
>
>

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

RE: RTF Tables

am 22.03.2007 17:11:44 von Ben Eagle

No that doesn work I tried various ways this was the latest


my $tableVal2 = [2500,1900,1200, 1400];
my @tableData2 = (
[[\'\cb3', 'this'], "bnlut", 'jhsdfhjsa', 'thing'],
["that", "this", 'kjhsadfh', 'ben'],
["me", "none", 'slhdfjhsf', 'prat'],
);
&table($tableVal2, @tableData2); ## calls the table function
which uses the array for values


sub table(){
my($localVal, @localData) = @_;
my $decl = RTF::Writer::TableRowDecl->new('widths' =>
$localVal );
$fh->row($decl, @$_) for @localData;

}

-----Original Message-----
From: Todd Beverly [mailto:todd.beverly@kodak.com]
Sent: Thursday, March 22, 2007 11:36 AM
To: Ben Eagle
Cc: activeperl@listserv.ActiveState.com
Subject: Re: RTF Tables

Ben Eagle wrote:
> Not quite what I ment, My apologies,
>
> I know how to make a color table, but I am making a actual table in
the
> rtf document, in which I need one cell of that table to be colored, I
> know its possible but I can't figure out exactly how to do that using
> rtf code od RTF::Writer, either or.
>
>
>
There was another section at the bottom of my note: \cbN, where N is the

corresponding number from the color table, does that work?
> and then using
> \cfN -- select foreground color #N (from color table)
> \cbN -- select background color #N (from color table)
>
>
>

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs