IXpsFixedPageWriter 接口

定义

定义用于将 FixedPage 部件写入 XPS 文档的方法。

public interface class IXpsFixedPageWriter : System::Windows::Xps::Packaging::IStoryFragmentProvider
public interface IXpsFixedPageWriter : System.Windows.Xps.Packaging.IStoryFragmentProvider
type IXpsFixedPageWriter = interface
    interface IStoryFragmentProvider
Public Interface IXpsFixedPageWriter
Implements IStoryFragmentProvider
实现

示例

以下示例演示如何使用 AddFixedPage 方法获取用于将页面添加到 的 XpsDocument固定页编写器。

// ------------------------- AddDocumentContent ---------------------------
/// <summary>
///   Adds a predefined set of content to a given document writer.</summary>
/// <param name="fixedDocumentWriter">
///   The document writer to add the content to.</param>
void AddDocumentContent (IXpsFixedDocumentWriter^ fixedDocumentWriter)
{
   // Collection of image and font resources used on the current page.
   //   Key: "XpsImage", "XpsFont"
   //   Value: List of XpsImage or XpsFont resources
   Dictionary<System::String^,List<XpsResource^>^>^ resources;

   try
   {
      // Add Page 1 to current document.
      IXpsFixedPageWriter^ fixedPageWriter = fixedDocumentWriter->AddFixedPage();
      // Add the resources for Page 1 and get the resource collection.
      resources = AddPageResources(fixedPageWriter);

      // Write page content for Page 1.
      WritePageContent(fixedPageWriter->XmlWriter, "Page 1 of " + fixedDocumentWriter->Uri->ToString(), resources);
      // Commit Page 1.
      fixedPageWriter->Commit();

      // Add Page 2 to current document.
      fixedPageWriter = fixedDocumentWriter->AddFixedPage();

      // Add the resources for Page 2 and get the resource collection.
      resources = AddPageResources(fixedPageWriter);

      // Write page content to Page 2.
      WritePageContent(fixedPageWriter->XmlWriter, "Page 2 of " + fixedDocumentWriter->Uri->ToString(), resources);
      // Commit Page 2.
      fixedPageWriter->Commit();
   } catch (XpsPackagingException^ xpsException)
   {
      throw xpsException;

   }
};// end:AddDocumentContent()
// ------------------------- AddDocumentContent ---------------------------
/// <summary>
///   Adds a predefined set of content to a given document writer.</summary>
/// <param name="fixedDocumentWriter">
///   The document writer to add the content to.</param>
private void AddDocumentContent(IXpsFixedDocumentWriter fixedDocumentWriter)
{
    // Collection of image and font resources used on the current page.
    //   Key: "XpsImage", "XpsFont"
    //   Value: List of XpsImage or XpsFont resources
    Dictionary<string, List<XpsResource>> resources;

    try
    {
        // Add Page 1 to current document.
        IXpsFixedPageWriter fixedPageWriter =
            fixedDocumentWriter.AddFixedPage();

        // Add the resources for Page 1 and get the resource collection.
        resources = AddPageResources(fixedPageWriter);

        // Write page content for Page 1.
        WritePageContent(fixedPageWriter.XmlWriter,
            "Page 1 of " + fixedDocumentWriter.Uri.ToString(), resources);

        // Commit Page 1.
        fixedPageWriter.Commit();

        // Add Page 2 to current document.
        fixedPageWriter = fixedDocumentWriter.AddFixedPage();

        // Add the resources for Page 2 and get the resource collection.
        resources = AddPageResources(fixedPageWriter);

        // Write page content to Page 2.
        WritePageContent(fixedPageWriter.XmlWriter,
            "Page 2 of " + fixedDocumentWriter.Uri.ToString(), resources);

        // Commit Page 2.
        fixedPageWriter.Commit();
    }
    catch (XpsPackagingException xpsException)
    {
        throw xpsException;
    }
}// end:AddDocumentContent()
' ------------------------- AddDocumentContent ---------------------------
''' <summary>
'''   Adds a predefined set of content to a given document writer.</summary>
''' <param name="fixedDocumentWriter">
'''   The document writer to add the content to.</param>
Private Sub AddDocumentContent(ByVal fixedDocumentWriter As IXpsFixedDocumentWriter)
    ' Collection of image and font resources used on the current page.
    '   Key: "XpsImage", "XpsFont"
    '   Value: List of XpsImage or XpsFont resources
    Dim resources As Dictionary(Of String, List(Of XpsResource))

    Try
        ' Add Page 1 to current document.
        Dim fixedPageWriter As IXpsFixedPageWriter = fixedDocumentWriter.AddFixedPage()

        ' Add the resources for Page 1 and get the resource collection.
        resources = AddPageResources(fixedPageWriter)

        ' Write page content for Page 1.
        WritePageContent(fixedPageWriter.XmlWriter, "Page 1 of " & fixedDocumentWriter.Uri.ToString(), resources)

        ' Commit Page 1.
        fixedPageWriter.Commit()

        ' Add Page 2 to current document.
        fixedPageWriter = fixedDocumentWriter.AddFixedPage()

        ' Add the resources for Page 2 and get the resource collection.
        resources = AddPageResources(fixedPageWriter)

        ' Write page content to Page 2.
        WritePageContent(fixedPageWriter.XmlWriter, "Page 2 of " & fixedDocumentWriter.Uri.ToString(), resources)

        ' Commit Page 2.
        fixedPageWriter.Commit()
    Catch xpsException As XpsPackagingException
        Throw xpsException
    End Try
End Sub

属性

LinkTargetStream

获取一个字符串列表,这些字符串标识当前页中包含的 LinkTarget 超链接点。

PageNumber

获取此页的页码(从零开始)。

PrintTicket

设置页的默认打印选项。

Uri

获取固定页的 URI。

XmlWriter

获取用于 XmlWriter 将 XML 标记写入页面的 。

方法

AddColorContext()

将一个新的 XpsColorContext 添加到当前页中。

AddFont()

将一个新的 XpsFont 添加到当前页中。

AddFont(Boolean)

将一个经过模糊处理的新 XpsFont 添加到当前页中。

AddFont(Boolean, Boolean)

将经过模糊处理或限制的新 XpsFont 添加到当前页中。

AddImage(String)

将具有指定 MIME 类型的新 XpsImage 添加到当前页。

AddImage(XpsImageType)

将一个具有指定 XpsImage 的新 XpsImageType 添加到当前页中。

AddResource(Type, Uri)

将一个新的 XpsResource 添加到当前页中。

AddResourceDictionary()

将一个 XpsResourceDictionary 添加到页中。

AddStoryFragment()

StoryFragments 元素添加到 XPS 包。

(继承自 IStoryFragmentProvider)
AddThumbnail(XpsImageType)

将指定 XpsImageType 的缩略图像添加到当前页中。

Commit()

刷新并关闭固定页编写器。

适用于

另请参阅