XRPdfContent.SourceUrl Property
Specifies the PDF document to be rendered in the report. Use a local file system path or URL to reference a document.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v20.1.dll
NuGet Packages: DevExpress.Reporting.Core, DevExpress.WindowsDesktop.Reporting.Core
Declaration
[DefaultValue("")]
[SRCategory(ReportStringId.CatData)]
public string SourceUrl { get; set; }
Property Value
Type | Default | Description |
---|---|---|
String | String.Empty | The URL or path to a PDF document that should be rendered in the report. |
Remarks
When users save the report, the URL or path specified in the SourceUrl property persists in the report definition file. The PDF file should be available at the specified location when a report is printed or rendered in a Document Viewer.
You can use expressions to conditionally specify the SourceUrl property value or bind it to a report parameters or data source field. Add an item to the XRPdfContent.ExpressionBindings collection to set an expression.
Use the Source property instead of SourceUrl to include PDF content in a report.
Tip
The SourceUrl property value takes precedence over the Source value. If you specify both properties, the XRPdfContent includes the content specified by SourceUrl. However, if the file specified in the SourceUrl property cannot be loaded, the binary data from the Source property is used.
Examples
The code below creates an XRPdfContent control, adds it to a report’s Detail band, and sets the control’s SourceUrl property to the path to a PDF document.
using System.IO;
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.Expressions;
// ...
// Create a report with a Detail band and Landscape page orientation.
XtraReport report = new XtraReport(){
Landscape = true,
Bands = {
new DetailBand() {
Name = "DetailBand",
HeightF = 25,
}
}
};
// Create an XRPdfContent class instance.
XRPdfContent pdfContent = new XRPdfContent();
// The PDF content is loaded from the MasterDetailReport.pdf file.
pdfContent.SourceUrl = Path.Combine(Path.GetDirectoryName(typeof(ReportCreator).Assembly.Location), "MasterDetailReport.pdf");
// Add the XRPdfContent class instance to the report's Detail band.
report.Bands[BandKind.Detail].Controls.Add(pdfContent);
The code below creates an XRPdfContent control and uses an expression to bind the control’s SourceUrl property to the report’s PdfParameter parameter.
using System.IO;
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.Expressions;
// ...
// Create a report with a Detail band and Landscape page orientation.
// The "PdfParameter" report parameter specifies a PDF file's location.
XtraReport report = new XtraReport(){
Landscape = true,
Parameters = {
new DevExpress.XtraReports.Parameters.Parameter() {
Name = "PdfParameter",
Type = typeof(string),
Value = Path.Combine(Path.GetDirectoryName(typeof(ReportCreator).Assembly.Location), "MasterDetailReport.pdf"),
Visible = true
},
},
Bands = {
new DetailBand() {
Name = "DetailBand",
HeightF = 25,
}
}
};
// Create an XRPdfContent class instance.
XRPdfContent pdfContent = new XRPdfContent();
// Create an expression that binds the XRPdfContent's SourceUrl property to the report's "PdfParameter" parameter.
pdfContent.ExpressionBindings.Add(new ExpressionBinding("SourceUrl", "?PdfParameter"));
// Add the XRPdfContent class instance to the report's Detail band.
report.Bands[BandKind.Detail].Controls.Add(pdfContent);