Back to Devexpress

DocumentViewerControl.DocumentSource Property

wpf-devexpress-dot-xpf-dot-documentviewer-dot-documentviewercontrol-ecd23007.md

latest8.2 KB
Original Source

DocumentViewerControl.DocumentSource Property

SECURITY-RELATED CONSIDERATIONS

Using file paths sourced from untrusted input may expose unauthorized files or allow unintended file access. Always validate and normalize all external paths to prevent path manipulation.

Specifies the document source. This is a dependency property.

Namespace : DevExpress.Xpf.DocumentViewer

Assembly : DevExpress.Xpf.DocumentViewer.v25.2.Core.dll

NuGet Package : DevExpress.Wpf.DocumentViewer.Core

Declaration

csharp
public object DocumentSource { get; set; }
vb
Public Property DocumentSource As Object

Property Value

TypeDescription
Object

A Object value that specifies the document source.

|

Remarks

The following source types are supported:

You can use the DocumentSource property to load a previously saved document from the PRNX file:

documentPreview.DocumentSource = @"...\Invoice.prnx";

To create a custom DocumentPreviewWindow, assign a document source to the DocumentSource property (available when using the DocumentPreviewWindow.PreviewControl property).

csharp
using DevExpress.Xpf.Printing;
using System.Windows;
// ...

private void Button_Click(object sender, RoutedEventArgs e) {
    XtraReport1 report = new XtraReport1();
    var window = new DocumentPreviewWindow();
    window.PreviewControl.DocumentSource = report;
    report.CreateDocument();
    window.Show();
}
vb
Imports DevExpress.Xpf.Printing
Imports System.Windows
' ...

Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
    Dim report As New XtraReport1()
    Dim window = New DocumentPreviewWindow()
    window.PreviewControl.DocumentSource = report
    report.CreateDocument()
    window.Show()
End Sub

Make sure to call the XtraReport.CreateDocument method before displaying the Print Preview.

To resolve subreport names, call ReportStorageExtension.RegisterExtensionGlobal.

The following code snippets (auto-collected from DevExpress Examples) contain references to the DocumentSource property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

reporting-wpf-mvvm-show-report-document-preview/CS/MainWindow.xaml#L17

xml
<dxp:DocumentPreviewControl RequestDocumentCreation="True"
                                DocumentSource="{Binding Report}" />
</DataTemplate>

wpf-reporting-use-custom-controls-for-editing-report-content-in-print-preview/CS/MainWindow.xaml#L26

xml
<DataTemplate>
    <dxp:DocumentPreviewControl RequestDocumentCreation="True" DocumentSource="{Binding Report, Mode=OneWay}" />
</DataTemplate>

wpf-pdf-viewer-replace-standard-command-with-custom-command/CS/MainWindow.xaml#L19

xml
<pdfViewer:PdfViewerControl x:Name="pdfViewer" DocumentSource="Demo.pdf">

reporting-wpf-mvvm-how-to-validate-editing-fields/CS/MainWindow.xaml#L13

xml
<dxp:DocumentPreviewControl RequestDocumentCreation="True"
                            DocumentSource="{Binding Report}"
                            HighlightEditingFields="True">

reporting-wpf-mvvm-viewmodel-data-to-report/CS/MainWindow.xaml#L19

xml
<dxp:DocumentPreviewControl RequestDocumentCreation="True"
                                DocumentSource="{Binding Report}" />
</DataTemplate>

reporting-wpf-hide-specific-export-formats-from-the-document-preview-control/CS/HideExportFormats/MainWindow.xaml.cs#L37

csharp
preview.DocumentSource = link;
link.CreateDocument();

reporting-wpf-print-listview-data/CS/Window1.xaml.cs#L18

csharp
DocumentPreviewWindow preview = new DocumentPreviewWindow();
preview.PreviewControl.DocumentSource = link;

wpf-pdf-viewer-draw-a-rectangle-over-a-document/CS/MainWindow.xaml.cs#L25

csharp
InitializeComponent();
    pdfView.DocumentSource = "Demo.pdf";
}

reporting-wpf-print-listview-data/VB/Window1.xaml.vb#L21

vb
Dim preview As DocumentPreviewWindow = New DocumentPreviewWindow()
preview.PreviewControl.DocumentSource = link
link.PageHeaderTemplate = CType(Resources("printHeaderTemplate"), DataTemplate)

wpf-pdf-viewer-draw-a-rectangle-over-a-document/VB/MainWindow.xaml.vb#L16

vb
Me.InitializeComponent()
    Me.pdfView.DocumentSource = "Demo.pdf"
End Sub

See Also

DocumentViewerControl Class

DocumentViewerControl Members

DevExpress.Xpf.DocumentViewer Namespace