首页 文章

使用CUPS和热敏打印机打印postscript文档

提问于
浏览
2

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

我的问题:当我打印图像(使用附言文档)时,它会浪费大量纸张,因为图像使用大约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 . 然后我尝试添加另一个100毫米而不是297毫米的配置,但问题仍然存在 .

我也尝试将标签%% 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

任何的想法?

2 回答

  • 1

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

  • 0

    我必须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
    

    但是打印机不打印,并且作业在杯子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是默认选项 .

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

相关问题