【问题标题】:Print a postscript document with CUPS and a thermal printer使用 CUPS 和热敏打印机打印 postscript 文档
【发布时间】:2012-09-09 01:15:03
【问题描述】:

我在 Ubuntu 12.04 中安装了一个 epson TM-T20,使用的是官方的driver。这是热敏打印机,我用的是 80mm 的纸。

我的问题:当我打印图像(使用 postscript 文档)时,会浪费大量纸张,因为图像使用大约 5 厘米,而打印机在图像之前发出 25 厘米的白纸。

我使用以下命令将文档发送到打印机:

lpr -P tm-t20 -o document.ps

打印机打印图像(200x200 图像),但首先会发出大量未打印的纸张。

CUPS 无法识别打印机(使用 localhost:631 的 Web 界面)。然后我使用以下过程安装它:

sudo lpadmin -p tm-t20 -E -v serial:/dev/ttyUSB0 -P /usr/share/ppd/epson-tm-t20-rastertotmt.ppd 

然后打印机出现在 CUPS Web 界面中,我对其进行了配置(波特率、位奇偶校验等)。

当我发送一些文本时,打印机工作正常。

这是打印机 ppd 的一部分:

*DefaultPageRegion:RP80x297
*PageRegion RP80x297/Roll Paper 80 x 297 mm: "<</PageSize[204 841.8]/           ImagingBBox null>>setpagedevice"
*PageRegion RP58x297/Roll Paper 58 x 297 mm: "<</PageSize[141.7 841.8]/         ImagingBBox null>>setpagedevice"
*CloseUI: *PageRegion

*DefaultImageableArea: RP80x297
*ImageableArea RP80x297/Roll Paper 80 x 297 mm: "0 0 204 841.8"
*ImageableArea RP58x297/Roll Paper 58 x 297 mm: "0 0 141.7 841.8"

*DefaultPaperDimension: RP80x297
*PaperDimension RP80x297/Roll Paper 80 x 297 mm: "204 841.8"
*PaperDimension RP58x297/Roll Paper 58 x 297 mm: "141.7 841.8"

我想这种浪费纸张是因为 ppd 文件中出现了 297mm 的长度。然后我尝试添加另一个100mm而不是297mm的配置,但问题仍然存在。

我也尝试将标签 %%DocumentMedia 添加到 ps 文件,但同样的问题:

%!PS-Adobe-3.0
%%Creator: GIMP PostScript file plugin V 1.17 by Peter Kirchgessner
%%Title: yay.ps
%%CreationDate: Thu Sep 13 13:44:26 2012
%%DocumentData: Clean7Bit
%%LanguageLevel: 2
%%Pages: 1
%%BoundingBox: 14 14 215 215
%%
%%EndComments
%%DocumentMedia: Plain 72 72 0 white Plain 
%%BeginProlog
% Use own dictionary to avoid conflicts
10 dict begin
%%EndProlog
%%Page: 1 1
% Translate for offset
14.173228346456694 14.173228346456694 translate
% Translate to begin of first scanline
0 199.99999999999997 translate
199.99999999999997 -199.99999999999997 scale
% Image geometry
200 200 8
% Transformation matrix
[ 200 0 0 200 0 0 ]
% Strings to hold RGB-samples per scanline
/rstr 200 string def
/gstr 200 string def
/bstr 200 string def
{currentfile /ASCII85Decode filter /RunLengthDecode filter rstr readstring pop}
{currentfile /ASCII85Decode filter /RunLengthDecode filter gstr readstring pop}
{currentfile /ASCII85Decode filter /RunLengthDecode filter bstr readstring pop}
true 3
%%BeginData:        14759 ASCII Bytes

有什么想法吗?

【问题讨论】:

    标签: epson thermal-printer cups


    【解决方案1】:

    终于在经历了很多痛苦之后。我发现问题出在串行到 USB 电缆上(为了将串行打印机连接到 USB 端口)。我尝试使用两种不同的串行到 USB 电缆,但问题仍然存在,最后我得出结论,如果未连接到“真实”串行端口,打印机工作不正常。我在具有串行端口的 PC 上在相同条件下测试了打印机,它运行良好,只需安装 epson 提供的驱动程序并将 chmod 777 提供给 /dev/ttyS0。在作业列表中,有时我会看到错误:“/usr/lib/cups/filter/pstopdf failed”。但是打印机打印正常,就像没有发生错误一样。

    【讨论】:

      【解决方案2】:

      我必须 chmod 777 /dev/ttyUSB0 才能使打印机正常工作(即使使用 sudo 运行命令)。

      使用 media=B8 选项,我得到了可接受的结果(文本不在中心)

      lp -d tm-t20 -o media=B8 document.ps
      

      我也试过

        lp -d tm-t20 -o media=Custom.80x90mm document.ps
      

      但打印机不打印,并且作业在 cups Web 界面上显示为已完成。

      如果我尝试

      lp -d tm-t20 -o media=Custom.200x190 document.ps
      

      打印机打印(未正确居中,我想我需要尝试使用不同的值,直到获得所需的结果)。以点为单位的纸张尺寸在本站:http://paulbourke.net/dataformats/postscript/

      打印机不切纸,我不知道如何提供该选项(打印并切纸)。

      打印机接受的选项有:

      lpoptions -p tm-t20 -l
      
      PageSize/Media Size: *RP80x297 RP58x297 Custom.WIDTHxHEIGHT
      Resolution/Resolution: *203x203dpi
      TmtSpeed/Printing Speed: *Auto 1 2 3 4
      TmtPaperReduction/Paper Reduction: Off Top *Bottom Both
      TmtPaperSource/Paper Source: *DocFeedCut DocFeedNoCut DocNoFeedCut DocNoFeedNoCut PageFeedCut PageFeedNoCut PageNoFeedCut
      TmtBuzzerControl/Buzzer: *Off Before After
      TmtSoundPattern/Sound Pattern: *A B C D E
      TmtBuzzerRepeat/Buzzer Repeat: *1 2 3 5
      TmtDrawer1/Cash Drawer #1: *Off Before After
      

      如何让打印机打印切纸?我需要从控制台执行此操作,才能从自定义 C++ 程序中使用它。如果您对Linux下的此类打印机有任何其他经验,请给我一些建议。我的目标是使用 C++ 程序中的打印机,我没有找到快速的方法(直接向打印机发送 ESC/POS 命令,在 Linux 下没有官方文档可以做到),所以我我从控制台使用 CUPS。

      剪纸已解决:

      lp -d tm-t20 -o media=Custom.200x258 -o source=DocFeedCut document.ps
      

      我不知道它为什么起作用,因为如选项中所示,DocFeedCut 是默认选项。

      现在我将尝试将文本正确居中。

      【讨论】:

      • 打印机停止工作,现在有时打印,有时不打印。我将发布更多详细信息...
      • 您不需要chmod 777,首先尝试将您的用户帐户添加到拥有设备文件的组并注销并重新登录。
      猜你喜欢
      • 2019-08-15
      • 2013-12-03
      • 2012-10-05
      • 2016-05-05
      • 2012-01-21
      • 2019-12-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多