Back to Devexpress

How to: Load a PDF Document from a File

wpf-400981-controls-and-libraries-pdf-viewer-examples-file-operations-how-to-load-a-pdf-document-from-a-file.md

latest1.8 KB
Original Source

How to: Load a PDF Document from a File

  • May 16, 2019

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:

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:

csharp
pdfViewer.OpenDocument("..\\..\\Demo.pdf");
vb
pdfViewer.OpenDocument("..\..\Demo.pdf");

See Also

How to: Load a PDF Document from a Stream

How to: Load a PDF Document from a Uri