Publishing a PDF through PXPlus web engine

Started by pwhirley, March 06, 2024, 02:30:45 PM

Previous topic - Next topic

pwhirley

I need to create a label of a specific size, format, font, etc and present it to be printed on the website.  The PVXPlus web engine will be running on one server and the website is on another server.  The website host will not have access to the folders for the application. The only access is through the web engine.

I'm using the *PDF* special file to create the PDF, but I do not know how to get the web server to publish that back to the website.  I'm sure it's simple.

Thanks - Phil
Philip Whirley
Freelance software developer
Ride the Lowcountry, LLC
phil@whirley.org

Mike King

How is the website forwarding the request to the PxPlus web server?  If its by a standard web request you likely could have the PxPlus web server application respond with the contents of the web file and set the content type to "application/pdf".  Basically open/read the resultant PDF file as a binary file and write it to %PRINT_FN.

Assuming the webs site forwards the response that it receives along with its headers the PDF should get displayed.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Mike King

Another thought, if the web server is Apache you might be able to use ProxyPass (and possibly ProxyPassReverse) to have the web simply re-route the specific request to your backend PVX Plus web server. 

This could be used to forward to whole request and return the result or to forward a request for the resultant PDF file and simply leave the PDF files on the PxPlus server.

There is something similar available for IIS if needed.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

pwhirley

Thanks Mike,
I think that the application/pdf might well work.  I'm not sure why I didn't think of that.  It should work fine with the IIS front end, I believe.

I appreciate the quick response.  I hope you're enjoying retirement as much as I am.  :-)

Phil

Philip Whirley
phil@whirley.org
Philip Whirley
Freelance software developer
Ride the Lowcountry, LLC
phil@whirley.org

Mike King

Let me know if you have any issue with setting the content type.  It should work.

As for me, while we have left PVX Plus Technologies, I am enjoying semi-retirement.  Doing some ad-hoc consulting in order to keep active and busy.

Anyway, if you need help feel free to contact me and we will see what we can do.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

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
Philip Whirley
Freelance software developer
Ride the Lowcountry, LLC
phil@whirley.org

Mike King

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

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


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.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

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
Philip Whirley
Freelance software developer
Ride the Lowcountry, LLC
phil@whirley.org