Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Load a PDF Document from a File

The following code example shows how to load a document from a file.

Important

The PDF Viewer locks a file until it is opened in the PDF Viewer. (PdfViewerControl.DetachStreamOnLoadComplete is set to false by default). This allows the PDF Viewer to render a large PDF quickly but makes it impossible to edit or delete the document until it is opened in the PDF Viewer.

If you want to unlock the file after a document is loaded into the PDF Viewer, set the PdfViewerControl.DetachStreamOnLoadComplete property to true. However, in this case the high rendering performance is not guaranteed.

Use the DocumentViewerControl.DocumentSource to load a document in XAML:

<!--Load document from a file-->
<dxpdf:PdfViewerControl x:Name="pdfViewer"
                        ShowStartScreen="True"
                        DocumentSource="..\\..\\Demo.pdf"/>

The PdfViewerControl.OpenDocument method allows you to load a document from a file in code:

pdfViewer.OpenDocument("..\\..\\Demo.pdf");
See Also