Matthew,

Here is what I do - may or may not help. I wrote a requisition system that
requires paper copy of requisitions entered. The paper copy is very formated
- would be a nightmare in html.

I create the form in word and then save it as rtf.  Everywhere I need to
inject data from the db, I enter as a variable. Like this

blah blah blah blah %%var1%% blah blah blah blah %%var2%% etc....


Then I have a routine in one of my packages that I took from the Advanced
Perl book. ( I also use this for all of my HTML template work also). However
in this version I have modified the routine so that it takes a template file
as imput and a result file as output giving me a whole new rtf file.

The routine:


=pod

=head1                  Module: Template2File

=head2                Uses template to merge user data and file into new
file


=over 4

=item 1
            Accepts the template file name the "fillings" or user data and
then
            merges the fillings into the template and writes the whole thing

            back out to the accepted output file. 

              use:  &Template2File('templateFile.rtf', $hash_ptr,
'resultfile.rtf');

=back


=cut

sub Template2File {

    my ($infile, $fillings, $outfile) = @_;
    my $text;
    local $/;
    local *F;
    open(F, "< $infile\0") || return ($!);
    $text = <F>;
    close(F);

    $text =~ s{ ~ ( .*? ) ~ }
    { exists( $fillings->{$1} )
      ? $fillings->{$1}
      : ""
      }gsex;

    open(F, "> $outfile\0") || return ($!);
    print F $text;
    close F;
    return(1);
}
1;

In my perl code I build a hash ref like this.

$form->{var1} = 'data from the db that I want in variable 1';
$form->{var2} = 'more data for variable 2';

&Template2File('MyRTFTemplate.rtf', $form, 'Result.rtf');

>From there I post the rtf for download to the user from my html directory
under apache.

The user can download it, read it, print it or whatever.


HTH

Ciao!




-----Original Message-----
From: Matthew J. Salerno [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 27, 2002 7:33 PM
To: [EMAIL PROTECTED]
Subject: Perl - CGI - OLE Advide 


Hi all, I need some advice.  I am working on a project, and I am looking for
the best way to do it.  This is all on an internal lan, running Windows 2000
Server with Apache Http.  I wrote a perl cgi interface that allows employees
to search a mysql database.  All of the returned records are perfectly
formatted.  When the correct record is saved, via submit button, I need to
be able to fill in and print out a document as the last step.  I have
everything down except for the document part.  What will be the best way for
me to do this ?

This document is a contact with all kinds of crazy formatting that html
cannot handle.  All I need to do in the document is search and replace all.

Can I pass OLE commands to the workstations via Perl/Http/Ole ?
If not, should I have the server do all of the printing ?

Please advise.

Thanks,

Matt

_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to