IXpsFixedPageWriter Interface

Definition

定義方法,以將 FixedPage 組件寫入至 XPS 文件。Defines methods for writing FixedPage parts to an XPS document.

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
Implements

Examples

下列範例顯示如何使用 AddFixedPage 方法來取得固定頁面寫入器,以便將頁面加入至 XpsDocumentThe following example shows how to use the AddFixedPage method to obtain a fixed-page writer for adding pages to an 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

Properties

LinkTargetStream

取得字串的清單,這些字串可識別目前頁面中包含的 LinkTarget 超連結點。Gets a list of strings that identify the LinkTarget hyperlink points that are contained in the current page.

PageNumber

取得這個頁面的以零起始的頁碼。Gets the zero-based page number of this page.

PrintTicket

設定頁面的預設列印選項。Sets the default printing options for the page.

Uri

取得固定頁面的 URI。Gets the URI of the fixed page.

XmlWriter

取得用於將 XMLXML 標記寫入至頁面的 XmlWriterGets an XmlWriter for writing XMLXML markup to the page.

Methods

AddColorContext()

將新的 XpsColorContext 加入目前頁面。Adds a new XpsColorContext to the current page.

AddFont()

將新的 XpsFont 加入目前頁面。Adds a new XpsFont to the current page.

AddFont(Boolean)

將新的模糊化 XpsFont 加入至目前頁面。Adds a new obfuscated XpsFont to the current page.

AddFont(Boolean, Boolean)

將新的模糊化或受限制的 XpsFont 加入至目前頁面。Adds a new obfuscated or restricted XpsFont to the current page.

AddImage(String)

將具有所指定 MIMEMIME 型別的新 XpsImage 加入至目前頁面。Adds a new XpsImage with a specified MIMEMIME type to the current page.

AddImage(XpsImageType)

將具有指定的 XpsImageXpsImageType 加入至目前頁面。Adds a new XpsImage with a specified XpsImageType to the current page.

AddResource(Type, Uri)

將新的 XpsResource 加入目前頁面。Adds a new XpsResource to the current page.

AddResourceDictionary()

XpsResourceDictionary 加入至頁面中。Adds a XpsResourceDictionary to the page.

AddStoryFragment()

Adds a StoryFragments element to an XPSXPS package.Adds a StoryFragments element to an XPSXPS package.

(Inherited from IStoryFragmentProvider)
AddThumbnail(XpsImageType)

將指定之 XpsImageType 的縮圖影像加入至目前頁面。Adds a thumbnail image of a specified XpsImageType to the current page.

Commit()

清除並關閉固定頁面寫入器。Flushes and closes the fixed-page writer.

Applies to

See also