XtraReports-导出为PDF时图像空白

时间:2019-07-08 08:34:23

标签: devexpress export-to-pdf xtrareport

我已经创建了下面的报告文件(quote.repx)。 我创建了一个图像字段,并将其映射到一个名为image_url的json字段,其中包含完整的图像URL 例如“ image_url”:“ https://designshack.net/wp-content/uploads/st-dummycontent-6.jpg

在预览中,使用json对象可以正常工作。

但是我想做的是使用基于用户的自定义图像即时传递json 这是我的C#代码

//Set Template Name for user
string templateName = "quote.repx";

//Build Report object Using Customer Data
dynamic report = BuildReport();

// Return Full formatted JSON the same layout as the template, but customised to user
string j = JsonConvert.SerializeObject(report);

//Build new JSON Data source using JSON string above
var jsonDataSource = new JsonDataSource();
jsonDataSource.JsonSource = new CustomJsonSource(j);

//Fill the DataSource
jsonDataSource.Fill();

//Get the report template and set the JSON data as the datasource
XtraReport result = new XtraReport();
result.LoadLayout(@"D:\\devexpress_templates\\" + templateName);
result.DataSource = jsonDataSource;

//export the result file to PDF and export to byte array
MemoryStream ms = new MemoryStream();
result.ExportToPdf(ms);
byte[] file = ms.ToArray();

return file;

除图像外,所有其他操作均有效。 JSON在[image_url]字段中包含与上述相同的图像url。

图像始终显示为空白。 为了使图像显示在PDF上,我还需要做些其他事情吗

这是从下面的完整模板中获取的image_url的表达式

   <Item4 Ref="47" ControlType="XRPictureBox" Name="pictureBox1" Sizing="ZoomImage" SizeF="149.235565,100.416664" LocationFloat="0, 0">
              <ExpressionBindings>
                <Item1 Ref="48" Expression="[image_url]" PropertyName="ImageUrl" EventName="BeforePrint" />
              </ExpressionBindings>
            </Item4>

这是完整的quote.repx文件

<?xml version="1.0" encoding="utf-8"?>
<XtraReportsLayoutSerializer SerializerVersion="19.1.4.0" Ref="1" ControlType="DevExpress.XtraReports.UI.XtraReport, DevExpress.XtraReports.v19.1, Version=19.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Name="XtraReport" PageWidth="850" PageHeight="1100" Version="19.1" DataSource="#Ref-0" Font="Arial, 9.75pt">
  <Bands>
    <Item1 Ref="2" ControlType="DetailBand" Name="Detail" HeightF="0" KeepTogether="true" TextAlignment="TopLeft" StyleName="baseControlStyle" Padding="0,0,0,0,100" />
    <Item2 Ref="3" ControlType="TopMarginBand" Name="TopMargin" TextAlignment="TopLeft" Padding="0,0,0,0,100">
      <StylePriority Ref="4" UseBackColor="false" />
    </Item2>
    <Item3 Ref="5" ControlType="BottomMarginBand" Name="BottomMargin" TextAlignment="TopLeft" Padding="0,0,0,0,100">
      <Controls>
        <Item1 Ref="6" ControlType="XRTable" Name="vendorContactsTable" SizeF="378.9991,15" LocationFloat="271, 25" Font="Segoe UI, 7.75pt" BorderColor="255,213,211,205">
          <Rows>
            <Item1 Ref="7" ControlType="XRTableRow" Name="vendorContactsRow" Weight="1">
              <Cells>
                <Item1 Ref="8" ControlType="XRTableCell" Name="vendorWebsite" Weight="1" CanGrow="false" CanShrink="true" Text="VendorWebsite" TextAlignment="MiddleLeft">
                  <StylePriority Ref="9" UseTextAlignment="false" />
                </Item1>
                <Item2 Ref="10" ControlType="XRTableCell" Name="vendorEmail" Weight="1" CanGrow="false" CanShrink="true" Text="VendorEmail" TextAlignment="MiddleCenter">
                  <StylePriority Ref="11" UseBorders="false" UseTextAlignment="false" />
                </Item2>
                <Item3 Ref="12" ControlType="XRTableCell" Name="vendorPhone" Weight="1" CanGrow="false" CanShrink="true" Text="VendorPhone" TextAlignment="MiddleRight">
                  <StylePriority Ref="13" UseBorders="false" UseTextAlignment="false" />
                </Item3>
              </Cells>
            </Item1>
          </Rows>
          <StylePriority Ref="14" UseFont="false" UseBorderColor="false" />
        </Item1>
      </Controls>
    </Item3>
    <Item4 Ref="15" ControlType="GroupHeaderBand" Name="GroupHeader2" GroupUnion="WithFirstDetail" Level="1" HeightF="313.3333" StyleName="baseControlStyle">
      <GroupFields>
        <Item1 Ref="16" FieldName="InvoiceNumber" />
      </GroupFields>
      <Controls>
        <Item1 Ref="17" ControlType="XRLabel" Name="label2" Multiline="true" Text="Deliver To" SizeF="100,23" LocationFloat="334.583344, 110.541664" Font="Segoe UI, 9.75pt, style=Bold" Padding="2,2,0,0,100">
          <StylePriority Ref="18" UseFont="false" />
        </Item1>
        <Item2 Ref="19" ControlType="XRLabel" Name="label1" Multiline="true" Text="Invoice To" SizeF="100,23" LocationFloat="10.0000067, 110.541664" Font="Segoe UI, 9.75pt, style=Bold" Padding="2,2,0,0,100">
          <StylePriority Ref="20" UseFont="false" />
        </Item2>
        <Item3 Ref="21" ControlType="XRTable" Name="table1" TextAlignment="TopRight" SizeF="287.6791,150" LocationFloat="334.583344, 133.541687">
          <Rows>
            <Item1 Ref="22" ControlType="XRTableRow" Name="tableRow1" Weight="1">
              <Cells>
                <Item1 Ref="23" ControlType="XRTableCell" Name="tableCell1" Weight="1" CanShrink="true" Text="VendorName" TextAlignment="MiddleLeft">
                  <ExpressionBindings>
                    <Item1 Ref="24" Expression="[deliver_to_name]" PropertyName="Text" EventName="BeforePrint" />
                  </ExpressionBindings>
                  <StylePriority Ref="25" UseFont="false" UsePadding="false" UseTextAlignment="false" />
                </Item1>
              </Cells>
            </Item1>
            <Item2 Ref="26" ControlType="XRTableRow" Name="tableRow2" Weight="1">
              <Cells>
                <Item1 Ref="27" ControlType="XRTableCell" Name="tableCell2" Weight="1" CanShrink="true" Text="VendorAddress" TextAlignment="MiddleLeft">
                  <ExpressionBindings>
                    <Item1 Ref="28" Expression="[deliver_to_address]" PropertyName="Text" EventName="BeforePrint" />
                  </ExpressionBindings>
                  <StylePriority Ref="29" UseFont="false" UseTextAlignment="false" />
                </Item1>
              </Cells>
            </Item2>
            <Item3 Ref="30" ControlType="XRTableRow" Name="tableRow3" Weight="1">
              <Cells>
                <Item1 Ref="31" ControlType="XRTableCell" Name="tableCell3" Weight="1" CanShrink="true" Text="VendorCity" TextAlignment="MiddleLeft">
                  <ExpressionBindings>
                    <Item1 Ref="32" Expression="[deliver_to_city]" PropertyName="Text" EventName="BeforePrint" />
                  </ExpressionBindings>
                  <StylePriority Ref="33" UseFont="false" UseTextAlignment="false" />
                </Item1>
              </Cells>
            </Item3>
            <Item4 Ref="34" ControlType="XRTableRow" Name="tableRow4" Weight="1">
              <Cells>
                <Item1 Ref="35" ControlType="XRTableCell" Name="tableCell4" Weight="1" CanShrink="true" Text="VendorCountry" TextAlignment="MiddleLeft">
                  <ExpressionBindings>
                    <Item1 Ref="36" Expression="[deliver_to_county]" PropertyName="Text" EventName="BeforePrint" />
                  </ExpressionBindings>
                  <StylePriority Ref="37" UseFont="false" UseTextAlignment="false" />
                </Item1>
              </Cells>
            </Item4>
            <Item5 Ref="38" ControlType="XRTableRow" Name="tableRow6" Weight="1">
              <Cells>
                <Item1 Ref="39" ControlType="XRTableCell" Name="tableCell6" Weight="1" Multiline="true" Text="tableCell6" TextAlignment="MiddleLeft">
                  <ExpressionBindings>
                    <Item1 Ref="40" Expression="[deliver_to_post_code]" PropertyName="Text" EventName="BeforePrint" />
                  </ExpressionBindings>
                  <StylePriority Ref="41" UseFont="false" UseTextAlignment="false" />
                </Item1>
              </Cells>
            </Item5>
            <Item6 Ref="42" ControlType="XRTableRow" Name="tableRow8" Weight="1">
              <Cells>
                <Item1 Ref="43" ControlType="XRTableCell" Name="tableCell8" Weight="1" Multiline="true" Text="tableCell8" TextAlignment="MiddleLeft">
                  <ExpressionBindings>
                    <Item1 Ref="44" Expression="[phone_no]" PropertyName="Text" EventName="BeforePrint" />
                  </ExpressionBindings>
                  <StylePriority Ref="45" UseFont="false" UseTextAlignment="false" />
                </Item1>
              </Cells>
            </Item6>
          </Rows>
          <StylePriority Ref="46" UseTextAlignment="false" />
        </Item3>
        <Item4 Ref="47" ControlType="XRPictureBox" Name="pictureBox1" Sizing="ZoomImage" SizeF="149.235565,100.416664" LocationFloat="0, 0">
          <ExpressionBindings>
            <Item1 Ref="48" Expression="[image_url]" PropertyName="ImageUrl" EventName="BeforePrint" />
          </ExpressionBindings>
        </Item4>
        <Item5 Ref="49" ControlType="XRTable" Name="vendorTable" TextAlignment="TopRight" SizeF="287.6791,150" LocationFloat="10.0000067, 133.541687">
          <Rows>
            <Item1 Ref="50" ControlType="XRTableRow" Name="vendorNameRow" Weight="1">
              <Cells>
                <Item1 Ref="51" ControlType="XRTableCell" Name="vendorName" Weight="1" CanShrink="true" Text="VendorName" TextAlignment="MiddleLeft">
                  <ExpressionBindings>
                    <Item1 Ref="52" Expression="[customer_name]" PropertyName="Text" EventName="BeforePrint" />
                  </ExpressionBindings>
                  <StylePriority Ref="53" UseFont="false" UsePadding="false" UseTextAlignment="false" />
                </Item1>
              </Cells>
            </Item1>
            <Item2 Ref="54" ControlType="XRTableRow" Name="vendorAddressRow" Weight="1">
              <Cells>
                <Item1 Ref="55" ControlType="XRTableCell" Name="vendorAddress" Weight="1" CanShrink="true" Text="VendorAddress" TextAlignment="MiddleLeft">
                  <ExpressionBindings>
                    <Item1 Ref="56" Expression="[bill_to_customer_address]" PropertyName="Text" EventName="BeforePrint" />
                  </ExpressionBindings>
                  <StylePriority Ref="57" UseFont="false" UseTextAlignment="false" />
                </Item1>
              </Cells>
            </Item2>
            <Item3 Ref="58" ControlType="XRTableRow" Name="vendorCityRow" Weight="1">
              <Cells>
                <Item1 Ref="59" ControlType="XRTableCell" Name="vendorCity" Weight="1" CanShrink="true" Text="VendorCity" TextAlignment="MiddleLeft">
                  <ExpressionBindings>
                    <Item1 Ref="60" Expression="[bill_to_customer_city]" PropertyName="Text" EventName="BeforePrint" />
                  </ExpressionBindings>
                  <StylePriority Ref="61" UseFont="false" UseTextAlignment="false" />
                </Item1>
              </Cells>
            </Item3>
            <Item4 Ref="62" ControlType="XRTableRow" Name="vendorCountryRow" Weight="1">
              <Cells>
                <Item1 Ref="63" ControlType="XRTableCell" Name="vendorCountry" Weight="1" CanShrink="true" Text="VendorCountry" TextAlignment="MiddleLeft">
                  <ExpressionBindings>
                    <Item1 Ref="64" Expression="[bill_to_customer_county]" PropertyName="Text" EventName="BeforePrint" />
                  </ExpressionBindings>
                  <StylePriority Ref="65" UseFont="false" UseTextAlignment="false" />
                </Item1>
              </Cells>
            </Item4>
            <Item5 Ref="66" ControlType="XRTableRow" Name="tableRow5" Weight="1">
              <Cells>
                <Item1 Ref="67" ControlType="XRTableCell" Name="tableCell5" Weight="1" Multiline="true" Text="tableCell5" TextAlignment="MiddleLeft">
                  <ExpressionBindings>
                    <Item1 Ref="68" Expression="[bill_to_customer_post_code]" PropertyName="Text" EventName="BeforePrint" />
                  </ExpressionBindings>
                  <StylePriority Ref="69" UseFont="false" UseTextAlignment="false" />
                </Item1>
              </Cells>
            </Item5>
            <Item6 Ref="70" ControlType="XRTableRow" Name="tableRow7" Weight="1">
              <Cells>
                <Item1 Ref="71" ControlType="XRTableCell" Name="tableCell7" Weight="1" Multiline="true" Text="tableCell7" TextAlignment="MiddleLeft">
                  <ExpressionBindings>
                    <Item1 Ref="72" Expression="[phone_no]" PropertyName="Text" EventName="BeforePrint" />
                  </ExpressionBindings>
                  <StylePriority Ref="73" UseFont="false" UseTextAlignment="false" />
                </Item1>
              </Cells>
            </Item6>
          </Rows>
          <StylePriority Ref="74" UseTextAlignment="false" />
        </Item5>
        <Item6 Ref="75" ControlType="XRLabel" Name="invoiceLabel" Text="Quote" TextAlignment="TopCenter" SizeF="185,50" LocationFloat="232.12471, 10.0000067" Font="Segoe UI, 26.25pt, style=Bold, charSet=0" Padding="2,2,0,0,100">
          <StylePriority Ref="76" UseFont="false" UseTextAlignment="false" />
        </Item6>
      </Controls>
      <StylePriority Ref="77" UseBackColor="false" />
    </Item4>
    <Item5 Ref="78" ControlType="GroupFooterBand" Name="GroupFooter2" GroupUnion="WithLastDetail" PrintAtBottom="true" Level="1" PageBreak="AfterBandExceptLastEntry" HeightF="86.66662" KeepTogether="true" StyleName="baseControlStyle">
      <Controls>
        <Item1 Ref="79" ControlType="XRTable" Name="summariesTable" SizeF="650.0001,56.6666336" LocationFloat="0, 29.9999866" ForeColor="255,90,86,85" BorderColor="255,203,201,194" Borders="Bottom">
          <Rows>
            <Item1 Ref="80" ControlType="XRTableRow" Name="totalCaptionRow" Weight="1">
              <Cells>
                <Item1 Ref="81" ControlType="XRTableCell" Name="totalCaption" Weight="2.3139507223619211" TextFormatString="{0:$0.00}" Text="TOTAL DUE" TextAlignment="TopRight" Font="Segoe UI, 8pt">
                  <StylePriority Ref="82" UseFont="false" UseForeColor="false" UseTextAlignment="false" />
                </Item1>
              </Cells>
            </Item1>
            <Item2 Ref="83" ControlType="XRTableRow" Name="totalRow" Weight="3.6000000584920282">
              <Cells>
                <Item1 Ref="84" ControlType="XRTableCell" Name="total" Weight="2.3139507223619211" TextFormatString="{0:$0.00}" Text="£0.00" TextAlignment="MiddleRight" Font="Segoe UI, 18pt, style=Bold" ForeColor="255,253,102,78">
                  <ExpressionBindings>
                    <Item1 Ref="85" Expression="[total_amount_including_vat]" PropertyName="Text" EventName="BeforePrint" />
                  </ExpressionBindings>
                  <StylePriority Ref="86" UseFont="false" UseForeColor="false" UseTextAlignment="false" />
                </Item1>
              </Cells>
            </Item2>
          </Rows>
          <StylePriority Ref="87" UseForeColor="false" UseBorderColor="false" UseBorders="false" />
        </Item1>
      </Controls>
    </Item5>
    <Item6 Ref="88" ControlType="GroupFooterBand" Name="GroupFooter1" HeightF="12.00001" StyleName="baseControlStyle">
      <Controls>
        <Item1 Ref="89" ControlType="XRTable" Name="subtotalTable" SizeF="650,2" LocationFloat="0, 10.00001" Font="Segoe UI, 8pt" ForeColor="255,90,86,85" Padding="2,2,5,0,100" BorderColor="255,203,201,194">
          <StylePriority Ref="90" UseFont="false" UseForeColor="false" UsePadding="false" UseBorderColor="false" />
        </Item1>
      </Controls>
    </Item6>
    <Item7 Ref="91" ControlType="GroupHeaderBand" Name="GroupHeader1" RepeatEveryPage="true" HeightF="50" StyleName="baseControlStyle">
      <GroupFields>
        <Item1 Ref="92" FieldName="name" />
      </GroupFields>
      <Controls>
        <Item1 Ref="93" ControlType="XRTable" Name="headerTable" SizeF="650,32" LocationFloat="0, 0" Font="Segoe UI, 8pt" ForeColor="255,90,86,85" Padding="2,2,5,0,100" BorderColor="255,203,201,194" Borders="Bottom">
          <Rows>
            <Item1 Ref="94" ControlType="XRTableRow" Name="headerTableRow" Weight="11.5">
              <Cells>
                <Item1 Ref="95" ControlType="XRTableCell" Name="tableCell11" Weight="1.1193313638222775" Multiline="true" Text="Code">
                  <StylePriority Ref="96" UsePadding="false" />
                </Item1>
                <Item2 Ref="97" ControlType="XRTableCell" Name="productNameCaption" Weight="1.9097737147880667" Text="DESCRIPTION">
                  <StylePriority Ref="98" UsePadding="false" />
                </Item2>
                <Item3 Ref="99" ControlType="XRTableCell" Name="tableCell12" Weight="1.2154470415881713" Multiline="true" Text="Unit of Measure&#xD;&#xA;">
                  <StylePriority Ref="100" UsePadding="false" />
                </Item3>
                <Item4 Ref="101" ControlType="XRTableCell" Name="quantityCaption" Weight="0.77234506619349985" Text="QTY" TextAlignment="TopRight">
                  <StylePriority Ref="102" UseTextAlignment="false" />
                </Item4>
                <Item5 Ref="103" ControlType="XRTableCell" Name="unitPriceCaption" Weight="0.71530405357389282" Text="PRICE" TextAlignment="TopRight">
                  <StylePriority Ref="104" UseTextAlignment="false" />
                </Item5>
                <Item6 Ref="105" ControlType="XRTableCell" Name="lineTotalCaptionCell" Weight="0.88202932143549484" Text="TOTAL" TextAlignment="TopRight">
                  <StylePriority Ref="106" UseTextAlignment="false" />
                </Item6>
              </Cells>
            </Item1>
          </Rows>
          <StylePriority Ref="107" UseFont="false" UseForeColor="false" UsePadding="false" UseBorderColor="false" UseBorders="false" />
        </Item1>
      </Controls>
    </Item7>
    <Item8 Ref="108" ControlType="DetailReportBand" Name="DetailReport" Level="0" DataMember="lines" DataSource="#Ref-0">
      <Bands>
        <Item1 Ref="109" ControlType="DetailBand" Name="Detail1" HeightF="35">
          <Controls>
            <Item1 Ref="110" ControlType="XRTable" Name="detailTable" SizeF="650,35" LocationFloat="0, 0" Font="Segoe UI, 9.75pt, style=Bold" Padding="2,2,5,0,100">
              <Rows>
                <Item1 Ref="111" ControlType="XRTableRow" Name="detailTableRow" Weight="12.343333333333334">
                  <Cells>
                    <Item1 Ref="112" ControlType="XRTableCell" Name="tableCell9" Weight="0.9743116552502108" Multiline="true" Text="tableCell9" Font="Segoe UI, 8pt, style=Bold">
                      <ExpressionBindings>
                        <Item1 Ref="113" Expression="[item_id]" PropertyName="Text" EventName="BeforePrint" />
                      </ExpressionBindings>
                      <StylePriority Ref="114" UseFont="false" UsePadding="false" />
                    </Item1>
                    <Item2 Ref="115" ControlType="XRTableCell" Name="productName" Weight="1.6623447247365994" Text="ProductName" Font="Segoe UI, 8pt, style=Bold">
                      <ExpressionBindings>
                        <Item1 Ref="116" Expression="[lines].[item_description]" PropertyName="Text" EventName="BeforePrint" />
                      </ExpressionBindings>
                      <StylePriority Ref="117" UseFont="false" UsePadding="false" />
                    </Item2>
                    <Item3 Ref="118" ControlType="XRTableCell" Name="tableCell10" Weight="1.0579747217831477" Multiline="true" Text="tableCell10" Font="Segoe UI, 8pt, style=Bold">
                      <ExpressionBindings>
                        <Item1 Ref="119" Expression="[unit_of_measure_id]" PropertyName="Text" EventName="BeforePrint" />
                      </ExpressionBindings>
                      <StylePriority Ref="120" UseFont="false" UsePadding="false" />
                    </Item3>
                    <Item4 Ref="121" ControlType="XRTableCell" Name="quantity" Weight="0.67228053336029481" Text="1" TextAlignment="TopRight" Font="Segoe UI, 8pt, style=Bold">
                      <ExpressionBindings>
                        <Item1 Ref="122" Expression="[lines].[quantity]" PropertyName="Text" EventName="BeforePrint" />
                      </ExpressionBindings>
                      <StylePriority Ref="123" UseFont="false" UsePadding="false" UseTextAlignment="false" />
                    </Item4>
                    <Item5 Ref="124" ControlType="XRTableCell" Name="unitPrice" Weight="0.62262979369495053" TextFormatString="{0:$0.00}" Text="£0.00" TextAlignment="TopRight" Font="Segoe UI, 8pt, style=Bold">
                      <ExpressionBindings>
                        <Item1 Ref="125" Expression="[lines].[unit_price]" PropertyName="Text" EventName="BeforePrint" />
                      </ExpressionBindings>
                      <StylePriority Ref="126" UseFont="false" UsePadding="false" UseTextAlignment="false" />
                    </Item5>
                    <Item6 Ref="127" ControlType="XRTableCell" Name="lineTotal" Weight="0.76775414849216328" TextFormatString="{0:$0.00}" Text="£0.00" TextAlignment="TopRight" Font="Segoe UI, 8pt, style=Bold" ForeColor="255,253,102,78">
                      <ExpressionBindings>
                        <Item1 Ref="128" Expression="[lines].[item_total]" PropertyName="Text" EventName="BeforePrint" />
                      </ExpressionBindings>
                      <StylePriority Ref="129" UseFont="false" UseForeColor="false" UsePadding="false" UseTextAlignment="false" />
                    </Item6>
                  </Cells>
                </Item1>
              </Rows>
              <StylePriority Ref="130" UseFont="false" UsePadding="false" />
            </Item1>
          </Controls>
        </Item1>
      </Bands>
    </Item8>
  </Bands>
  <StyleSheet>
    <Item1 Ref="131" Name="baseControlStyle" BorderStyle="Inset" Padding="2,2,0,0,100" Font="Segoe UI, 9.75pt" StringFormat="Near;Near;0;None;Character;Default" />
    <Item2 Ref="132" Name="Style1" BorderStyle="Inset" StringFormat="Near;Near;0;None;Character;Default" />
  </StyleSheet>
</XtraReportsLayoutSerializer>

0 个答案:

没有答案