IXpsFixedDocumentWriter.AddFixedPage Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Consente di aggiungere un nuovo oggetto FixedPage a FixedDocument.
public:
System::Windows::Xps::Packaging::IXpsFixedPageWriter ^ AddFixedPage();
public System.Windows.Xps.Packaging.IXpsFixedPageWriter AddFixedPage ();
abstract member AddFixedPage : unit -> System.Windows.Xps.Packaging.IXpsFixedPageWriter
Public Function AddFixedPage () As IXpsFixedPageWriter
Restituisce
Writer per l'output del nuovo oggetto FixedPage.
Esempio
Nell'esempio seguente viene illustrato come utilizzare il metodo AddFixedPage.
// ------------------------- 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