Partager via


IXpsFixedPageWriter Interface

Définition

Définit des méthodes pour écrire des parties FixedPage dans un document 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
Implémente

Exemples

L’exemple suivant montre comment utiliser la AddFixedPage méthode pour obtenir un writer de page fixe pour ajouter des pages à un 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

Propriétés

LinkTargetStream

Obtient une liste des chaînes qui identifient les points de lien hypertexte LinkTarget qui sont contenus dans la page active.

PageNumber

Obtient le numéro de page commençant par un de cette page.

PrintTicket

Définit les paramètres d'impression par défaut pour la page.

Uri

Obtient l’URI de la page fixe.

XmlWriter

Obtient un XmlWriter pour l’écriture de balisage XML dans la page.

Méthodes

AddColorContext()

Ajoute un nouveau XpsColorContext à la page active.

AddFont()

Ajoute un nouveau XpsFont à la page active.

AddFont(Boolean)

Ajoute un XpsFont obscurcie à la page active.

AddFont(Boolean, Boolean)

Ajoute un XpsFont obscurcie ou restreinte à la page active.

AddImage(String)

Ajoute un nouveau XpsImage avec un type MIME spécifié à la page active.

AddImage(XpsImageType)

Ajoute un XpsImage avec un XpsImageType spécifié à la page active.

AddResource(Type, Uri)

Ajoute un nouveau XpsResource à la page active.

AddResourceDictionary()

Ajoute un XpsResourceDictionary à la page.

AddStoryFragment()

Ajoute un StoryFragments élément à un package XPS.

(Hérité de IStoryFragmentProvider)
AddThumbnail(XpsImageType)

Ajoute une image miniature d'un XpsImageType spécifié à la page active.

Commit()

Vide et ferme le writer de page fixe.

S’applique à

Voir aussi