XRPdfContent.Source Property
Specifies the source PDF document in the binary data format. The control renders the specified document in the report.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v20.1.dll
NuGet Packages: DevExpress.Reporting.Core, DevExpress.WindowsDesktop.Reporting.Core
Declaration
Property Value
Type | Default | Description |
---|---|---|
Byte[] | *null* | The source PDF document in the binary data format. |
Remarks
When users save the report, the Source property value persists in the report definition file.
You can use expressions to conditionally specify the Source property value or bind it to a report parameter or data source field. Add an ExpressionBinding item to the XRPdfContent.ExpressionBindings collection to set an expression.
Use the SourceUrl property instead of Source to provide a URL or path to a PDF file.
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 sample below creates an XRPdfContent control, adds it to a report’s Detail band, and sets the control’s Source property to binary PDF data from a file.
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();
// Obtain the binary PDF data and assign it to the XRPdfContent's Source property.
pdfContent.Source = System.IO.File.ReadAllBytes("MasterDetailReport.pdf");
// Assign the XRPdfContent class instance to the report's Detail band.
report.Bands[BandKind.Detail].Controls.Add(pdfContent);
The code sample below creates an XRPdfContent control and uses an expression to bind the control’s Source property to the PdfData data source field.
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();
// Create an expression that binds the XRPdfContent's Source property to the data source's "PdfData" field.
pdfContent.ExpressionBindings.Add(new ExpressionBinding("Source", "[PdfData]"));
// Assign the XRPdfContent class instance to the report's Detail band.
report.Bands[BandKind.Detail].Controls.Add(pdfContent);