Пример #1
0
        public static void DisplayPrintTicket(System.Printing.PrintTicket printTicket)
        {
            MemoryStream memStream = printTicket.GetXmlStream();
            string       xml       = Encoding.ASCII.GetString(memStream.GetBuffer(), 0, (int)memStream.Length);

            Console.WriteLine(xml);
        }
Пример #2
0
        /// <summary>
        /// Merges delta PrintTicket with base PrintTicket and then validates the merged PrintTicket.
        /// </summary>
        /// <param name="basePrintTicket">The base PrintTicket.</param>
        /// <param name="deltaPrintTicket">The delta PrintTicket.</param>
        /// <param name="scope">scope that delta PrintTicket and result PrintTicket will be limited to</param>
        /// <returns>Struct that contains PrintTicket validation result info.</returns>
        /// <remarks>
        /// The <paramref name="deltaPrintTicket"/> parameter could be null, in which case
        /// only validation will be performed on <paramref name="basePrintTicket"/>.
        /// </remarks>
        /// <exception cref="ObjectDisposedException">
        /// The PrintTicketManager instance has already been disposed.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="basePrintTicket"/> parameter is null.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// The <paramref name="scope"/> parameter is not one of the standard <see cref="PrintTicketScope"/> values.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// The base PrintTicket specified by <paramref name="basePrintTicket"/> is not well-formed,
        /// or delta PrintTicket specified by <paramref name="deltaPrintTicket"/> is not well-formed.
        /// </exception>
        /// <exception cref="PrintQueueException">
        /// The PrintTicketManager instance failed to merge and validate the input PrintTicket(s).
        /// </exception>
        public ValidationResult MergeAndValidatePrintTicket(PrintTicket basePrintTicket,
                                                            PrintTicket deltaPrintTicket,
                                                            PrintTicketScope scope)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("PrintTicketManager");
            }

            // Base PrintTicket is required. Delta PrintTicket is optional.
            if (basePrintTicket == null)
            {
                throw new ArgumentNullException("basePrintTicket");
            }

            // validate scope value
            if ((scope != PrintTicketScope.PageScope) &&
                (scope != PrintTicketScope.DocumentScope) &&
                (scope != PrintTicketScope.JobScope))
            {
                throw new ArgumentOutOfRangeException("scope");
            }

            MemoryStream   baseStream = null, deltaStream = null, resultStream = null;
            ConflictStatus status;

            baseStream = basePrintTicket.GetXmlStream();

            if (deltaPrintTicket != null)
            {
                deltaStream = deltaPrintTicket.GetXmlStream();
            }

            resultStream = _ptProvider.MergeAndValidatePrintTicket(baseStream,
                                                                   deltaStream,
                                                                   scope,
                                                                   out status);

            return(new ValidationResult(resultStream, status));
        }
Пример #3
0
        /// <summary>
        /// Gets the PrintCapabilities (in XML form) relative to the given PrintTicket.
        /// </summary>
        /// <param name="printTicket">The PrintTicket object based on which PrintCapabilities should be built.</param>
        /// <returns>MemoryStream that contains XML PrintCapabilities.</returns>
        /// <remarks>
        /// The <paramref name="printTicket"/> parameter could be null, in which case
        /// the device's default PrintTicket will be used to construct the PrintCapabilities.
        /// </remarks>
        /// <exception cref="ObjectDisposedException">
        /// The PrintTicketManager instance has already been disposed.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// The input PrintTicket specified by <paramref name="printTicket"/> is not well-formed.
        /// </exception>
        /// <exception cref="PrintQueueException">
        /// The PrintTicketManager instance failed to retrieve the PrintCapabilities.
        /// </exception>
        public MemoryStream GetPrintCapabilitiesAsXml(PrintTicket printTicket)
        {
            Toolbox.EmitEvent(EventTrace.Event.WClientDRXGetPrintCapStart);

            if (_disposed)
            {
                throw new ObjectDisposedException("PrintTicketManager");
            }

            MemoryStream ptStream = null;

            if (printTicket != null)
            {
                ptStream = printTicket.GetXmlStream();
            }

            MemoryStream pcStream = _ptProvider.GetPrintCapabilities(ptStream);

            Toolbox.EmitEvent(EventTrace.Event.WClientDRXGetPrintCapEnd);

            return(pcStream);
        }
Пример #4
0
 /// <summary>
 /// Merges delta PrintTicket with base PrintTicket and then validates the merged PrintTicket.
 /// </summary>
 /// <param name="basePrintTicket">The base PrintTicket.</param>
 /// <param name="deltaPrintTicket">The delta PrintTicket.</param>
 /// <returns>Struct that contains PrintTicket validation result info.</returns>
 /// <remarks>
 /// The <paramref name="deltaPrintTicket"/> parameter could be null, in which case
 /// only validation will be performed on <paramref name="basePrintTicket"/>.
 /// </remarks>
 /// <exception cref="ObjectDisposedException">
 /// The PrintTicketManager instance has already been disposed.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 /// The <paramref name="basePrintTicket"/> parameter is null.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// The base PrintTicket specified by <paramref name="basePrintTicket"/> is not well-formed,
 /// or delta PrintTicket specified by <paramref name="deltaPrintTicket"/> is not well-formed.
 /// </exception>
 /// <exception cref="PrintQueueException">
 /// The PrintTicketManager instance failed to merge and validate the input PrintTicket(s).
 /// </exception>
 public ValidationResult MergeAndValidatePrintTicket(PrintTicket basePrintTicket,
                                                     PrintTicket deltaPrintTicket)
 {
     return(MergeAndValidatePrintTicket(basePrintTicket, deltaPrintTicket, PrintTicketScope.JobScope));
 }