如何使用WebService显示或下载PDF文件的包含?

发布于 2025-01-27 12:38:31 字数 835 浏览 3 评论 0原文

首先,我在WebServices和JavaScript上认识。

我正在尝试调用以这种格式返回PDF文件的Web服务:

”在此处输入图像描述

为了调用PDF,我正在使用res.body,就像下面的代码:

    var url="https://........../......./..../..";
    var options = {
  "rejectUnauthorized": false,
  "method": "GET",
  "url": url,
 "headers": {
    "Authorization": "Basic EJFHUygdiAISDGIF",
    "Content-Type": "application/json"
  }
 
};



request(options, (err, res) => {

  if (res.statusCode == 200 )  {
   
    conversation.logger().info("pdf:" + res.body); // in order to check the content of the pdf in the platform i use
  }
});

我的问题是我没有知道如何下载或显示PDF内容。

任何帮助都是有价值的。

first of all i am quite knew at webservices and javascript.

I am trying to call a web service that returns a pdf file in this format :

enter image description here

In order to call the pdf i am using res.body just like the code below :

    var url="https://........../......./..../..";
    var options = {
  "rejectUnauthorized": false,
  "method": "GET",
  "url": url,
 "headers": {
    "Authorization": "Basic EJFHUygdiAISDGIF",
    "Content-Type": "application/json"
  }
 
};



request(options, (err, res) => {

  if (res.statusCode == 200 )  {
   
    conversation.logger().info("pdf:" + res.body); // in order to check the content of the pdf in the platform i use
  }
});

My problem here is that i dont know how to download or display the pdf content .

Any help would be valuable.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

海夕 2025-02-03 12:38:31

将内容类型更改为PDF

"headers": {
    "Authorization": "Basic EJFHUygdiAISDGIF",
    "Content-Type": "application/pdf"
  }

Change content type to pdf

"headers": {
    "Authorization": "Basic EJFHUygdiAISDGIF",
    "Content-Type": "application/pdf"
  }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文