爲Linux安裝虛擬PDF打印機

原文地址:https://lujun9972.github.io/blog/2020/04/11/爲linux安裝虛擬pdf打印機/index.html

今天發現一個 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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章