IXpsFixedDocumentReader.Uri Property

Definition

Gets the uniform resource identifier (URI) of the FixedDocument.

C#
public Uri Uri { get; }

Property Value

Uri

A Uri that represents the URI for the document.

Examples

The following example shows how to use the Uri property.

C#
// --------------------- IterateXpsPackageParts() ---------------------
/// <summary>
///   Iterates through the parts contained in a given XpsDocument
///   package initializing a tree view control with the name of each
///   part contained within the package.</summary>
/// <param name="xpsDocument">
///   The XPS document to extract the part names from.</param>
/// <param name="treeView">
///   The TreeView control to insert the part names into.</param>
/// <param name="fileName">
///   The XPS document filename.</param>
public void IterateXpsPackageParts(
    XpsDocument xpsDocument, TreeView treeView, string fileName)
{
    // Set up the Tree View
    treeView.Items.Clear();
    treeView.Visibility      = Visibility.Visible;
    TreeViewItem packageNode = new TreeViewItem();
    packageNode.ToolTip      = fileName;
    packageNode.Header       = System.IO.Path.GetFileName(fileName);
    treeView.Items.Add(packageNode);

    // Start with a DoucmentSequence.
    IXpsFixedDocumentSequenceReader docSeq =
        xpsDocument.FixedDocumentSequenceReader;
    TreeViewItem docSeqNode = AddUriToTreeView(packageNode, docSeq.Uri);

    // For every FixedDocument within the DocumentSequence.
    foreach (IXpsFixedDocumentReader docReader in docSeq.FixedDocuments)
    {
        TreeViewItem docNode = AddUriToTreeView(docSeqNode, docReader.Uri);

        // For every FixedPage within the FixedDocument.
        foreach (IXpsFixedPageReader page in docReader.FixedPages)
        {
            TreeViewItem pageNode = AddUriToTreeView(docNode, docReader.Uri);

            // For every Image on the page.
            foreach (XpsImage image in page.Images)
            {
                AddUriToTreeView(pageNode, image.Uri);
            }

            // For every Font on the page.
            foreach (XpsFont font in page.Fonts)
            {
                AddUriToTreeView(pageNode, font.Uri);
            }
        }
    }
}// end:IterateXpsPackageParts()

Applies to

Produkt Versiounen
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10