Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Writing a Word file

compuchipcompuchip Posts: 273Member
Here's the situation: I am writing an online reservation system for a travel agency, so there are a lot of codes used that the passengers don't understand.
Therefore, I want the agency to be able to issue a command that makes a travel schedule for the clients, with the following conditions:
1) They have to be able to make changes in the document
2) The document can be printed but without the IE headers (IE always prints the date and page URL at the top - I don't want that)
3) It's possible - but not necessary - to save the document.
4) The Perl script that makes the document is able to edit the page settings, so - for example - vouchers can be printed on a small page and long schedules on 'chain paper'?
I could of course print the entire thing to a HTML page and make the user press the toolbar button that opens the document in Word, but I'm not sure if that's a good idea.
I'd rather write all the information to a Word document on the server and then open that in a frame. I don't know if this is possible though: I searched the entire Internet.
What do you recommend? And *is* it possible to use Perl to create a Word document on the server and open it in the browser, from where it can be edited, saved and/or printer without the IE header+footer?

Thanks a lot.
«1

Comments

  • JonathanJonathan Posts: 2,914Member
    Hi,

    : What do you recommend? And *is* it possible to use Perl to create a
    : Word document on the server and open it in the browser, from where
    : it can be edited, saved and/or printer without the IE header+footer?
    I don't know about creating a Word file. I've looked around CPAN and don't see any modules for that. There are however a range of modules that allow you to create a PDF file, namely PDF::Create, and you may want to investigate these as an alternative to Word. People on platforms other than Windows almost certainly won't have word but they may have a hope of reading a PDF file. Anyone without MS Office will be blocked from reading it too... Just some thoughts. :-)

    Hope this helps,

    Jonathan



    -------------------------------------------
    Count your downloads:
    http://www.downloadcounter.com/
    And host your site:
    http://www.incrahost.com/
    Don't say I never give you anything... ;-)

  • compuchipcompuchip Posts: 273Member
    [b][red]This message was edited by compuchip at 2003-3-23 12:8:4[/red][/b][hr]
    Thanks, but as I have explained, this function is only for the travel agency. Their employees have to be able to edit this document and they all have access to a copy of Word at their workstation.
    The clients might not, but they will only be able to check out their reservation details online in HTML.

    If it's not possible perhaps you can a) tell me how to 'fill in' a Word template or b) tell me how to edit the page formatting in HTML.

    Thanks.

    : Hi,
    :
    : : What do you recommend? And *is* it possible to use Perl to create a
    : : Word document on the server and open it in the browser, from where
    : : it can be edited, saved and/or printer without the IE header+footer?
    : I don't know about creating a Word file. I've looked around CPAN and don't see any modules for that. There are however a range of modules that allow you to create a PDF file, namely PDF::Create, and you may want to investigate these as an alternative to Word. People on platforms other than Windows almost certainly won't have word but they may have a hope of reading a PDF file. Anyone without MS Office will be blocked from reading it too... Just some thoughts. :-)
    :
    : Hope this helps,
    :
    : Jonathan
    :
    :
    :
    : -------------------------------------------
    : Count your downloads:
    : http://www.downloadcounter.com/
    : And host your site:
    : http://www.incrahost.com/
    : Don't say I never give you anything... ;-)
    :
    :



  • JonathanJonathan Posts: 2,914Member
    : Thanks, but as I have explained, this function is only for the
    : travel agency. Their employees have to be able to edit this document
    : and they all have access to a copy of Word at their workstation.
    : The clients might not, but they will only be able to check out their
    : reservation details online in HTML.
    Fair enough...

    : If it's not possible perhaps you can a) tell me how to 'fill in' a
    : Word template or b) tell me how to edit the page formatting in HTML.
    a) No idea.
    b) Uh...just alter the HTML code?

    How about writing an RTF file? They use plain text control characters (though it's a horrible format) and you could make an RTF file and put things like $variable in it and then print it to a file and it'd interpolate the variables and probably work OK. RTF can then be opened in Word.

    Jonathan


    -------------------------------------------
    Count your downloads:
    http://www.downloadcounter.com/
    And host your site:
    http://www.incrahost.com/
    Don't say I never give you anything... ;-)

  • compuchipcompuchip Posts: 273Member
    : : Thanks, but as I have explained, this function is only for the
    : : travel agency. Their employees have to be able to edit this document
    : : and they all have access to a copy of Word at their workstation.
    : : The clients might not, but they will only be able to check out their
    : : reservation details online in HTML.
    : Fair enough...
    :
    : : If it's not possible perhaps you can a) tell me how to 'fill in' a
    : : Word template or b) tell me how to edit the page formatting in HTML.
    : a) No idea. [red]ok[/red]
    : b) Uh...just alter the HTML code? [red]For me, that's not a problem, but I can't expect employees of a *tour operator* (!!!) to learn HTML just for this purpose, can I?[/red]
    :
    : How about writing an RTF file? They use plain text control characters (though it's a horrible format) and you could make an RTF file and put things like $variable in it and then print it to a file and it'd interpolate the variables and probably work OK. RTF can then be opened in Word.
    :
    : Jonathan

    [red]Can you tell me more about the RTF writing?
    Can I edit the page formatting? Can I write tables?[/red]
  • JonathanJonathan Posts: 2,914Member
    : b) Uh...just alter the HTML code? [red]For me, that's not a
    : problem, but I can't expect employees of a *tour operator* (!!!) to
    : learn HTML just for this purpose, can I?[/red]
    WYSIWYG HTML editor? And did you know that Word can open HTML files? But maybe it's still not the best way forward.

    : How about writing an RTF file? They use plain text control
    : characters (though it's a horrible format) and you could make an RTF
    : file and put things like $variable in it and then print it to a file
    : and it'd interpolate the variables and probably work OK. RTF can
    : then be opened in Word.
    : [red]Can you tell me more about the RTF writing?
    : Can I edit the page formatting?[/red]
    You can do whatever you want if you take the time to figure out the RTF formatting. But it's not nice. I have to reverse engineer an RTF file to work it all out, but there will probably be documentation somewhere. But it is a text based format so it's not a big job, especially and if variable interpolation is all you want to do it's easy enough.

    : [red]Can I write tables?[/red]
    Don't think RTF supports tables, no. But I may be wrong...

    Jonathan

    -------------------------------------------
    Count your downloads:
    http://www.downloadcounter.com/
    And host your site:
    http://www.incrahost.com/
    Don't say I never give you anything... ;-)

  • compuchipcompuchip Posts: 273Member
    Hmm.. well thank you for the info anyway.
    I'll see if there's something useful at CSPAN.

    : : b) Uh...just alter the HTML code? [red]For me, that's not a
    : : problem, but I can't expect employees of a *tour operator* (!!!) to
    : : learn HTML just for this purpose, can I?[/red]
    : WYSIWYG HTML editor? And did you know that Word can open HTML files? But maybe it's still not the best way forward.
    :
    : : How about writing an RTF file? They use plain text control
    : : characters (though it's a horrible format) and you could make an RTF
    : : file and put things like $variable in it and then print it to a file
    : : and it'd interpolate the variables and probably work OK. RTF can
    : : then be opened in Word.
    : : [red]Can you tell me more about the RTF writing?
    : : Can I edit the page formatting?[/red]
    : You can do whatever you want if you take the time to figure out the RTF formatting. But it's not nice. I have to reverse engineer an RTF file to work it all out, but there will probably be documentation somewhere. But it is a text based format so it's not a big job, especially and if variable interpolation is all you want to do it's easy enough.
    :
    : : [red]Can I write tables?[/red]
    : Don't think RTF supports tables, no. But I may be wrong...
    :
    : Jonathan
    :
    : -------------------------------------------
    : Count your downloads:
    : http://www.downloadcounter.com/
    : And host your site:
    : http://www.incrahost.com/
    : Don't say I never give you anything... ;-)
    :
    :

  • compuchipcompuchip Posts: 273Member
    I've spent all afternoon looking for a simple script or package but came up with nothing. Maybe there's something wrong with my way of searching?
    All I want is a free Perl script / package that will let me write RTF files to a directory on my server that contain tables (and preferably let me change the page setup).
    Is that too much asked?
  • JonathanJonathan Posts: 2,914Member
    No point getting frustrated...

    : I've spent all afternoon looking for a simple script or package but
    : came up with nothing. Maybe there's something wrong with my way of
    : searching?
    Maybe, I've just found what you were probably looking for in about 30 seconds. I just went to:-
    http://www.cpan.org/
    And went to the page "CPAN modules, distributions, and authors" and entered RTF. And various RTF stuff came up.

    : All I want is a free Perl script / package that will let me write
    : RTF files to a directory on my server that contain tables (and
    : preferably let me change the page setup).
    Search above should find you the package you want:-
    http://search.cpan.org/author/RRWO/RTF-Document-0.64/Document.pm
    "...that contain tables..." - I told you in a previous thread I believe RTF doesn't support tables! Just 'cus I'm known to be wrong doesn't mean I will be every time. :-)

    : Is that too much asked?
    Let's think about this for a minute. Perl - free. CPAN modules - free. People have to put serious amounts of time in to do these things. The fact that people make any of this free is a great personal giving on their part in my opinion, and I greatly respect the work of these people and their contribution to the computing community. If you've got a gripe about what's available I suggest you fix it yourself or go about doing that.

    What kind of server you running on? If you're on a Windows server (and I think this is gonna be the first time I've ever said a Windows server is gonna be an advantage) then you can make a program in something other than Perl that will be able to create the Word file as I believe you can actually create an instance of word and make a document on the fly using that. Then reference that from Perl. But I don't know anything on how.

    I still think my best thought was to make it a HTML output, because Word can open HTML just fine and it can be saved into a Word Document.

    Jonathan


    ###
    ('Is Perl Just Another Hack?' =~ /^w+ (w+) (w+) (w+)(er) (w+)?$/) and print "$2 $3$4 $1 $5$4";
    ###
    http://www.incrahost.com/ :: Great Hosting!
    ###

  • compuchipcompuchip Posts: 273Member
    lol, thanks for cooling me down, I just was really pissed last night.
    Based on your info I have searched again and came up with a solution so simple that I can't believe I didn't think of it myself.
    I use Word to create a "template" RTF document and a few documents that only contain the three types of tables needed. Where I want variables to be interpolated I write $variablename.
    The only thing needed to be done is
    $line =~ s/$([^ .,?!
    \]*)/${$1}/g;

    When I need one of the three tables, I can read in the appropriate file and insert it in $line.

    Thank you so very much for your support with this :)))))

    : No point getting frustrated...
    :
    : : I've spent all afternoon looking for a simple script or package but
    : : came up with nothing. Maybe there's something wrong with my way of
    : : searching?
    : Maybe, I've just found what you were probably looking for in about 30 seconds. I just went to:-
    : http://www.cpan.org/
    : And went to the page "CPAN modules, distributions, and authors" and entered RTF. And various RTF stuff came up.
    :
    : : All I want is a free Perl script / package that will let me write
    : : RTF files to a directory on my server that contain tables (and
    : : preferably let me change the page setup).
    : Search above should find you the package you want:-
    : http://search.cpan.org/author/RRWO/RTF-Document-0.64/Document.pm
    : "...that contain tables..." - I told you in a previous thread I believe RTF doesn't support tables! Just 'cus I'm known to be wrong doesn't mean I will be every time. :-)
    :
    : : Is that too much asked?
    : Let's think about this for a minute. Perl - free. CPAN modules - free. People have to put serious amounts of time in to do these things. The fact that people make any of this free is a great personal giving on their part in my opinion, and I greatly respect the work of these people and their contribution to the computing community. If you've got a gripe about what's available I suggest you fix it yourself or go about doing that.
    :
    : What kind of server you running on? If you're on a Windows server (and I think this is gonna be the first time I've ever said a Windows server is gonna be an advantage) then you can make a program in something other than Perl that will be able to create the Word file as I believe you can actually create an instance of word and make a document on the fly using that. Then reference that from Perl. But I don't know anything on how.
    :
    : I still think my best thought was to make it a HTML output, because Word can open HTML just fine and it can be saved into a Word Document.
    :
    : Jonathan
    :
    :
    : ###
    : ('Is Perl Just Another Hack?' =~ /^w+ (w+) (w+) (w+)(er) (w+)?$/) and print "$2 $3$4 $1 $5$4";
    : ###
    : http://www.incrahost.com/ :: Great Hosting!
    : ###
    :
    :

  • JonathanJonathan Posts: 2,914Member
    : lol, thanks for cooling me down, I just was really pissed last night.
    I figured... ;-)

    : Based on your info I have searched again and came up with a solution
    : so simple that I can't believe I didn't think of it myself.
    : I use Word to create a "template" RTF document and a few documents
    : that only contain the three types of tables needed. Where I want
    : variables to be interpolated I write $variablename.
    : The only thing needed to be done is
    : $line =~ s/$([^ .,?!
    \]*)/${$1}/g;
    :
    : When I need one of the three tables, I can read in the appropriate
    : file and insert it in $line.

    Wow! And interpolating variables straight into a word file actually works and doesn't trash the file and so on? I know it won't with RTF (unless the variable contains dodgy characters such as , { and }) but I didn't know it'd work in Word documents. Anyway, pleased to hear it does!

    : Thank you so very much for your support with this :)))))
    No problem. Happy hacking...

    Jonathan


    ###
    ('Is Perl Just Another Hack?' =~ /^w+ (w+) (w+) (w+)(er) (w+)?$/) and print "$2 $3$4 $1 $5$4";
    ###
    http://www.incrahost.com/ :: Great Hosting!
    ###

«1
Sign In or Register to comment.