WEBSPEED with PDFInclude

I can't generate pdf file in webserver

RUN pdf_new ("Spdf","http://example.com/pdf/Hello.pdf").
RUN pdf_new ("Spdf","c:\temp\pdf\Hello.pdf").
RUN pdf_new ("Spdf","data/programs/pdf/Hello.pdf").

what is the correct form?
need some especial settings or configuration in the server?

in local works fine, but when i put it in webserver doesn't work
any suggestion or examples that I can see with webspeed working


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
CyrixInstead's picture

WEBSPEED with PDFInclude

When I use PDFInclude with WebSpeed I create a temporary PDF file on the web server and then read that in and output through the Webstream.

For example, output to a temporary file name:

ASSIGN cFilePDF = OS-GETENV("temp":U) + "/temporary_filename.pdf".
RUN pdf_new("Spdf",cFilePDF).
/* Continue building PDF */

After the pdf has been created by PDFInclude read it in and output to the webstream. In my example the variable cFilePDF is the name that the PDF sent to the user's browser will be called:

DEFINE VARIABLE rwFileLine AS RAW        NO-UNDO.

/* Output HTTP headers prior to running. Use the Output-Content-Type() function
to output the proper header based on the file type. For instance to output
a .gif file, you would use output-content-type("image/gif").
A fully qualified path is required.

/* This will open the PDF in the user's browser */
output-http-header ("Content-disposition","Inline~;filename=" + cFileOut).
/* You would use the following to open the save dialog */
/*output-http-header ("Content-disposition","Attachment~;filename=" + cFileOut).*/

/* Must use the Binary qualifier here to prevent code page
   tanslations on the way in. */

INPUT STREAM infile FROM VALUE(cFilePDF) BINARY NO-ECHO NO-MAP NO-CONVERT.

/* Read the file in 1024 byte chunks.  Input must be UNFORMATTED
   in order to read the binary codes. Output directly to the
   browser using the WEBSTREAM pre-processor. PUT must also
   use CONTROL to prevent code page translations on the way out. */

REPEAT:
    LENGTH(rwFileLine) = 1024.
    IMPORT STREAM infile UNFORMATTED rwFileLine.
    PUT {&WEBSTREAM} CONTROL rwFileLine.
END.

/* Clean-up: Raw variable should be reset to deallocate the memory, the stream
             should be closed and the temporary PDF deleted. */

LENGTH(rwFileLine) = 0.
INPUT STREAM infile CLOSE.
OS-DELETE VALUE(cFilePDF) NO-ERROR.

Hope that helps!

~Cyrix