printer
printer copied to clipboard
pdf文档打印
如何打印pdf文档
如何打印pdf文档
I do not know.
Alex
Reference: https://docs.microsoft.com/zh-cn/windows/win32/printdocs/writeprinter#remarks
如何打印pdf文档
如果没有编程语言限制,可以参考一下这个链接 https://zhuanlan.zhihu.com/p/494279624
使用python作为“胶水” (1测试未成功,2测试成功) 1.调用windows自带的cmd命令-->print, 2.调用第三方exe,如PDFtoPrinter.exe
使用python的pywin32包的win32print模块 (看起来可行,未实际测试) https://www.cnblogs.com/cfld/p/16159080.html
Just pass the binary data of pdf to the write method, works fine on my printer "Mi All-in-One Laser Printer K200 [0984]".
package main
import (
"fmt"
"os"
"strings"
"github.com/alexbrainman/printer"
)
func main() {
printers, _ := printer.ReadNames()
for _, name := range printers {
fmt.Println(name)
if strings.Contains(name, "K200") {
p, _ := printer.Open(name)
p.StartRawDocument("Test")
dat, _ := os.ReadFile("./download.pdf")
p.Write(dat)
p.EndDocument()
p.Close()
}
}
}