Hi,
I set a report with .xsd file as schema of table. and I insert an OLE object with graphic location to load an image.
Here comes the strange thing. Image does not show when I set the data source and export pdf file, every filed shows correctly but image. However, Image shows if I don't set data source and export pdf.
below is how I set the datasource:
void SetXmlDataSource(ReportDocument report)
{
if(!Utils.CheckFileExists(_configuration.Schema))
{
throw new Exception($"File {_configuration.Schema} does not exist");
}
if(!Utils.CheckFileExists(_commandLine))
{
throw new Exception($"File {_commandLine} does not exist");
}
var ds = new DataSet();
ds.ReadXmlSchema(_configuration.Schema);
ds.ReadXml(_commandLine);
report.SetDataSource(ds);
}<br>
Language: C# (.net4.5)
OS Platform: Windows Server 2016 (x64)
SDK: SP32
Crystal Reports Version: Crystal Report 2020
Request clarification before answering.
It has always been this way, if you insert an image into a report CR will only load the image when the Report is opened or loaded in an application.
The solution R&D came up with is to use a database field that points to the location of the image. It could be a field in the DB or a file located on the Harddrive.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your kindly reply. Here I want to put some screen shots to make my problem more clear.
1. choose a .xsd file as database ADO.NET(XML)
<?xml version="1.0" standalone="yes"?>
<xs:schema id="data"
xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="data" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="docid">
<xs:complexType>
<xs:sequence>
<xs:element name="RptDate" type="xs:string" minOccurs="0" msdata:Ordinal="0" />
<xs:element name="PolNo" type="xs:string" minOccurs="0" msdata:Ordinal="1" />
<xs:element name="PolicyName" type="xs:string" minOccurs="0" msdata:Ordinal="2" />
<xs:element name="NextAnni" type="xs:string" minOccurs="0" msdata:Ordinal="3" />
<xs:element name="Address1" type="xs:string" minOccurs="0" msdata:Ordinal="4" />
<xs:element name="Address2" type="xs:string" minOccurs="0" msdata:Ordinal="5" />
<xs:element name="Address3" type="xs:string" minOccurs="0" msdata:Ordinal="6" />
<xs:element name="Address4" type="xs:string" minOccurs="0" msdata:Ordinal="7" />
<xs:element name="State" type="xs:string" minOccurs="0" msdata:Ordinal="8" />
<xs:element name="CONTPERSON" type="xs:string" minOccurs="0" msdata:Ordinal="9" />
<xs:element name="AgentName" type="xs:string" minOccurs="0" msdata:Ordinal="10" />
<xs:element name="AGYNAME" type="xs:string" minOccurs="0" msdata:Ordinal="11" />
<xs:element name="CommDisclsInd" type="xs:string" minOccurs="0" msdata:Ordinal="12" />
<xs:element name="company_code" type="xs:integer" minOccurs="0" msdata:Ordinal="13" />
<xs:element name="company_short_name_e" type="xs:string" minOccurs="0" msdata:Ordinal="14" />
<xs:element name="company_short_name_c" type="xs:string" minOccurs="0" msdata:Ordinal="15" />
<xs:element name="company_full_name_e" type="xs:string" minOccurs="0" msdata:Ordinal="16" />
<xs:element name="company_full_name_c" type="xs:string" minOccurs="0" msdata:Ordinal="17" />
<xs:element name="fax_number" type="xs:string" minOccurs="0" msdata:Ordinal="18" />
<xs:element name="csc_phone" type="xs:string" minOccurs="0" msdata:Ordinal="19" />
<xs:element name="print_date" type="xs:string" minOccurs="0" msdata:Ordinal="20" />
<xs:element name="logo" type="xs:string" minOccurs="0" msdata:Ordinal="21" />
</xs:sequence>
<xs:attribute name="letterdoc">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="GRNV005R01|GRNV005R02|GRNV005R03|GRNV005R04"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>3.I set a report as below

2.preview in designer. As you can see, hard code graphic location image shows correctly
3. call method SetXmlDataSource to load xsd file and xml file.
<data>
<docid letterdoc="GRNV005R01">
<RptDate>08/12/2022 10:24:50</RptDate>
<PolNo>0000012345</PolNo>
<PolicyName>Howard & Ping</PolicyName>
<NextAnni>09/30/2022 00:00:00</NextAnni>
<Address1>SUITE AA</Address1>
<Address2>CMA BUILDING</Address2>
<Address3>20 CONNAUGHT ROAD CENTRAL</Address3>
<Address4></Address4>
<State>HONG KONG</State>
<CONTPERSON>MS. ELIZABETH LAW</CONTPERSON>
<AgentName></AgentName>
<AGYNAME></AGYNAME>
<CommDisclsInd>N</CommDisclsInd>
<company_code>41</company_code>
<company_short_name_e>Apple</company_short_name_e>
<company_short_name_c>Apple</company_short_name_c>
<company_full_name_e>Apple</company_full_name_e>
<company_full_name_c>苹果</company_full_name_c>
<fax_number>1234 9011</fax_number>
<csc_phone>2234 9999</csc_phone>
<print_date>08/11/2022 00:00:00</print_date>
<logo>.\Header_Portrait_Logo.bmp</logo>
</docid>
</data>
4. call ExportToDisk method to export pdf ( you can see both image are blank and logo field has correct value)

5. exe application and report and image are all in debug folder.
Plase help me, thank you
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.