5

为Linux安装虚拟PDF打印机

 3 years ago
source link: https://www.lujun9972.win/blog/2020/04/11/%E4%B8%BAlinux%E5%AE%89%E8%A3%85%E8%99%9A%E6%8B%9Fpdf%E6%89%93%E5%8D%B0%E6%9C%BA/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

为Linux安装虚拟PDF打印机

今天发现一个 CUPS-PDF 项目,可以为 CUPS(Common Unix Printing System) 添加 PDF 打印机.

步骤非常简单:

  1. 安装 CPUS-PDF

    sudo apt install -y cups-pdf
    
  2. 根据 CPUS-PDF的文档说明, 需要设置 cups-pdf 的所有者为 root,且权限为 0700

    sudo chown root:root /usr/lib/cups/backend/cups-pdf
    sudo chmod 0700 /usr/lib/cups/backend/cups-pdf
    
  3. 重启CUPS服务

    sudo systemctl restart cups.service
    
  4. 可以通过修改 /etc/cups/cups-pdf.confOUT 参数来设置pdf的输出位置

    ### Key: Out (config)                                                        
    ##  CUPS-PDF output directory                                                
    ##  special qualifiers:                                                      
    ##     ${HOME} will be expanded to the user's home directory                 
    ##     ${USER} will be expanded to the user name                             
    ##  in case it is an NFS export make sure it is exported without             
    ##  root_squash!                                                             
    ##  on Ubuntu, the cupsd AppArmor profile needs to be updated                
    ##  to match the output path as per instructions in LP:147551                
    ### Default: /var/spool/cups-pdf/${USER}                                     
    
    Out ${HOME}/PDF                                                              
    
  5. 然后在CUPS的admin页面中就能看到一个PDF打印机了

    screenshot-73.png

    或者用 lpstat 来查看:

    lpstat -p -d
    
    printer PDF is idle.  enabled since Sat 11 Apr 2020 09:52:10 PM HKT
    system default destination: PDF
    
  6. 使用 lpr 打印一个文件试试

    lp ~/dead.letter
    
    request id is PDF-5 (1 file(s))
    
    ls ~/PDF
    
    dead.letter__2_PDF-job_5.pdf
    
  7. 最后要注意的是,根据 README 的说明,客户端选择打印机时,供应商应该选择 Postscript, model选择 Color Printer

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK