共用方式為


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)

將具有指定的 XpsImageXpsImageType 加入至目前頁面。

AddResource(Type, Uri)

將新的 XpsResource 加入目前頁面。

AddResourceDictionary()

XpsResourceDictionary 加入至頁面中。

AddStoryFragment()

StoryFragments將專案加入至 XPS 套件。

(繼承來源 IStoryFragmentProvider)
AddThumbnail(XpsImageType)

將指定之 XpsImageType 的縮圖影像加入至目前頁面。

Commit()

清除並關閉固定頁面寫入器。

適用於

另請參閱