fumasoft 发表于 2018-5-23 18:41:50

JSON数据源导出PDF中图片不显示问题

本帖最后由 fumasoft 于 2018-5-31 18:44 编辑

公司安排我做一个JSON数据源导出PDF的功能,数据中有一个图片需要显示,图片数据是一个URL的图片ID,这个ID会传入报表,与内置的URL拼接并显示出来,但是我在预览状态下可以看到图片显示,但是用WinForm导出报表时看不到图片,可是我可以将图片ID做文本显示出来,但不知道为什么图片无法显示。





请大神指导一下


KearneyKang 发表于 2018-5-24 10:44:28

你好,你现在的问题是在winform的情况下,显示图片是可以正常显示的,但是导出PDF的时候图片就显示不出来是吧!
如果是这样,你试着换另外一种PDF的导出方式试试:

// Provide the page report you want to render.
System.IO.FileInfo rptPath = new System.IO.FileInfo(@"..\..\PageReport1.rdlx");
GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport(rptPath);

// Create an output directory.
System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyPDF");
outputDirectory.Create();

// Provide settings for your rendering output.
GrapeCity.ActiveReports.Export.Pdf.Page.Settings pdfSetting = new GrapeCity.ActiveReports.Export.Pdf.Page.Settings();

// Reduce the report size and report generation time.
pdfSetting.OptimizeStatic = true;

// Set the rendering extension and render the report.
GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension pdfRenderingExtension = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name));
            
// Overwrite output file if it already exists
outputProvider.OverwriteOutputFile = true;

pageReport.Document.Render(pdfRenderingExtension, outputProvider, pdfSetting);




fumasoft 发表于 2018-5-24 14:39:06

不是,WinForm也显示不出来

KearneyKang 发表于 2018-5-24 16:00:16

那就是直接预览的时候,就显示不出来。
那你要确保图片的URL是正确的,并且在控件图片直接绑定显示的这个URL是可以显示图片的,也就是说,你在winform图片里显示的文字,也就是URL链接是可以显示出来的。如下图这样

fumasoft 发表于 2018-5-24 18:21:09

我知道了,我的图片路径是https的,我看了一个你的贴子
[
设置了<ActiveReports11>
    <WebServicepublicURI   publicURI="https://xxx.com" />
</ActiveReports11>
但是reportService: { url: 'http://reverse-proxy.com'; };这种怎么设置啊,设置到哪个文件中啊

KearneyKang 发表于 2018-5-25 10:57:26

本帖最后由 KearneyKang 于 2018-5-25 10:58 编辑

你看到这个解决办法可能不可以解决你的问题,这个是Java用户使用AR然后的内外网端口不一致导致无法访问的问题。
你这个是图片绑定的URL根本就不正确的问题,也就是说你的Value值不正确。你要确保绑定的value 值正确,然后图片才可以正常显示

fumasoft 发表于 2018-5-25 15:22:38

本帖最后由 fumasoft 于 2018-5-25 16:35 编辑

哦,好,我再看一下路径问题

KearneyKang 发表于 2018-5-25 16:36:46

你的URL是没有问题,我在我本地直接绑定你提供的是可以正常显示的。
用记事本打开报表的配置信息如下:
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition">
        <Body>
                <Height>5cm</Height>
                <ReportItems>
                        <Image Name="Image1">
                                <Height>3.4cm</Height>
                                <Left>3.4cm</Left>
                                <Sizing>Fit</Sizing>
                                <Source>External</Source>
                                <Style />
                                <Top>0.6cm</Top>
                                <Value>https://aapi.laifuyun.com/v2/image/2,0a3e0ece9d55/@100</Value>
                                <Width>5cm</Width>
                        </Image>
                </ReportItems>
                <Style />
        </Body>
        <BottomMargin>2.5cm</BottomMargin>
        <LeftMargin>2.5cm</LeftMargin>
        <PageHeight>29.7cm</PageHeight>
        <PageWidth>21cm</PageWidth>
        <RightMargin>2.5cm</RightMargin>
        <TopMargin>2.5cm</TopMargin>
        <Width>16cm</Width>
</Report>

fumasoft 发表于 2018-5-25 18:43:44

不好意思,是我这边的问题,现在我已经可以显示图片了,谢谢

KearneyKang 发表于 2018-5-28 09:06:28

很高兴,解决了困扰您很久的问题。你具体是哪里操作导致了该问题
页: [1] 2
查看完整版本: JSON数据源导出PDF中图片不显示问题