Documentation ¶
Overview ¶
Package printers Windows printing.
Index ¶
- Constants
- func AddCustomPaperSize(printerName, paperName string, widthMM, heightMM, leftMM, topMM uint32) (err error)
- func AddForm(h syscall.Handle, level uint32, form *FORM_INFO_1) (err error)
- func ClosePrinter(h syscall.Handle) (err error)
- func DeleteCustomPaperSize(printerName, paperName string) (err error)
- func DeleteForm(h syscall.Handle, pFormName *uint16) (err error)
- func DocumentProperties(hWnd uint32, h syscall.Handle, pDeviceName *uint16, devModeOut *DevMode, ...) (err error)
- func EndDocPrinter(h syscall.Handle) (err error)
- func EndPagePrinter(h syscall.Handle) (err error)
- func EnumForms(h syscall.Handle, level uint32, pForm *byte, cbBuf uint32, pcbNeeded *uint32, ...) (err error)
- func EnumJobs(h syscall.Handle, firstJob uint32, noJobs uint32, level uint32, buf *byte, ...) (err error)
- func EnumPrinterDrivers(pName *uint16, env *uint16, level uint32, pDriverInfo *byte, cbBuf uint32, ...) (err error)
- func EnumPrinters(flags uint32, name *uint16, level uint32, buf *byte, bufN uint32, ...) (err error)
- func GetDefault() (printer string, err error)
- func GetDefaultPrinter(buf *uint16, bufN *uint32) (err error)
- func GetPrinter(h syscall.Handle, level uint32, buf *byte, bufN uint32, needed *uint32) (err error)
- func GetPrinterDriver(h syscall.Handle, env *uint16, level uint32, di *byte, n uint32, ...) (err error)
- func OpenPrinter(name *uint16, h *syscall.Handle, defaults *PrinterDefaults) (err error)
- func ReadNames() ([]string, error)
- func SetDefault(printer string) (err error)
- func SetDefaultPrinter(name *uint16) (err error)
- func SetPrinter(h syscall.Handle, level uint32, buf *byte, command uint32) (err error)
- func StartDocPrinter(h syscall.Handle, level uint32, docInfo *DOC_INFO_1) (err error)
- func StartPagePrinter(h syscall.Handle) (err error)
- func WritePrinter(h syscall.Handle, buf *byte, bufN uint32, written *uint32) (err error)
- type DOC_INFO_1
- type DRIVER_INFO_8
- type DevMode
- func (dm *DevMode) ClearPaperLength()
- func (dm *DevMode) ClearPaperSize()
- func (dm *DevMode) ClearPaperWidth()
- func (dm *DevMode) GetCollate() (int16, bool)
- func (dm *DevMode) GetColor() (int16, bool)
- func (dm *DevMode) GetCopies() (int16, bool)
- func (dm *DevMode) GetDeviceName() string
- func (dm *DevMode) GetDuplex() (int16, bool)
- func (dm *DevMode) GetOrientation() (int16, bool)
- func (dm *DevMode) GetPaperLength() (int16, bool)
- func (dm *DevMode) GetPaperSize() (int16, bool)
- func (dm *DevMode) GetPaperWidth() (int16, bool)
- func (dm *DevMode) SetCollate(collate int16)
- func (dm *DevMode) SetColor(color int16)
- func (dm *DevMode) SetCopies(copies int16)
- func (dm *DevMode) SetDuplex(duplex int16)
- func (dm *DevMode) SetOrientation(orientation int16)
- func (dm *DevMode) SetPaperLength(length int16)
- func (dm *DevMode) SetPaperSize(paperSize int16)
- func (dm *DevMode) SetPaperWidth(width int16)
- func (dm *DevMode) String() string
- type DriverInfo
- type FORM_INFO_1
- type FORM_INFO_2
- type FormInfo
- type FormInfo2
- type JOB_INFO_1
- type JobInfo
- type PRINTER_INFO_2
- type PRINTER_INFO_5
- type PRINTER_INFO_9
- type Printer
- func (p *Printer) Close() error
- func (p *Printer) DocumentPropertiesGet(deviceName string) (devMode *DevMode, err error)
- func (p *Printer) DocumentPropertiesSet(deviceName string, devMode *DevMode) (err error)
- func (p *Printer) DriverInfo() (*DriverInfo, error)
- func (p *Printer) EndDocument() error
- func (p *Printer) EndPage() error
- func (p *Printer) EnumDriverInfo() (drivers []DriverInfo, err error)
- func (p *Printer) Forms() (forms []FormInfo, err error)
- func (p *Printer) Forms2() (forms []FormInfo2, err error)
- func (p *Printer) GetDataType() (dataType string, err error)
- func (p *Printer) GetPrinter2() (printerInfo *PRINTER_INFO_2, err error)
- func (p *Printer) GetPrinter9() (printerInfo *PRINTER_INFO_9, err error)
- func (p *Printer) Jobs() ([]JobInfo, error)
- func (p *Printer) SetPrinter2(printerInfo *PRINTER_INFO_2) (err error)
- func (p *Printer) SetPrinter9(printerInfo *PRINTER_INFO_9) (err error)
- func (p *Printer) StartDocument(name, datatype string) error
- func (p *Printer) StartPage() error
- func (p *Printer) StartRawDocument(name string) error
- func (p *Printer) Write(b []byte) (int, error)
- type PrinterDefaults
- type Rect
- type SIZE
Constants ¶
const ( CCHDEVICENAME = 32 CCHFORMNAME = 32 DM_SPECVERSION uint16 = 0x00000401 DM_COPY uint32 = 2 DM_MODIFY uint32 = 8 DM_ORIENTATION uint32 = 0x00000001 DM_PAPERSIZE uint32 = 0x00000002 DM_PAPERLENGTH uint32 = 0x00000004 DM_PAPERWIDTH uint32 = 0x00000008 DM_SCALE uint32 = 0x00000010 DM_POSITION uint32 = 0x00000020 DM_NUP uint32 = 0x00000040 DM_DISPLAYORIENTATION uint32 = 0x00000080 DM_COPIES uint32 = 0x00000100 DM_DEFAULTSOURCE uint32 = 0x00000200 DM_PRINTQUALITY uint32 = 0x00000400 DM_COLOR uint32 = 0x00000800 DM_DUPLEX uint32 = 0x00001000 DM_YRESOLUTION uint32 = 0x00002000 DM_TTOPTION uint32 = 0x00004000 DM_COLLATE uint32 = 0x00008000 DM_FORMNAME uint32 = 0x00010000 DM_LOGPIXELS uint32 = 0x00020000 DM_BITSPERPEL uint32 = 0x00040000 DM_PELSWIDTH uint32 = 0x00080000 DM_PELSHEIGHT uint32 = 0x00100000 DM_DISPLAYFLAGS uint32 = 0x00200000 DM_DISPLAYFREQUENCY uint32 = 0x00400000 DM_ICMMETHOD uint32 = 0x00800000 DM_ICMINTENT uint32 = 0x01000000 DM_MEDIATYPE uint32 = 0x02000000 DM_DITHERTYPE uint32 = 0x04000000 DM_PANNINGWIDTH uint32 = 0x08000000 DM_PANNINGHEIGHT uint32 = 0x10000000 DM_DISPLAYFIXEDOUTPUT uint32 = 0x20000000 DMORIENT_PORTRAIT int16 = 1 DMORIENT_LANDSCAPE int16 = 2 DMCOLOR_MONOCHROME int16 = 1 DMCOLOR_COLOR int16 = 2 DMDUP_SIMPLEX int16 = 1 DMDUP_VERTICAL int16 = 2 DMDUP_HORIZONTAL int16 = 3 DMCOLLATE_FALSE int16 = 0 DMCOLLATE_TRUE int16 = 1 DMNUP_SYSTEM uint32 = 1 DMNUP_ONEUP uint32 = 2 )
const ( PRINTER_ENUM_LOCAL = 2 PRINTER_ENUM_CONNECTIONS = 4 PRINTER_DRIVER_XPS = 0x00000002 )
const ( JOB_STATUS_PAUSED = 0x00000001 // Job is paused JOB_STATUS_ERROR = 0x00000002 // An error is associated with the job JOB_STATUS_DELETING = 0x00000004 // Job is being deleted JOB_STATUS_SPOOLING = 0x00000008 // Job is spooling JOB_STATUS_PRINTING = 0x00000010 // Job is printing JOB_STATUS_OFFLINE = 0x00000020 // Printer is offline JOB_STATUS_PAPEROUT = 0x00000040 // Printer is out of paper JOB_STATUS_PRINTED = 0x00000080 // Job has printed JOB_STATUS_DELETED = 0x00000100 // Job has been deleted JOB_STATUS_BLOCKED_DEVQ = 0x00000200 // Printer driver cannot print the job JOB_STATUS_USER_INTERVENTION = 0x00000400 // User action required JOB_STATUS_RESTART = 0x00000800 // Job has been restarted JOB_STATUS_COMPLETE = 0x00001000 // Job has been delivered to the printer JOB_STATUS_RETAINED = 0x00002000 // Job has been retained in the print queue JOB_STATUS_RENDERING_LOCALLY = 0x00004000 // Job rendering locally on the client )
Variables ¶
This section is empty.
Functions ¶
func AddCustomPaperSize ¶
func AddCustomPaperSize(printerName, paperName string, widthMM, heightMM, leftMM, topMM uint32) (err error)
AddCustomPaperSize 添加自定义纸张规格
Reference C# code ¶
- https://www.cnblogs.com/datacool/p/datacool_windowsapi_printerhelper.html - https://github.com/vanloc0301/ecouponsprinter/blob/master/ECouponsPrinter/ECouponsPrinter/Printer.cs
func ClosePrinter ¶
func DeleteCustomPaperSize ¶
DeleteCustomPaperSize 删除自定义纸张规格
func DocumentProperties ¶
func EndDocPrinter ¶
func EndPagePrinter ¶
func EnumPrinterDrivers ¶ added in v0.1.6
func EnumPrinters ¶
func GetDefaultPrinter ¶
func GetPrinter ¶
func GetPrinterDriver ¶
func OpenPrinter ¶
func OpenPrinter(name *uint16, h *syscall.Handle, defaults *PrinterDefaults) (err error)
func SetDefaultPrinter ¶
func SetPrinter ¶
func StartDocPrinter ¶
func StartDocPrinter(h syscall.Handle, level uint32, docInfo *DOC_INFO_1) (err error)
func StartPagePrinter ¶
Types ¶
type DOC_INFO_1 ¶
type DRIVER_INFO_8 ¶
type DRIVER_INFO_8 struct { /* DWORD cVersion; LPTSTR pName; LPTSTR pEnvironment; LPTSTR pDriverPath; LPTSTR pDataFile; LPTSTR pConfigFile; LPTSTR pHelpFile; LPTSTR pDependentFiles; LPTSTR pMonitorName; LPTSTR pDefaultDataType; LPTSTR pszzPreviousNames; FILETIME ftDriverDate; DWORDLONG dwlDriverVersion; LPTSTR pszMfgName; LPTSTR pszOEMUrl; LPTSTR pszHardwareID; LPTSTR pszProvider; LPTSTR pszPrintProcessor; LPTSTR pszVendorSetup; LPTSTR pszzColorProfiles; LPTSTR pszInfPath; DWORD dwPrinterDriverAttributes; LPTSTR pszzCoreDriverDependencies; FILETIME ftMinInboxDriverVerDate; DWORDLONG dwlMinInboxDriverVerVersion; */ Version uint32 Name *uint16 Environment *uint16 DriverPath *uint16 DataFile *uint16 ConfigFile *uint16 HelpFile *uint16 DependentFiles *uint16 MonitorName *uint16 DefaultDataType *uint16 PreviousNames *uint16 DriverDate windows.Filetime DriverVersion uint64 MfgName *uint16 OEMUrl *uint16 HardwareID *uint16 Provider *uint16 PrintProcessor *uint16 VendorSetup *uint16 ColorProfiles *uint16 InfPath *uint16 PrinterDriverAttributes uint32 CoreDriverDependencies *uint16 MinInboxDriverVerDate windows.Filetime MinInboxDriverVerVersion uint32 }
type DevMode ¶
type DevMode struct {
// contains filtered or unexported fields
}
DevMode struct.
func (*DevMode) ClearPaperLength ¶
func (dm *DevMode) ClearPaperLength()
func (*DevMode) ClearPaperSize ¶
func (dm *DevMode) ClearPaperSize()
func (*DevMode) ClearPaperWidth ¶
func (dm *DevMode) ClearPaperWidth()
func (*DevMode) GetCollate ¶
func (*DevMode) GetDeviceName ¶
func (*DevMode) GetOrientation ¶
func (*DevMode) GetPaperLength ¶
func (*DevMode) GetPaperSize ¶
func (*DevMode) GetPaperWidth ¶
func (*DevMode) SetCollate ¶
func (*DevMode) SetOrientation ¶
func (*DevMode) SetPaperLength ¶
func (*DevMode) SetPaperSize ¶
func (*DevMode) SetPaperWidth ¶
type DriverInfo ¶
DriverInfo stores information about printer driver.
type FORM_INFO_1 ¶
type FORM_INFO_2 ¶
type FORM_INFO_2 struct { /* DWORD Flags; LPTSTR pName; SIZEL Size; RECTL ImageableArea; LPCSTR pKeyword; DWORD StringType; LPCTSTR pMuiDll; DWORD dwResourceId; LPCTSTR pDisplayName; LANGID wLangId; */ Flags uint32 Size SIZE ImageableArea Rect StringType uint32 // contains filtered or unexported fields }
type FormInfo2 ¶
type FormInfo2 struct { Flags uint32 Name string Size SIZE ImageableArea Rect PKeyword string StringType uint32 PMuiDll string DwResourceId uint32 PDisplayName string WLangId uint16 }
FormInfo2 stores information about a print form.
type JOB_INFO_1 ¶
type JOB_INFO_1 struct { /* DWORD JobId; LPTSTR pPrinterName; LPTSTR pMachineName; LPTSTR pUserName; LPTSTR pDocument; LPTSTR pDatatype; LPTSTR pStatus; DWORD Status; DWORD Priority; DWORD Position; DWORD TotalPages; DWORD PagesPrinted; SYSTEMTIME Submitted; */ JobID uint32 PrinterName *uint16 MachineName *uint16 UserName *uint16 Document *uint16 DataType *uint16 Status *uint16 StatusCode uint32 Priority uint32 Position uint32 TotalPages uint32 PagesPrinted uint32 Submitted windows.Systemtime }
type JobInfo ¶
type JobInfo struct { JobID uint32 UserMachineName string UserName string DocumentName string DataType string Status string StatusCode uint32 Priority uint32 Position uint32 TotalPages uint32 PagesPrinted uint32 Submitted time.Time }
JobInfo stores information about a print job.
type PRINTER_INFO_2 ¶
type PRINTER_INFO_2 struct {
// contains filtered or unexported fields
}
func (*PRINTER_INFO_2) GetDataType ¶
func (pi *PRINTER_INFO_2) GetDataType() string
type PRINTER_INFO_5 ¶
type PRINTER_INFO_9 ¶
type PRINTER_INFO_9 struct {
// contains filtered or unexported fields
}
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
func OpenWithDefaults ¶
func OpenWithDefaults(name string, defaults *PrinterDefaults) (*Printer, error)
func (*Printer) DocumentPropertiesGet ¶
func (*Printer) DocumentPropertiesSet ¶
func (*Printer) DriverInfo ¶
func (p *Printer) DriverInfo() (*DriverInfo, error)
DriverInfo returns information about printer p driver.
func (*Printer) EndDocument ¶
func (*Printer) EnumDriverInfo ¶ added in v0.1.6
func (p *Printer) EnumDriverInfo() (drivers []DriverInfo, err error)
EnumDriverInfo returns information about printer p driver.
func (*Printer) GetDataType ¶
func (*Printer) GetPrinter2 ¶
func (p *Printer) GetPrinter2() (printerInfo *PRINTER_INFO_2, err error)
GetPrinter2 get Printer Info 2
func (*Printer) GetPrinter9 ¶
func (p *Printer) GetPrinter9() (printerInfo *PRINTER_INFO_9, err error)
GetPrinter9 get Printer Info 9
func (*Printer) SetPrinter2 ¶
func (p *Printer) SetPrinter2(printerInfo *PRINTER_INFO_2) (err error)
func (*Printer) SetPrinter9 ¶
func (p *Printer) SetPrinter9(printerInfo *PRINTER_INFO_9) (err error)
func (*Printer) StartDocument ¶
func (*Printer) StartRawDocument ¶
StartRawDocument calls StartDocument and passes either "RAW" or "XPS_PASS" as a document type, depending on if printer driver is XPS-based or not.