XpsResource.Commit 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.
Esegue il commit di tutte le modifiche e scarica la risorsa nel pacchetto del documento.
public:
void Commit();
public void Commit ();
member this.Commit : unit -> unit
Public Sub Commit ()
Esempio
Nell'esempio seguente viene illustrato come usare il Commit metodo (in una classe derivata) quando si aggiungono risorse a un XpsDocumentoggetto .
// -------------------------- AddPageResources ----------------------------
Dictionary<System::String^,List<XpsResource^>^>^ AddPageResources (IXpsFixedPageWriter^ fixedPageWriter)
{
// Collection of all resources for this page.
// Key: "XpsImage", "XpsFont"
// Value: List of XpsImage or XpsFont
Dictionary<System::String^,List<XpsResource^>^>^ resources = gcnew Dictionary<System::String^,List<XpsResource^>^>();
// Collections of images and fonts used in the current page.
List<XpsResource^>^ xpsImages = gcnew List<XpsResource^>();
List<XpsResource^>^ xpsFonts = gcnew List<XpsResource^>();
try
{
XpsImage^ xpsImage;
XpsFont^ xpsFont;
// Add, Write, and Commit image1 to the current page.
xpsImage = fixedPageWriter->AddImage(XpsImageType::JpegImageType);
WriteToStream(xpsImage->GetStream(), image1);
xpsImage->Commit();
xpsImages->Add(xpsImage); // Add image1 as a required resource.
// Add, Write, and Commit font 1 to the current page.
xpsFont = fixedPageWriter->AddFont();
WriteObfuscatedStream(xpsFont->Uri->ToString(), xpsFont->GetStream(), font1);
xpsFont->Commit();
xpsFonts->Add(xpsFont); // Add font1 as a required resource.
// Add, Write, and Commit image2 to the current page.
xpsImage = fixedPageWriter->AddImage(XpsImageType::TiffImageType);
WriteToStream(xpsImage->GetStream(), image2);
xpsImage->Commit();
xpsImages->Add(xpsImage); // Add image2 as a required resource.
// Add, Write, and Commit font2 to the current page.
xpsFont = fixedPageWriter->AddFont(false);
WriteToStream(xpsFont->GetStream(), font2);
xpsFont->Commit();
xpsFonts->Add(xpsFont); // Add font2 as a required resource.
// Return the image and font resources in a combined collection.
resources->Add("XpsImage", xpsImages);
resources->Add("XpsFont", xpsFonts);
return resources;
} catch (XpsPackagingException^ xpsException)
{
throw xpsException;
}
};// end:AddPageResources()
// -------------------------- AddPageResources ----------------------------
private Dictionary<string, List<XpsResource>>
AddPageResources(IXpsFixedPageWriter fixedPageWriter)
{
// Collection of all resources for this page.
// Key: "XpsImage", "XpsFont"
// Value: List of XpsImage or XpsFont
Dictionary<string, List<XpsResource>> resources =
new Dictionary<string, List<XpsResource>>();
// Collections of images and fonts used in the current page.
List<XpsResource> xpsImages = new List<XpsResource>();
List<XpsResource> xpsFonts = new List<XpsResource>();
try
{
XpsImage xpsImage;
XpsFont xpsFont;
// Add, Write, and Commit image1 to the current page.
xpsImage = fixedPageWriter.AddImage(XpsImageType.JpegImageType);
WriteToStream(xpsImage.GetStream(), image1);
xpsImage.Commit();
xpsImages.Add(xpsImage); // Add image1 as a required resource.
// Add, Write, and Commit font 1 to the current page.
xpsFont = fixedPageWriter.AddFont();
WriteObfuscatedStream(
xpsFont.Uri.ToString(), xpsFont.GetStream(), font1);
xpsFont.Commit();
xpsFonts.Add(xpsFont); // Add font1 as a required resource.
// Add, Write, and Commit image2 to the current page.
xpsImage = fixedPageWriter.AddImage(XpsImageType.TiffImageType);
WriteToStream(xpsImage.GetStream(), image2);
xpsImage.Commit();
xpsImages.Add(xpsImage); // Add image2 as a required resource.
// Add, Write, and Commit font2 to the current page.
xpsFont = fixedPageWriter.AddFont(false);
WriteToStream(xpsFont.GetStream(), font2);
xpsFont.Commit();
xpsFonts.Add(xpsFont); // Add font2 as a required resource.
// Return the image and font resources in a combined collection.
resources.Add("XpsImage", xpsImages);
resources.Add("XpsFont", xpsFonts);
return resources;
}
catch (XpsPackagingException xpsException)
{
throw xpsException;
}
}// end:AddPageResources()
' -------------------------- AddPageResources ----------------------------
Private Function AddPageResources(ByVal fixedPageWriter As IXpsFixedPageWriter) As Dictionary(Of String, List(Of XpsResource))
' Collection of all resources for this page.
' Key: "XpsImage", "XpsFont"
' Value: List of XpsImage or XpsFont
Dim resources As New Dictionary(Of String, List(Of XpsResource))()
' Collections of images and fonts used in the current page.
Dim xpsImages As New List(Of XpsResource)()
Dim xpsFonts As New List(Of XpsResource)()
Try
Dim xpsImage As XpsImage
Dim xpsFont As XpsFont
' Add, Write, and Commit image1 to the current page.
xpsImage = fixedPageWriter.AddImage(XpsImageType.JpegImageType)
WriteToStream(xpsImage.GetStream(), image1)
xpsImage.Commit()
xpsImages.Add(xpsImage) ' Add image1 as a required resource.
' Add, Write, and Commit font 1 to the current page.
xpsFont = fixedPageWriter.AddFont()
WriteObfuscatedStream(xpsFont.Uri.ToString(), xpsFont.GetStream(), font1)
xpsFont.Commit()
xpsFonts.Add(xpsFont) ' Add font1 as a required resource.
' Add, Write, and Commit image2 to the current page.
xpsImage = fixedPageWriter.AddImage(XpsImageType.TiffImageType)
WriteToStream(xpsImage.GetStream(), image2)
xpsImage.Commit()
xpsImages.Add(xpsImage) ' Add image2 as a required resource.
' Add, Write, and Commit font2 to the current page.
xpsFont = fixedPageWriter.AddFont(False)
WriteToStream(xpsFont.GetStream(), font2)
xpsFont.Commit()
xpsFonts.Add(xpsFont) ' Add font2 as a required resource.
' Return the image and font resources in a combined collection.
resources.Add("XpsImage", xpsImages)
resources.Add("XpsFont", xpsFonts)
Return resources
Catch xpsException As XpsPackagingException
Throw xpsException
End Try
End Function ' end:AddPageResources()
Commenti
In base alle impostazioni di XpsSerializationManager e , ad FontSubsetterCommitPolicies esempio e PackageInterleavingOrderXpsPackagingPolicy, l'operazione di scaricamento del Commit metodo può essere ritardata fino a quando l'intero XpsDocument non viene chiuso.