FAQ
I want to create a doc file that will contain my text, fonts, sizes as if i wrote manually.

Can i do that thing?

Search Discussions

  • Stout, Joel R at Oct 7, 2003 at 3:29 pm
    Good place to ask. Jenda and some others are great with perl and M$. One
    thing I've done in the past is to write HTML but save it as a *.doc.
    Example:

    Open a file and write:
    <html><h1>test</h1><br/><p><b>test</b> <i>test</i> <u>test</u></p></html>

    Save it as test.doc.

    Open it in Word. It show the formatting. The user can then edit and save
    as a doc file (though the first option will be to save it as a htm file).

    Joel


    -----Original Message-----
    From: John
    Sent: Tuesday, October 07, 2003 8:16 AM
    To: Perl Beginners
    Subject: Microsoft Word Creation


    I want to create a doc file that will contain my text, fonts, sizes as if i
    wrote manually.

    Can i do that thing?
  • John at Oct 7, 2003 at 3:54 pm
    Have you got the code to test if you concept is what i need?


    ----- Original Message -----
    From: "Stout, Joel R" <Stout.Joel@emeryworld.com>
    To: "'John'" <sc00170@cc.uoi.gr>; "Perl Beginners" <beginners@perl.org>
    Sent: Tuesday, October 07, 2003 6:32 PM
    Subject: RE: Microsoft Word Creation

    Good place to ask. Jenda and some others are great with perl and M$. One
    thing I've done in the past is to write HTML but save it as a *.doc.
    Example:

    Open a file and write:
    <html><h1>test</h1><br/><p><b>test</b> <i>test</i> <u>test</u></p></html>

    Save it as test.doc.

    Open it in Word. It show the formatting. The user can then edit and save
    as a doc file (though the first option will be to save it as a htm file).

    Joel


    -----Original Message-----
    From: John
    Sent: Tuesday, October 07, 2003 8:16 AM
    To: Perl Beginners
    Subject: Microsoft Word Creation


    I want to create a doc file that will contain my text, fonts, sizes as if i
    wrote manually.

    Can i do that thing?

    --
    To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org
  • Rob Dixon at Oct 7, 2003 at 3:41 pm

    John wrote:
    I want to create a doc file that will contain my text,
    fonts, sizes as if i wrote manually.
    You can use Win32::OLE drive MSWord itself to generate a document,
    but I think that's an awful way to do things. Why not look at
    RTF::Generator which will let you create an RTF file which Word
    will then read happily.

    HTH,

    Rob
  • Rob Dixon at Oct 7, 2003 at 4:55 pm
    "Rob Dixon" <rob@dixon.port995.com> wrote in message news:20031007154106.10573.qmail@onion.perl.org...
    John wrote:
    I want to create a doc file that will contain my text,
    fonts, sizes as if i wrote manually.
    You can use Win32::OLE drive MSWord itself to generate a document,
    but I think that's an awful way to do things. Why not look at
    RTF::Generator which will let you create an RTF file which Word
    will then read happily.
    My apologies, that should have been RTF::Writer.

    Cheers,

    Rob
  • Rob Dixon at Oct 7, 2003 at 7:28 pm

    John wrote:
    Rob Dixon wrote:
    John wrote:
    I want to create a doc file that will contain my text,
    fonts, sizes as if i wrote manually.
    You can use Win32::OLE drive MSWord itself to generate a document,
    but I think that's an awful way to do things. Why not look at
    RTF::Generator which will let you create an RTF file which Word
    will then read happily.
    My apologies, that should have been RTF::Writer.
    Have you got any relevant code?
    Hi John.

    Something like this?

    use strict;
    use warnings;

    use RTF::Writer;

    my $rtf = RTF::Writer->new_to_file("demo.rtf");

    $rtf->prolog;

    $rtf->paragraph(
    \'\b', # Bold
    \'\ul', # Underline
    "Title");

    $rtf->paragraph; # Blank First Paragraph

    $rtf->paragraph(
    "First text paragraph.");

    $rtf->paragraph(
    "Second text paragraph", \'\line',
    "with an explicit line break.");

    $rtf->close;

    But you'll be better informed by reading the RTF::Writer POD
    which includes an RTF primer called RTF::Cookbook.

    HTH,

    Rob
  • Sc00170 at Oct 8, 2003 at 7:35 am
    Your solution is also amazing but where can i define the TrueType fonts for
    every single word? Or the size of them, color,...

    Quoting Rob Dixon <rob@dixon.port995.com>:
    John wrote:
    Rob Dixon wrote:
    John wrote:
    I want to create a doc file that will contain my text,
    fonts, sizes as if i wrote manually.
    You can use Win32::OLE drive MSWord itself to generate a document,
    but I think that's an awful way to do things. Why not look at
    RTF::Generator which will let you create an RTF file which Word
    will then read happily.
    My apologies, that should have been RTF::Writer.
    Have you got any relevant code?
    Hi John.

    Something like this?

    use strict;
    use warnings;

    use RTF::Writer;

    my $rtf = RTF::Writer->new_to_file("demo.rtf");

    $rtf->prolog;

    $rtf->paragraph(
    \'\b', # Bold
    \'\ul', # Underline
    "Title");

    $rtf->paragraph; # Blank First Paragraph

    $rtf->paragraph(
    "First text paragraph.");

    $rtf->paragraph(
    "Second text paragraph", \'\line',
    "with an explicit line break.");

    $rtf->close;

    But you'll be better informed by reading the RTF::Writer POD
    which includes an RTF primer called RTF::Cookbook.

    HTH,

    Rob



    --
    To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org
  • Rob Dixon at Oct 8, 2003 at 9:57 am
    wrote:
    Quoting Rob Dixon <rob@dixon.port995.com>:
    John wrote:
    Rob Dixon wrote:
    John wrote:
    I want to create a doc file that will contain my text,
    fonts, sizes as if i wrote manually.
    You can use Win32::OLE drive MSWord itself to generate a document,
    but I think that's an awful way to do things. Why not look at
    RTF::Generator which will let you create an RTF file which Word
    will then read happily.
    My apologies, that should have been RTF::Writer.
    Have you got any relevant code?
    Hi John.

    Something like this?

    use strict;
    use warnings;

    use RTF::Writer;

    my $rtf = RTF::Writer->new_to_file("demo.rtf");

    $rtf->prolog;

    $rtf->paragraph(
    \'\b', # Bold
    \'\ul', # Underline
    "Title");

    $rtf->paragraph; # Blank First Paragraph

    $rtf->paragraph(
    "First text paragraph.");

    $rtf->paragraph(
    "Second text paragraph", \'\line',
    "with an explicit line break.");

    $rtf->close;

    But you'll be better informed by reading the RTF::Writer POD
    which includes an RTF primer called RTF::Cookbook.
    Your solution is also amazing but where can i define the TrueType fonts for
    every single word? Or the size of them, color,...
    Hi.

    A name would be nice...?

    All of the answers are in the module documentation. The code below shows
    a lot of the common requirements. Anything else you can fish from the
    POD.

    Sean, the author of the module, has written O'Reilly's "RTF Pocket Guide"
    which I haven't seen but assume is still in print. It will be much more
    comprehensive than the RTF::Cookbook POD.

    HTH,

    Rob



    use strict;
    use warnings;

    use RTF::Writer;

    my $rtf = RTF::Writer->new_to_file("demo.rtf");

    $rtf->prolog( fonts => ['Times New Roman', 'Courier New'] );

    $rtf->print(\'\f0\fs24'); # Default to Font zero (Times) in 12 pt

    $rtf->paragraph(
    \'\sa120', # 6pt space after paragraph
    \'\b', # Bold
    \'\ul', # Underline
    "Title");

    $rtf->paragraph; # Blank First Paragraph

    $rtf->paragraph(
    \'\sa120',
    "First text paragraph.");

    $rtf->paragraph(
    \'\sa120',
    \'\f1', # Font 1 (Courier)
    "Second text paragraph in Courier New",
    \'\line',
    "with an explicit line break.");

    $rtf->paragraph(
    \'\sa120',
    "Third text paragraph reverts to default font zero.");

    # Most arguments takes measurements in twips (twentieths of a point)
    # so \sa120 is a space-after of 6 points
    # Font Size takes measurements of half a point, so \fs16 is 8-point
    #
    $rtf->paragraph(
    \'\sa120',
    \'\f1',
    \'\fs16', # Font size 8pt
    "Fourth text paragraph in Courier New 8pt ",
    "with no explicit line break but extended text ",
    "to show that automatic line wrapping applies ",
    "just as in Word."
    );

    $rtf->paragraph(
    \'\sa120',
    "Fifth text paragraph.");

    $rtf->close;
  • Sc00170 at Oct 8, 2003 at 1:29 pm
    This method would be perfect unless i had problem with the encoding. I want to
    write greek documents but i cannot.


    Quoting Rob Dixon <rob@dixon.port995.com>:
    wrote:
    Quoting Rob Dixon <rob@dixon.port995.com>:
    John wrote:
    Rob Dixon wrote:
    John wrote:
    I want to create a doc file that will contain my text,
    fonts, sizes as if i wrote manually.
    You can use Win32::OLE drive MSWord itself to generate a document,
    but I think that's an awful way to do things. Why not look at
    RTF::Generator which will let you create an RTF file which Word
    will then read happily.
    My apologies, that should have been RTF::Writer.
    Have you got any relevant code?
    Hi John.

    Something like this?

    use strict;
    use warnings;

    use RTF::Writer;

    my $rtf = RTF::Writer->new_to_file("demo.rtf");

    $rtf->prolog;

    $rtf->paragraph(
    \'\b', # Bold
    \'\ul', # Underline
    "Title");

    $rtf->paragraph; # Blank First Paragraph

    $rtf->paragraph(
    "First text paragraph.");

    $rtf->paragraph(
    "Second text paragraph", \'\line',
    "with an explicit line break.");

    $rtf->close;

    But you'll be better informed by reading the RTF::Writer POD
    which includes an RTF primer called RTF::Cookbook.
    Your solution is also amazing but where can i define the TrueType fonts for
    every single word? Or the size of them, color,...
    Hi.

    A name would be nice...?

    All of the answers are in the module documentation. The code below shows
    a lot of the common requirements. Anything else you can fish from the
    POD.

    Sean, the author of the module, has written O'Reilly's "RTF Pocket Guide"
    which I haven't seen but assume is still in print. It will be much more
    comprehensive than the RTF::Cookbook POD.

    HTH,

    Rob



    use strict;
    use warnings;

    use RTF::Writer;

    my $rtf = RTF::Writer->new_to_file("demo.rtf");

    $rtf->prolog( fonts => ['Times New Roman', 'Courier New'] );

    $rtf->print(\'\f0\fs24'); # Default to Font zero (Times) in 12 pt

    $rtf->paragraph(
    \'\sa120', # 6pt space after paragraph
    \'\b', # Bold
    \'\ul', # Underline
    "Title");

    $rtf->paragraph; # Blank First Paragraph

    $rtf->paragraph(
    \'\sa120',
    "First text paragraph.");

    $rtf->paragraph(
    \'\sa120',
    \'\f1', # Font 1 (Courier)
    "Second text paragraph in Courier New",
    \'\line',
    "with an explicit line break.");

    $rtf->paragraph(
    \'\sa120',
    "Third text paragraph reverts to default font zero.");

    # Most arguments takes measurements in twips (twentieths of a point)
    # so \sa120 is a space-after of 6 points
    # Font Size takes measurements of half a point, so \fs16 is 8-point
    #
    $rtf->paragraph(
    \'\sa120',
    \'\f1',
    \'\fs16', # Font size 8pt
    "Fourth text paragraph in Courier New 8pt ",
    "with no explicit line break but extended text ",
    "to show that automatic line wrapping applies ",
    "just as in Word."
    );

    $rtf->paragraph(
    \'\sa120',
    "Fifth text paragraph.");

    $rtf->close;



    --
    To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org
  • Rob Dixon at Oct 8, 2003 at 7:04 pm
    wrote:
    Quoting Rob Dixon <rob@dixon.port995.com>:
    wrote:

    Hi.

    A name would be nice...?

    All of the answers are in the module documentation. The code below shows
    a lot of the common requirements. Anything else you can fish from the
    POD.

    Sean, the author of the module, has written O'Reilly's "RTF Pocket Guide"
    which I haven't seen but assume is still in print. It will be much more
    comprehensive than the RTF::Cookbook POD.

    HTH,

    Rob



    use strict;
    use warnings;

    use RTF::Writer;

    my $rtf = RTF::Writer->new_to_file("demo.rtf");

    $rtf->prolog( fonts => ['Times New Roman', 'Courier New'] );

    $rtf->print(\'\f0\fs24'); # Default to Font zero (Times) in 12 pt

    $rtf->paragraph(
    \'\sa120', # 6pt space after paragraph
    \'\b', # Bold
    \'\ul', # Underline
    "Title");

    $rtf->paragraph; # Blank First Paragraph

    $rtf->paragraph(
    \'\sa120',
    "First text paragraph.");

    $rtf->paragraph(
    \'\sa120',
    \'\f1', # Font 1 (Courier)
    "Second text paragraph in Courier New",
    \'\line',
    "with an explicit line break.");

    $rtf->paragraph(
    \'\sa120',
    "Third text paragraph reverts to default font zero.");

    # Most arguments takes measurements in twips (twentieths of a point)
    # so \sa120 is a space-after of 6 points
    # Font Size takes measurements of half a point, so \fs16 is 8-point
    #
    $rtf->paragraph(
    \'\sa120',
    \'\f1',
    \'\fs16', # Font size 8pt
    "Fourth text paragraph in Courier New 8pt ",
    "with no explicit line break but extended text ",
    "to show that automatic line wrapping applies ",
    "just as in Word."
    );

    $rtf->paragraph(
    \'\sa120',
    "Fifth text paragraph.");

    $rtf->close;
    This method would be perfect unless i had problem with the
    encoding. I want to write greek documents but i cannot.
    Something like this may help:

    $rtf->prolog(
    fonts => ['Times New Roman', 'Courier New'],
    more_default => \'\deflang1253',
    );

    which sets the default language to 1253 (Greek).
    I can't try it out as I have only English fonts
    installed. It's documented in the POD, which you
    should really read.

    If you're really stuck, try editing the resulting RTF
    in WORD, changing the language to Greek, and writing
    it as a new RTF file. Then you can see what has been changed.

    Can't help you much further.

    Rob

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedOct 7, '03 at 3:17p
activeOct 8, '03 at 7:04p
posts10
users3
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase