Exemplo n.º 1
0
 public void WritePrintTicket(XpsPartBase relatedPart, PackagePart metroPart, PrintTicket printTicket)
 {
     Stream stream;
     if (relatedPart == null)
     {
         throw new ArgumentNullException("relatedPart");
     }
     if (metroPart == null)
     {
         throw new ArgumentNullException("metroPart");
     }
     if (printTicket == null)
     {
         throw new ArgumentNullException("printTicket");
     }
     Uri partUri = this.GeneratePrintTicketUri(relatedPart);
     PackagePart part = this.GeneratePart(XpsS0Markup.PrintTicketContentType, partUri);
     string uriString = MakeRelativePath(metroPart.Uri, part.Uri);
     metroPart.CreateRelationship(new Uri(uriString, UriKind.Relative), TargetMode.Internal, XpsS0Markup.PrintTicketRelationshipName);
     if (this._metroPackage.FileOpenAccess == FileAccess.Write)
     {
         stream = part.GetStream(FileMode.Create);
     }
     else
     {
         stream = part.GetStream(FileMode.OpenOrCreate);
     }
     printTicket.SaveTo(stream);
     stream.Close();
 }
Exemplo n.º 2
0
 public void WriteEmptyPrintTicket(XpsPartBase relatedPart, PackagePart metroPart)
 {
     if (relatedPart == null)
     {
         throw new ArgumentNullException("relatedPart");
     }
     if (metroPart == null)
     {
         throw new ArgumentNullException("metroPart");
     }
     if (this.Streaming)
     {
         Uri partUri = this.GeneratePrintTicketUri(relatedPart);
         PackagePart part = this.GeneratePart(XpsS0Markup.PrintTicketContentType, partUri);
         string uriString = MakeRelativePath(metroPart.Uri, part.Uri);
         metroPart.CreateRelationship(new Uri(uriString, UriKind.Relative), TargetMode.Internal, XpsS0Markup.PrintTicketRelationshipName);
         Stream outStream = part.GetStream(FileMode.Create);
         new PrintTicket().SaveTo(outStream);
         outStream.Close();
     }
 }