【发布时间】:2019-11-25 02:55:54
【问题描述】:
我目前正在尝试编写一个 bash 脚本,以允许用户为需要打印的条形码(类型 C128)输入文本,然后:
- 下载带有条码图像或仅图像的网页,然后在本地打印
- 打印远程 URL 页面,将他们输入的文本作为要打印的 URL 的读取变量
特别是这个网站:
用任何文本替换 TEST1。
我尝试过使用 wget、curl、html2ps、html2ps + ps2pdf,但我遇到了源自 URL 页面基础的问题:
https://www.barcodesinc.com/generator/image.php
通过 CLI 我得到这个:
"需要条码类型ex.C39"
目的是在本地打印图片或保存后再打印。
这是我迄今为止尝试过的:
#!/bin/bash
echo -ne "Enter the ID you want to print: "
read locid
#html2ps https://www.barcodesinc.com/generator/image.php?code=LOCATION$locid&style=165&type=C128B&width=388&height=150&xres=2&font=5 | lpr
#html2ps https://www.barcodesinc.com/generator/image.php?code=LOCATION$locid&style=165&type=C128B&width=388&height=150&xres=2&font=5 | ps2pdf - /home/byron/locations/LOCATION$locid.pdf
#html2ps https://www.barcodesinc.com/generator/image.php?code=LOCATION$locid&style=165&type=C128B&width=388&height=150&xres=2&font=5 -o /home/byron/locations/LOCATION$locid.html
#ps2pdf /home/byron/locations/LOCATION$locid.html /home/byron/locations/LOCATION$locid.pdf
lpr /home/byron/locations/LOCATION$locid.pdf
当使用任何 CLI 工具时,我似乎得到一个空文件或标准输出输出。此外,打印作业会立即取消并显示“(stdin)到打印机”。
我尝试了https://unix.stackexchange.com/questions/168569/printing-webpage-using-browser-via-cli,但没有成功。
【问题讨论】: