Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread How to receive a PDF file via a service
Tue, Feb 16 2021 2:46 AMPermanent Link

Paul Coshott

Avatar

Hi All,

I need to send a couple of bits of filter criteria via a service to my rest server, where a report will be generated as a pdf file. The service can then return the pdf file.

My question is what data type is best used for EWB to receive the pdf file? I haven't written the rest service yet, so wondering what EWB needs to receive.

Cheers,
Paul
Tue, Feb 16 2021 8:31 AMPermanent Link

Paul Coshott

Avatar

So I just found out the correct way to send the pdf file from my rest service is using a TStream.

How do I receive a TStream in EWB and then display the pdf file?

Cheers,
Paul
Wed, Feb 17 2021 11:01 AMPermanent Link

erickengelke

Avatar

Paul Coshott wrote:
>I need to send a couple of bits of filter criteria via a service to my rest server, where a report will be generated
> as a pdf file. The service can then return the pdf file.
>
>My question is what data type is best used for EWB to receive the pdf file? I haven't written the rest service yet, so >wondering what EWB needs to receive.

There are two ways that pop in mind.

I generally display in a TBrowser.

One solution is to set the header field declaring the content as Applicaiton/PDF
and then just dump the PDF in the output and have the TBrowser load the file as a URL, passing any parameters you need on the URL line encoded in typical URI format.  This is the simplest.

The other solution I use elsewhere is to Base64 encode the PDF on the server and return it in a string field in your JSON. returned to the client.  Then assign the PDF string to the url of the TBrowser after loading the JSON into a TDataset.  This is handy for a number of reasons, you can pass along other parameters in the JSON (such as file date, etc.).   You will need to look up how to create a PDF Base64 encoded URL.  It's not hard.

Erick
EWB Programming Books and Component Library
http://www.erickengelke.com
Image