how to load one specific xps document into DocumentViewer for reading without loading it when application start

387 Views Asked by At

I only made a button to add a document. Is it possible to somehow load a document from a folder with a Visual Studio project or something else?

private void Load_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "XPS file (*.xps)|*.xps";

            if (ofd.ShowDialog() == true)
            {
                XpsDocument doc = new XpsDocument(ofd.FileName, FileAccess.Read);
                documentViewer.Document = doc.GetFixedDocumentSequence();
            }
        }
1

There are 1 best solutions below

0
frik On
private void Book1_Click(object sender, RoutedEventArgs e)
{
 var xpsDocument = new XpsDocument(@"C:documentPath", FileAccess.Read);
 documentViewer.Document = xpsDocument.GetFixedDocumentSequence();
}