Main Board > Web Services

Publishing a PDF through PXPlus web engine

<< < (2/2)

pwhirley:
Well, Mike.  I'm sure I'm doing something wrong.  I've tried using an HTML format with <head> and <body> putting the content-type: application/pdf and content-size in the <head> and the binary in the <body>.  I've also tried an HTTP POST format, which I've never used to send *to* a web browser.  Neither one worked. 

I've also tried using <embed>, <object> and <img> with encoding/decoding the pdf data.

What format should I be using?  I'm testing with just the web engine directly.  Eventually I'll probably be using IIS or Apache, but those aren't set up to use, yet.  I've never used the web engine except with iNOMADS, Webster+ and the old Sage 100 eBusiness stuff.

- Phil

Mike King:
Here is a simple web program that will return a PDF file:


--- Code: ---0010 OPEN (HFN)"*pdf*;file=output.pdf"
0020 FOR i=1 TO 20
0030 PRINT (LFO)"This is line ",i
0040 NEXT i
0050 CLOSE (LFO)
0060 OPEN (HFN,ISZ=-1)"output.pdf"
0070 READ RECORD (LFO,SIZ=1000000)contents$
0080 CLOSE (LFO)
0090 WRITE RECORD (%print_fn)contents$
0100 LET %Content_type$="Application/pdf"
0120 END
--- End code ---

It creates a PDF file on "output.pdf" with lines 1 thru 20, sets the content type, and returns the PDF file contents.

You should be able to save this on your PxPlus Web server in the document root directory as something like pdf.pxp then call up the URL.  It will display the PDF.

Obviously in production you would dynamically create the PDF output file name and delete it when done.

pwhirley:
Thanks Mike,
That's too easy.  :-)

The piece I was missing is the %Content-type$ global variable.  I'm sure there are many other variables used by the web engine that I don't know about.

I appreciate the help.

- Phil

Navigation

[0] Message Index

[*] Previous page

Go to full version