Question about webspeed and pdfinclude.

FrancoisL

Member
Hello everyone,

I saw many messages about using Webspeed and pdfinclude for reporting . But i have a question beyond generating the report itself.

pdfincludes generates a pdf file on your system but what technique do you use to get that file to the Webstream.

I see 2 ways that it can be possibly done , either you generate the file directly on your webserver and redirect the browser to that page once it generated (would like to avoid this). The other way is that you input from the generated file and output it to the webstream.

Is there another way ? And if you use the input/output method what header do you have to send to the webstream ? And what kind of input / output do you use? binary? ( can it be sent on the webstream with {&OUT} or do you have to do something special?

Thanks for the help,
 

Casper

ProgressTalk.com Moderator
Staff member
I generate the file at the database server and then send it to the webserver using something like:

Code:
DEFINE INPUT  PARAMETER cp_file AS CHARACTER  NO-UNDO.
DEFINE VARIABLE i_len      AS INTEGER    NO-UNDO.
DEFINE VARIABLE i_length   AS INTEGER    NO-UNDO.
DEFINE VARIABLE ra_rawdata AS RAW        NO-UNDO.
 
INPUT FROM VALUE(cp_file) BINARY NO-MAP NO-CONVERT.
/* find length */
SEEK INPUT TO END.
i_len = SEEK(INPUT).
/* position at start */
SEEK INPUT TO 0.
/* Output header */
{&OUT} "Content-Type: application/pdf" SKIP
       "Accept-Ranges: none" skip
       "Content-Length: " i_len format ">>>>>>9" skip (1).
/*stream file to webpage in 8k blocks (just a number :-) ) */
ASSIGN LENGTH (ra_rawdata) = 8192.
REPEAT:
    IMPORT UNFORMATTED ra_rawdata.
    PUT {&WEBSTREAM} CONTROL ra_rawdata.
END.
ASSIGN LENGTH (ra_rawdata) = 0.  /* Deallocate memory */
INPUT CLOSE.

HTH,

Casper.
 

FrancoisL

Member
wow very nice code,

Thanks alot Casper,
 
Top