Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Creating Bold in RTF FIle 1

Status
Not open for further replies.

smurfer

Programmer
Jun 8, 2001
57
US
Hi all,

I am trying to modify a script someone else created and make certain portions of it bold. Basic it is a sheet listing values but it will list a header value I want bold, list some data objects below I do not want bold, then list additional headers (bold) and data values (non bold) as it builds the RTF file. The script is using the following line to set the attributes of the file:
print OFILE "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fmodern\\fprq1\\fcharset0 LinePrinter;}}\\landscape\\paperw15840\\paperh12240\\margl1440\\margr1440\\viewkind4\\uc1\\pard\\f0\\fs16";

And I can make the first column header bold and data value bold, but can not get it to print the next header in bold again. The script has many lines like:
print OFILE $header;
printToFile($value1);

through out it and am looking for an easy way to turn bold on and off when necessary. I am not a perl developer and have researched everywhere with no luck. Please help!!!

Thank you!
 
Code:
print OFILE [b]$header;[/b]
[b]printToFile[/b] ($value1);
$header possibly has the attributes that turn bold on, we'd need to see that
printToFile is a function, and we'd need to see that before we could offer any advice.

--Paul

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Hi,

Here is the printtoFile function, very basic I belive just filling in spaces to set a length.
sub printToFile
{
print OFILE $_[0];

for ($i = length($_[0]); $i < $_[1]; $i++)
{
print OFILE " ";
}
}

and the header does not have any attributes to make it bold, there are many header declarations and all are just like this one:

@headerList1 =
(" \\par",
" PICKUP CUST NAME ADDRESS CITY ST CUST TEL # WEIGHT CASES CFT MILES\\par"
);

and are used as follows throughout the script:
print OFILE $headerList1;

If you know a way to set the headers as BOLD when they are declared, that would suffice as well.

Thanks for your help.
 
From wikipedia
Code:
{\rtf
Hello!\par
This is some {\b bold} text.\par
}
so this should work, though it looks like you need to escape the slashes \\ instead of \
Code:
@headerList1 =
    ("                                                                       \\par",    
    "    (\\bPICKUP)  CUST NAME              ADDRESS                   CITY            ST   CUST TEL #       WEIGHT    CASES     CFT       MILES\\par"
    );

HTH

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Thanks Paul.

I had to test it slightly to get it to work finally as:
print OFILE "{\\b $header}";

Not sure why that was not working as I thought I tried that before posting, but it works. Thanks for pointing me in right direction.
 
you're welcome


Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top