Avatar

Level 2

Hello,

My goal is to have a webform with a link for the client to download a PDF, this PDF should come from a HTTP request from a server in our network and I will display it via webform to the public.

I'm not able to receive the full response for a PDF on an HttpClientRequest, it seems that everytime the pdf is incomplete, if I try with a website URL the response is longer and ok, but never with PDF.

I've try all kinds of hearders but with no success.

Here's a sample of the code:

Code

var url = 'https://www.soundczech.cz/temp/lorem-ipsum.pdf';

var http = new HttpClientRequest(url);

http.method = "GET";

http.header["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36";

http.header["Accept"] = "application/pdf";

http.header["Content-Type"] = "application/pdf;charset=utf-8";

http.header["accept-encoding"] = "gzip, deflate";

http.execute();

logInfo(http.response.body);

pdf = http.response.body;;

The logInfo goes to web@default and the pdf is displayed on webpage.

Thanks for any help