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

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 answer

  • answered 2022-01-23 12:12 nosferatu zodd

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

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum