yujiang112569 发表于 2021-3-15 17:06:06

【activeReport】调用ARJS.PdfExport.exportDocument方法导出pdf遇到图片跨域问题....

【activeReport】调用ARJS.PdfExport.exportDocument方法导出pdf遇到图片跨域问题,请问要怎么解决呢。能正常打开预览界面,从预览界面输出pdf正常,通过调用ARJS.PdfExport.exportDocument却出现了跨域问题:'(

Crystal.Li 发表于 2021-3-16 15:33:41

可以将您的报错截个图吗?

yujiang112569 发表于 2021-3-17 21:56:19

import ARJS from "@grapecity/activereports";

    this.reportObj = JSON.parse(item.tempContent);
          var pageReport = new ARJS.Core.PageReport();
          pageReport
            .load(this.reportObj)
            .then(() => pageReport.run())
            .then(pageDocument => {
            if (type === "pdf") {
                return ARJS.PdfExport.exportDocument(
                  pageDocument,
                  {
                  fonts: this.fonts,

                  },
                  () => { }
                );
            } else if (type === "excel") {
                return ARJS.XlsxExport.exportDocument(
                  pageDocument,
                  {
                  fonts: this.fonts
                  },
                  () => { }
                );
            } else {
                return ARJS.HtmlExport.exportDocument(
                  pageDocument,
                  {
                  fonts: this.fonts
                  },
                  () => { }
                );
            }
            })
            .then(result => result.download(this.fileName));



yujiang112569 发表于 2021-3-17 21:58:15

报错信息如下:
:8080/#/quote/detail?from=quote&action=M&quotaNo=65Q21000071&title=%E6%8A%A5%E4%BB%B7%E5%8D%95%E8%AF%A6%E6%83%85-65Q21000071:1 Access to XMLHttpRequest at 'https://abk-dev-bucket-oss.800abk.com/fos/attach/20210220101444_446a9d89-02d5-4c4b-b88c-72fd5476c4af.png?Expires=1616007028&OSSAccessKeyId=LTAIJnRwUODxfT3P&Signature=ukfEZlp6wfdpujN%2B7R3%2FwRvUHRM%3D' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

yujiang112569 发表于 2021-3-17 22:00:40

Crystal.Li 发表于 2021-3-16 15:33
可以将您的报错截个图吗?

版主你好,报错信息见4楼,主要代码见3楼。我想知道我大概要传入什么参数才能解决调用activeReport自带的API出现图片跨域问题:'(

Crystal.Li 发表于 2021-3-18 09:42:25

您好,如果除去图片是不是就没有跨域?现在看起来就是图片跨域了,您这个图片资源地址无法跨域访问,如果是这样的话,是需要这个图片资源服务端去做配置的,才能解决跨域问题~
页: [1]
查看完整版本: 【activeReport】调用ARJS.PdfExport.exportDocument方法导出pdf遇到图片跨域问题....