Training, Open Source computer languages

This is page http://www.wellho.net/forum/Perl-Programming/Text-formatting.html

Our email: info@wellho.net • Phone: 01144 1225 708225

 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Text formatting

Posted by matt (matt), 22 May 2003
Graham

Text formatting urgghhhhhhh.

I am not even sure if this is possible, if it is can you tell me or point to a reference source where I can find how to change text to bold and change font.

And yes I have got a new job as a secretary making reports look pretty.

Thanks in advance

Matt

p.s. Some good news, Rachel is pregnant and due on Nov 21 and yes it is mine (I think).

Posted by admin (Graham Ellis), 22 May 2003
Do you know what format you're going to be using? HTML? RTF? Markup for these pages where you can make things bold or italic?    It can usually be done, but you need to know the format!

Posted by matt (matt), 24 May 2003
The format I need will always be RTF.

Matt

Posted by admin (Graham Ellis), 24 May 2003
Oh ... RTF is a dog of a format.   If you want an idea of just how much of a dog, have a look at:
http://www.php9.com/index.php/section/articles/name/Using%20PHP%20for%20Rich%20Text%20Format%20RTF

There's even an RTF pocket guide published by O'Reilly - think it's one of the few books I haven't got.  ISBN 0-596-00475-3, published May 2003.

Have a search for RTF on the CPAN .... there's a number.  RTF:ocument came up first for me, and looks like it might do the job for you.   Here's the sort of thing (this example from the module's documentation. rrr

Code:
use RTF::Document;

   # Document properties

   $rtf = new RTF::Document(
     {
       doc_page_width => '8.5in',
       doc_page_height => '11in'
     }
   );

   # Font definitions

   $fAvantGarde = $rtf->add_font ("AvantGarde",
      { family=>swiss,
        default=>1
      } );
   $fCourier = $rtf->add_font ("Courier",
     { family=>monospace, pitch=>fixed,
       alternates=>["Courier New", "American Typewriter"]
     } );

   # Color definitions

   $cRed   = $rtf->add_color ( { red=>255 } );
   $cGreen = $rtf->add_color ( { green=>128 } );
   $cCustm = $rtf->add_color ( { red=>0x66, blue=>0x33, green=>0x33 } );

   $cBlack = $rtf->add_color ( { name=>'black' } );
   $cWhite = $rtf->add_color ( { gray=>'100%' } );

   $cNavy = $rtf->add_color ( { blue=>'100%', gray=>'50%' } );

   # style definitions

   $sNormal = $rtf->add_style( "Normal",
     { font=>$fAvantGarde, font_size=>'12pt',
       color_foreground=>$cBlack },
     { type=>paragraph, default=>1 }
   );

   $sGreen = $rtf->add_style( "Green",
     { color_foreground=>$cGreen },
     { type=>character, additive=>1 }
   );

   # Mix any combo of properties and text...

   $rtf->add_text( $rtf->root(),
      "Default text\n\n",

      { bold=>1, underline=>continuous },
      "Bold/Underlined Text\n\n",

      { font_size=>'20pt', font=>$fCourier,
        color_foreground=>$cRed },
      "Bigger, Red and Monospaced.\n\n",

      { style_default=>paragraph },
      { style_default=>character },

      "This is ",
      [ { style=>$sGreen }, "green" ],
      " styled.\n\n"

   );

   open FILE, ">MyFile.rtf";
   binmode FILE;
   print FILE $rtf->rtf();
   close FILE;


Example is Copyright (c) 1999-2000 Robert Rothenberg. "All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself."  I think I'm within those terms to quote it in this way ...






This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho