DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 20th December 2017
shep shep is offline
Real Name: Scott
Arp Constable
 
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,503
Default PDF/Postscript -> print filter -> Print Queue Filter

The cups-filters pkg README has instructions to use a foomatic-rip with a ppd. The instructions advise the use of a2ps, or enscript, I believe that a2ps detects postscript files and passes them on to the printer while txt files are converted to *.ps on their way to the printer. One thing I have noticed is that /etc/a2ps.cfg has entries to also generate postscript out of a pdf. For me, printing a pdf from the command line does not work with a2ps.

The FreeBSD handbook has a "Smart Filters" example that will call enscript if a postscript file is not detected: the first 4 characters of a postscript file are
Quote:
%!PS"
The first 4 characters of a pdf file are
Quote:
%PDF
so I thought the Smart Filter could be expanded to detect a pdf and filter it through pdftops print/poppler. I modified the script provided by W. Block to detect pdf files and hopefully convert to postscript.

The last piece of this is that I predominately use 2 print queues: lp: simplex letter and duplex: duplex letter. Both queues work when I use evince/xpdf/gv/pdftops but I get an "undefined command h operand stack" printed out with the following:
/usr/local/libexec/print_filter
Code:
#!/bin/sh
#
#  print_filter - Print PostScript, PDF or plain text on a PostScript printer
#
IFS="" read -r first_line
first_four_chars=`expr "$first_line" : '\(....\)'`

case "$first_four_chars" in
%!PS)
    echo "$first_line" && cat && exit 0
    exit 2
    ;;
%PDF)
    ( echo "$first_line"; cat ) | /usr/local/bin/pdftops - | && exit 0
    exit 2
    ;;
*)
    ( echo "$first_line"; cat ) | /usr/local/bin/enscript -o - && exit 0
    exit 2
    ;;
esac
/usr/local/libexec/br_script_duplex
Code:
#!/bin/sh

/usr/local/libexec/print_filter | \
 /usr/local/bin/foomatic-rip --ppd \
 /etc/foomatic/direct/Brother-HL-5450DN_BR-Script3-Postscript-Brother-en.ppd \
 -o PageSize=Letter -o Duplex=DuplexNoTumble
My older pcl5e printer would detect *ps, *pdf and *txt with a ghostscript filter. What is the best way to pipe the output from print_filter -> queue filter? Is it acceptable to use scripts sequentially? I could create pdf/pdf-duplex and txt print queues but it seems less elegant.

Last edited by shep; 21st December 2017 at 12:08 AM.
Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ultp? libusb? cups - Can't print npmaier FreeBSD General 2 13th October 2012 04:12 AM
echo and print ? sharris FreeBSD General 1 4th September 2011 06:25 AM
Windows scripts can't print drhowarddrfine Other OS 15 31st March 2009 08:53 AM
Can't Print (Fresh First Time install) BSD newb Xero FreeBSD Installation and Upgrading 4 15th February 2009 07:11 PM
Print on remote WinXP from web host drhowarddrfine General software and network 5 13th October 2008 05:41 PM


All times are GMT. The time now is 12:37 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick