donglugou6652 2019-07-22 08:44
浏览 228

如何用golang打印?

I am trying to print on printer with go, but printer only prints strange characters ... I don't know how can I solve it.

If I print string it works, if I try print pdf on external software it works, only fail on go.

I used "github.com/jadefox10200/goprint"

printerHandle, err := goprint.GoOpenPrinter("CUSTOM K80")   
if err != nil {log("Failed to open printer")}
defer goprint.GoClosePrinter(printerHandle)

err = goprint.GoPrint(printerHandle, "hello.pdf")
if err != nil { log("during the func sendToPrinter, there was an error") }

Result:

> %PDF-1.3 3 0 obj <</Type /Page /Parent 1 0 R /Resources 2 0 R
> /Contents 4 0 R>> endobj 4 0 obj <</Filter /FlateDecode /Length 215>>
> stream
> x�ϿJ4A�|�����?�
  • 写回答

1条回答 默认 最新

  • dsfdsf21312 2019-07-22 14:26
    关注

    Possible areas to check

    • jadefox goprint package might not perform rasterisation, or at least not for your "CUSTOM K80" printer. It might therefore pass the raw file contents to the printer for it to rasterise.

    • your printer might not support PDF internally. Many mid range and higher-end laser printers do. Cheaper printers often don't. Printers that don't parse PDF may instead treat the received data as plain ASCII text.

    评论

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面