Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdf文档打印 #22

Open
zhuqiyun opened this issue Sep 24, 2020 · 4 comments
Open

pdf文档打印 #22

zhuqiyun opened this issue Sep 24, 2020 · 4 comments

Comments

@zhuqiyun
Copy link

如何打印pdf文档

@alexbrainman
Copy link
Owner

如何打印pdf文档

I do not know.

Alex

@bajins
Copy link

bajins commented Sep 13, 2021

@YXH-YXH
Copy link

YXH-YXH commented Sep 14, 2022

如何打印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

@muzea
Copy link

muzea commented Sep 21, 2023

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()
		}

	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants