cups之socket方式打印bmp

5 篇文章 0 订阅
4 篇文章 1 订阅

如题,以bmp打印为例,简述如下,

1.  cups启动MIME type所需的filter,并根据URI(连接打印机形式)启动backend。

log如下

D [31/Oct/2018:10:43:30 +0800] [Job 15] envp[29]="FINAL_CONTENT_TYPE=application/vnd.cups-pdf"
D [31/Oct/2018:10:43:30 +0800] [Job 15] envp[30]="AUTH_I****"
I [31/Oct/2018:10:43:30 +0800] [Job 15] Started filter /usr/lib/cups/filter/imagetopdf (PID 3985)
I [31/Oct/2018:10:43:30 +0800] [Job 15] Started filter /usr/lib/cups/filter/foomatic-rip (PID 3986)
I [31/Oct/2018:10:43:30 +0800] [Job 15] Started backend /usr/lib/cups/backend/socket (PID 3987)

2. cupsd有两种方式告知 imagetopdf待打印文件信息:1) pipe;2)argv。imagetopdf根据参数个数判别:argc == 6时,为pipe,从stdin读入,并保存为temp文件;argc == 7时,从argv[6]获知文件名。

3. imagetopdf通过pipe将转换成的PDF文件传输给foomatic-rip。foomatic-rip首次读取输入文件,判定类型为PDF,启动pdftops进程,并将读取并保存的ps文件作为argv传递给pdftops。

log中显示,

D [31/Oct/2018:10:43:31 +0800] [Job 15] Starting process \"pdf-to-ps\" (generation 1)

4. pdftops处理PDF文件做了如下事情,

   a) 根据 cups option:pdftops-renderer,选择render。可能是pdftops/acroread/pdftocairo/mupdftoraster/hybrid。其中,mupdftoraster需要rastertops接力处理。

   b) 根据不同render,组织argv,建立pipe,运行进程。根据需要建立pipe,运行rastertops。

   c) 运行pstops。

过程log,

D [31/Oct/2018:10:43:31 +0800] [Job 15] Starting process \"pdf-to-ps\" (generation 1)
D [31/Oct/2018:10:43:31 +0800] [Job 15] Printer make and model: HP HP Color LaserJet
D [31/Oct/2018:10:43:31 +0800] [Job 15] Running command line for pstops: pstops 15 jzhg 1.bmp 1 \' finishings=3 number-up=1 position=bottom-left job-uuid=urn:uuid:c152e279-0129-3950-7160-5becf380d735 job-originating-host-name=localhost date-time-at-creation= date-time-at-processing= time-at-creation=1540953810 time-at-processing=1540953810 document-name-supplied=1.bmp\'
D [31/Oct/2018:10:43:31 +0800] [Job 15] Using image rendering resolution 600 dpi
D [31/Oct/2018:10:43:31 +0800] [Job 15] Running command line for gs: gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=ps2write -sOUTPUTFILE=%stdout -dLanguageLevel=3 -r600 -dCompressFonts=false -dNoT3CCITT -dNOINTERPOLATE -c \'save pop\' -f /tmp/foomatic-U033uS
D [31/Oct/2018:10:43:31 +0800] [Job 15] Started filter gs (PID 3990)
D [31/Oct/2018:10:43:31 +0800] [Job 15] Started filter pstops (PID 3991)
D [31/Oct/2018:10:43:31 +0800] [Job 15] Page = 595x842; 0,36 to 595,806
D [31/Oct/2018:10:43:31 +0800] [Job 15] slow_collate=0, slow_duplex=0, slow_order=0
D [31/Oct/2018:10:43:31 +0800] [Job 15] Before copy_comments - %!PS-Adobe-3.0
D [31/Oct/2018:10:43:31 +0800] [Job 15] %!PS-Adobe-3.0
D [31/Oct/2018:10:43:31 +0800] [Job 15] %%BoundingBox: 0 0 595 842
D [31/Oct/2018:10:43:31 +0800] [Job 15] %%HiResBoundingBox: 0 0 595.00 842.00
D [31/Oct/2018:10:43:31 +0800] [Job 15] %%Creator: GPL Ghostscript 918 (ps2write)
D [31/Oct/2018:10:43:31 +0800] [Job 15] %%LanguageLevel: 2
D [31/Oct/2018:10:43:31 +0800] [Job 15] %%CreationDate: D:20181031104331+08\'00\'
D [31/Oct/2018:10:43:31 +0800] [Job 15] %%Pages: 1
D [31/Oct/2018:10:43:31 +0800] [Job 15] %%EndComments
D [31/Oct/2018:10:43:31 +0800] [Job 15] Before copy_prolog - %%BeginProlog
D [31/Oct/2018:10:43:31 +0800] [Job 15] Filetype: PostScript
D [31/Oct/2018:10:43:31 +0800] [Job 15] Reading PostScript input ...
D [31/Oct/2018:10:43:31 +0800] [Job 15] --> This document is DSC-conforming!
D [31/Oct/2018:10:43:31 +0800] [Job 15] Found %RBINumCopies: 1
D [31/Oct/2018:10:43:31 +0800] [Job 15] -----------
D [31/Oct/2018:10:43:31 +0800] [Job 15] Found: %%BeginProlog
D [31/Oct/2018:10:43:31 +0800] [Job 15] Inserting option code into \"Prolog\" section.
D [31/Oct/2018:10:43:31 +0800] [Job 15] Before copy_setup - %%Page: 1 1
D [31/Oct/2018:10:43:31 +0800] [Job 15] Before page loop - %%Page: 1 1
D [31/Oct/2018:10:43:31 +0800] [Job 15] Copying page 1...
D [31/Oct/2018:10:43:31 +0800] [Job 15] pagew = 595.0, pagel = 770.0
D [31/Oct/2018:10:43:31 +0800] [Job 15] bboxx = 0, bboxy = 0, bboxw = 595, bboxl = 842
D [31/Oct/2018:10:43:31 +0800] [Job 15] PageLeft = 0.0, PageRight = 595.0
D [31/Oct/2018:10:43:31 +0800] [Job 15] PageTop = 806.0, PageBottom = 36.0
D [31/Oct/2018:10:43:31 +0800] [Job 15] PageWidth = 595.0, PageLength = 842.0
D [31/Oct/2018:10:43:31 +0800] [Job 15] Found: %%EndProlog
D [31/Oct/2018:10:43:31 +0800] [Job 15] -----------
D [31/Oct/2018:10:43:31 +0800] [Job 15] Found: %%BeginSetup
D [31/Oct/2018:10:43:31 +0800] [Job 15] Found: %%BeginFeature: *Resolution 600x600dpi
D [31/Oct/2018:10:43:31 +0800] [Job 15] Option: Resolution=600x600dpi
D [31/Oct/2018:10:43:31 +0800] [Job 15] --> Option will be set by PostScript interpreter
D [31/Oct/2018:10:43:31 +0800] [Job 15] Found: %%BeginFeature: *PageSize A4
D [31/Oct/2018:10:43:31 +0800] [Job 15] Option: PageSize=A4
D [31/Oct/2018:10:43:31 +0800] [Job 15] --> Option will be set by PostScript interpreter
D [31/Oct/2018:10:43:31 +0800] [Job 15] Found: %%BeginFeature: *InputSlot Default
D [31/Oct/2018:10:43:31 +0800] [Job 15] Option: InputSlot=Default
D [31/Oct/2018:10:43:31 +0800] [Job 15] --> Option will be set by PostScript interpreter
D [31/Oct/2018:10:43:31 +0800] [Job 15] Found: %%BeginFeature: *Duplex None
D [31/Oct/2018:10:43:31 +0800] [Job 15] Option: Duplex=None
D [31/Oct/2018:10:43:31 +0800] [Job 15] --> Option will be set by PostScript interpreter
D [31/Oct/2018:10:43:31 +0800] [Job 15] Found: %%EndSetup
D [31/Oct/2018:10:43:31 +0800] [Job 15] Inserting option code into \"Setup\" section.
D [31/Oct/2018:10:43:31 +0800] [Job 15] -----------
D [31/Oct/2018:10:43:31 +0800] [Job 15] New page: %%Page: 1 1
D [31/Oct/2018:10:43:31 +0800] [Job 15] Found: %%BeginPageSetup
D [31/Oct/2018:10:43:31 +0800] [Job 15] Inserting option code into \"PageSetup\" section.
D [31/Oct/2018:10:43:31 +0800] [Job 15] Wrote 1 pages...
D [31/Oct/2018:10:43:31 +0800] [Job 15] PID 3990 (gs) exited with no errors.
D [31/Oct/2018:10:43:31 +0800] [Job 15] PID 3991 (pstops) exited with no errors.

5. foomatic-rip再次从stdin监控pdftops输出的文件流,此次判定为ps文件。从pdftops接收到ps后,开启渲染。

D [31/Oct/2018:10:43:31 +0800] [Job 15] Starting renderer with command: \"cat\"
D [31/Oct/2018:10:43:31 +0800] [Job 15] Starting process \"kid3\" (generation 1)
D [31/Oct/2018:10:43:31 +0800] [Job 15] Starting process \"kid4\" (generation 2)
D [31/Oct/2018:10:43:31 +0800] [Job 15] Starting process \"renderer\" (generation 2)

6. 最终渲染后的数据被发送给backend,由后者通过kernel driver发给打印机。

疑问:

1.  cups option:pdftops-renderer从何而来

2. cupsd/foomatic-rip/socket三者pipe通信方式。

3. imagetopdf运行时已经获知了用户设置的纸张类型。此参数可以通过lp -o media=A5传递。这个参数是如何传递给imagetopdf的?

另外,应该学会参考help doc。比如lp -o各选项,可以参考cups/doc/help/options.html。各种选项,应有尽有。

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值