Esempio n. 1
0
        public Printer(string name, string DocName = "RAW DOCUMENT")
        {
            if (string.IsNullOrEmpty(DocName))
            {
                throw new TinySatoArgumentException($"The document name is empty. name:{name}, DocName:{DocName}");
            }

            this.ConnectionType = ConnectionType.Driver;
            this.Barcode        = new Barcode(this);
            this.Graphic        = new Graphic(this);

            if (!UnsafeNativeMethods.OpenPrinter(name, out printer, IntPtr.Zero))
            {
                throw new TinySatoPrinterNotFoundException($"The printer not found. name:{name}",
                                                           new Win32Exception(Marshal.GetLastWin32Error()));
            }
            const int level = 1; // for not win98
            var       di    = new DOCINFO()
            {
                pDataType = "raw", pDocName = DocName
            };

            if (!UnsafeNativeMethods.StartDocPrinter(printer, level, di))
            {
                throw new TinySatoIOException($"Failed to use printer. name:{name}",
                                              new Win32Exception(Marshal.GetLastWin32Error()));
            }

            this.status = new JobStatus(ConnectionType.Driver);
        }
Esempio n. 2
0
 internal static extern bool StartDocPrinter(IntPtr hPrinter, Int32 level, [In, MarshalAs(UnmanagedType.LPStruct)] DOCINFO di);