internal static byte[] InternalConvertPrintTicketToDevMode(PTProviderBase provider, PrintTicket printTicket, BaseDevModeType baseType, PrintTicketScope scope) { // Input PrinTicket can't be null. if (printTicket == null) { throw new ArgumentNullException(nameof(printTicket)); } // Validate the base type value. if ((baseType != BaseDevModeType.UserDefault) && (baseType != BaseDevModeType.PrinterDefault)) { throw new ArgumentOutOfRangeException(nameof(baseType)); } // Validate scope value. if ((scope != PrintTicketScope.PageScope) && (scope != PrintTicketScope.DocumentScope) && (scope != PrintTicketScope.JobScope)) { throw new ArgumentOutOfRangeException(nameof(scope)); } MemoryStream ptStream = printTicket.GetXmlStream(); return(provider.ConvertPrintTicketToDevMode(ptStream, baseType, scope)); }
/// <summary> /// Constructs a new PrintTicketManager instance for the given device. /// </summary> /// <param name="deviceName">Name of printer device the PrintTicketManager instance should be bound to.</param> /// <param name="clientPrintSchemaVersion">Print Schema version requested by client.</param> /// <exception cref="ArgumentNullException"> /// The <paramref name="deviceName"/> parameter is null. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// The <paramref name="clientPrintSchemaVersion"/> parameter value is not greater than 0 /// or is greater than the maximum Print Schema version <see cref="MaxPrintSchemaVersion"/> /// PrintTicketManager can support. /// </exception> /// <exception cref="PrintQueueException"> /// The PrintTicketManager instance failed to bind to the printer specified by <paramref name="deviceName"/>. /// </exception> public PrintTicketManager(string deviceName, int clientPrintSchemaVersion) { // Check input argument if (deviceName == null) { throw new ArgumentNullException("deviceName"); } // Check if we can support the schema version client has requested if ((clientPrintSchemaVersion > MaxPrintSchemaVersion) || (clientPrintSchemaVersion <= 0)) { throw new ArgumentOutOfRangeException("clientPrintSchemaVersion"); } // Instantiate a new PTProvider instance. PTProvider constructor throws exception if it fails for any reason. _ptProvider = PTProviderBase.Create(deviceName, MaxPrintSchemaVersion, clientPrintSchemaVersion); }
internal static PrintTicket InternalConvertDevModeToPrintTicket(PTProviderBase provider, byte[] devMode, PrintTicketScope scope) { // validate devMode parameter if (devMode == null) { throw new ArgumentNullException(nameof(devMode)); } // validate sope parameter if ((scope != PrintTicketScope.PageScope) && (scope != PrintTicketScope.DocumentScope) && (scope != PrintTicketScope.JobScope)) { throw new ArgumentOutOfRangeException(nameof(scope)); } MemoryStream ptStream = provider.ConvertDevModeToPrintTicket(devMode, scope); return(new PrintTicket(ptStream)); }
/// <summary> /// Constructs a new PrintTicketConverter instance for the given device. /// </summary> /// <param name="deviceName">Name of printer device the PrintTicketConverter instance should be bound to.</param> /// <param name="clientPrintSchemaVersion">Print Schema version requested by client.</param> /// <exception cref="ArgumentNullException"> /// The <paramref name="deviceName"/> parameter is null. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// The <paramref name="clientPrintSchemaVersion"/> parameter value is not greater than 0 /// or is greater than the maximum Print Schema version <see cref="MaxPrintSchemaVersion"/> /// PrintTicketConverter can support. /// </exception> /// <exception cref="PrintQueueException"> /// The PrintTicketConverter instance failed to bind to the printer specified by <paramref name="deviceName"/>. /// </exception> public PrintTicketConverter(string deviceName, int clientPrintSchemaVersion) { // Check input argument if (deviceName == null) { throw new ArgumentNullException(nameof(deviceName)); } // Check if we can support the schema version client has requested if ((clientPrintSchemaVersion > MaxPrintSchemaVersion) || (clientPrintSchemaVersion <= 0)) { throw new ArgumentOutOfRangeException(nameof(clientPrintSchemaVersion)); } // Instantiate the provider object this converter instance will use. // PTProvider constructor throws exception if it fails for any reason. _ptProvider = PTProviderBase.Create(deviceName, MaxPrintSchemaVersion, clientPrintSchemaVersion); //Create Dispatcher object to insure the PrintTicketConverted is utilized from the same thread _accessVerifier = new PrintSystemDispatcherObject(); }