PDFWriter does not work anymore

After upgrading to Sequioa (maybe in previous upgrade), printing to the PDFWriter from any application will create an empty file in the corresponding output folder (normally PdfWriter).

MacBook Pro 14″, macOS 15.3

Posted on Jan 29, 2025 7:49 AM

Reply
Question marked as Top-ranking reply

Posted on Jan 30, 2025 1:29 AM

Since I still need this driver to work, I've managed to enable something that would suffice.


1 - Enable file device in CUPS URI

CUPS doesn't allow the file protocol by default. Enable it by editing '/etc/cups/cups-file.conf':

FileDevice Yes


2 - Create a file backend

Check available backends:

% lpinfo -v


If the line 'file file' is missing, create the backend:

% sudo nano /usr/libexec/cups/backend/file


Write:

#!/bin/zsh
echo "file file \"PDFDriver\" \"Print to pdf file\""


Make it executable:

% chmod ugo+x /usr/libexec/cups/backend/file


Verify with:

% 'lpinfo -v'


If the 'file' backend is not included, check that the '/usr/libexec/cups/backend/file' runs from the terminal and produces the expected output. Verify that the step 1 is properly completed. Restart CUPS service or the computer.


3 - Add a new printer

Enable the web interface:

% cupsctl WebInterface=Yes


Go to: 'localhost:631/admin', log in:

  • Under the 'Administration' tab, in the 'Printers' section, select the button 'Add Printer'
  • Select 'Print to pdf file (PDFDriver)'
  • Set URI (e.g., 'file:///Users/your_user_name/PdfDriver/file.ps')
  • 'Name' the printer queue: (e.g., 'pdf_driver').
  • 'Description' (e.g., 'PdfDriver')
  • Choose 'Generic PostScript Printer (en)'


4 - Prepare the output folder

% mkdir ${HOME}/PdfDriver
% chmod ugo+w ${HOME}/PdfDriver


5 - Install Postscript to PDF converter

Install Ghostscript (includes ps2pdf converter):


% brew install ghostscript


6 - Create a shell script for Conversion

Create '${HOME}/pdf-driver.sh':

#!/bin/zsh

# Folder to monitor
WATCH_DIR="$HOME/PdfDriver"

# File to process
TARGET_FILE="$WATCH_DIR/file.ps"

# Output file name
OUTPUT_FILE="$WATCH_DIR/output-$(date +%Y%m%d%H%M%S).pdf"

# Check if the target file exists
if [ -f "$TARGET_FILE" ]; then
    # Convert the file using ps2pdf (requires sudo)
    sudo /opt/homebrew/bin/ps2pdf "$TARGET_FILE" "$OUTPUT_FILE"
    
    # Delete the original .ps file
    sudo rm "$TARGET_FILE"
    
    echo "Processed and deleted: $TARGET_FILE"
else
    echo "Target file not found: $TARGET_FILE"
fi


Make it executable:

% chmod ugo+x ${HOME}/pdf-driver.sh


Note that the script points to '/opt/homebrew/bin/ps2pdf' as the conversion program to be used, change it according to the command of your preference.


Grant execution without password by editing the '/etc/sudoers' file with 'sudo visudo':


your_user_name ALL = (ALL) NOPASSWD: /Users/your_user_name/pdf-driver.sh


7 - Create an Automator folder action to trigger the shell script.

  • Open Automator, create a 'Folder Action' workflow
  • Select 'PdfDriver' as the watched folder
  • Add a 'Run Shell Script' ('/bin/zsh'), pass input 'as arguments'. insert:
sudo /Users/federico/0-bashscripts/pdf-driver.sh
  • Save.


How it works

  • A 'file.ps' file is created by CUPS into '${HOME}/PdfDriver'
  • The script converts it to 'output-YYYYmmddHHMMSS.pdf'
  • The 'file.ps' file is deleted.


Notes

  • Restarting CUPS may reset 'FileDevice Yes'.
  • The ideal approach would be a backend handling the conversion directly, but CUPS currently does not relay jobs to the backend. The 2dir backend, for example, does not work.


Hope this helps!

6 replies
Question marked as Top-ranking reply

Jan 30, 2025 1:29 AM in response to falcantara

Since I still need this driver to work, I've managed to enable something that would suffice.


1 - Enable file device in CUPS URI

CUPS doesn't allow the file protocol by default. Enable it by editing '/etc/cups/cups-file.conf':

FileDevice Yes


2 - Create a file backend

Check available backends:

% lpinfo -v


If the line 'file file' is missing, create the backend:

% sudo nano /usr/libexec/cups/backend/file


Write:

#!/bin/zsh
echo "file file \"PDFDriver\" \"Print to pdf file\""


Make it executable:

% chmod ugo+x /usr/libexec/cups/backend/file


Verify with:

% 'lpinfo -v'


If the 'file' backend is not included, check that the '/usr/libexec/cups/backend/file' runs from the terminal and produces the expected output. Verify that the step 1 is properly completed. Restart CUPS service or the computer.


3 - Add a new printer

Enable the web interface:

% cupsctl WebInterface=Yes


Go to: 'localhost:631/admin', log in:

  • Under the 'Administration' tab, in the 'Printers' section, select the button 'Add Printer'
  • Select 'Print to pdf file (PDFDriver)'
  • Set URI (e.g., 'file:///Users/your_user_name/PdfDriver/file.ps')
  • 'Name' the printer queue: (e.g., 'pdf_driver').
  • 'Description' (e.g., 'PdfDriver')
  • Choose 'Generic PostScript Printer (en)'


4 - Prepare the output folder

% mkdir ${HOME}/PdfDriver
% chmod ugo+w ${HOME}/PdfDriver


5 - Install Postscript to PDF converter

Install Ghostscript (includes ps2pdf converter):


% brew install ghostscript


6 - Create a shell script for Conversion

Create '${HOME}/pdf-driver.sh':

#!/bin/zsh

# Folder to monitor
WATCH_DIR="$HOME/PdfDriver"

# File to process
TARGET_FILE="$WATCH_DIR/file.ps"

# Output file name
OUTPUT_FILE="$WATCH_DIR/output-$(date +%Y%m%d%H%M%S).pdf"

# Check if the target file exists
if [ -f "$TARGET_FILE" ]; then
    # Convert the file using ps2pdf (requires sudo)
    sudo /opt/homebrew/bin/ps2pdf "$TARGET_FILE" "$OUTPUT_FILE"
    
    # Delete the original .ps file
    sudo rm "$TARGET_FILE"
    
    echo "Processed and deleted: $TARGET_FILE"
else
    echo "Target file not found: $TARGET_FILE"
fi


Make it executable:

% chmod ugo+x ${HOME}/pdf-driver.sh


Note that the script points to '/opt/homebrew/bin/ps2pdf' as the conversion program to be used, change it according to the command of your preference.


Grant execution without password by editing the '/etc/sudoers' file with 'sudo visudo':


your_user_name ALL = (ALL) NOPASSWD: /Users/your_user_name/pdf-driver.sh


7 - Create an Automator folder action to trigger the shell script.

  • Open Automator, create a 'Folder Action' workflow
  • Select 'PdfDriver' as the watched folder
  • Add a 'Run Shell Script' ('/bin/zsh'), pass input 'as arguments'. insert:
sudo /Users/federico/0-bashscripts/pdf-driver.sh
  • Save.


How it works

  • A 'file.ps' file is created by CUPS into '${HOME}/PdfDriver'
  • The script converts it to 'output-YYYYmmddHHMMSS.pdf'
  • The 'file.ps' file is deleted.


Notes

  • Restarting CUPS may reset 'FileDevice Yes'.
  • The ideal approach would be a backend handling the conversion directly, but CUPS currently does not relay jobs to the backend. The 2dir backend, for example, does not work.


Hope this helps!

Jan 29, 2025 8:02 AM in response to VikingOSX

Thanks VikingOSX, as you stated, PDFWriter is a third party product. It relies on the cups ability to register custom backend.


This application seems to no longer being maintained.


I am trying to enable a PDF driver so that applications not having the Apple interface can generate a PDF.


Anyway I've found a work around, that I'll post in a reply to this question.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

PDFWriter does not work anymore

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.