Jump to content

Using CUPS backend to create PDF virtual printer


rsutherland
 Share

Recommended Posts

this was taken from some place on line however I did not get the names. Anyway It worked on MDK 9.2 and 9.1 so...

 

1. You need Linux, CUPS, and ghostscript.

 

2. Go here: http://printing.kde.org/downloads/ and download this backend

script: http://printing.kde.org/downloads/pdfdistiller

 

Note: mdk9.2 and 9.1 already has this as /usr/lib/cups/backend/pdf

 

3. Log in as root, put it in /usr/lib/cups/backend or wherever

cups/backend lives (not needed on mdk).

 

4. 'chmod +x' the file should be 755 or rwxr-xr-x (not needed on mdk).

 

5. Restart CUPS (not needed on mdk).

 

6. To check if CUPS recognizes it as a usable backend, let root run:

      'lpinfo -v | grep pdf'

    should output "direct pdf"

 

7. Test the pdfdistiller backend:

    a. '/usr/lib/cups/backend/pdf'

        should output 'direct pdf "Unknown" "PDF Writing"'

    b. "/usr/lib/cups/backend/pdf 1 2 a b"

      should output: "Usage: pdf job-id user title copies options [file]"

 

8. Test existence of Ghostscript's ps2pdf with 'which ps2pdf'. Output

should be a path like "/usr/bin/ps2pdf" or similar

 

9. Download a PPD file for cups to print with. An Adobe Distiller PPD is

a great choice. Try this page:

 

http://www.pentondigitalads.com/PentonDigi...cript_files.htm

("Acrobat Distiller PPD for Windows")

    If this link is dead, search Google/web for "distiller ppd" and

find a suitable file.

    I used the Adist4.ppd found on the link...

 

10. Put the PPD file in /usr/share/cups/model or wherever your CUPS

model PPDs are stored.

 

11. Restart CUPS.

 

12. Add the printer to CUPS with the command:

    'lpadmin -p <Chosen Name> -E -v pdf:<out folder> -m <ppd-file>'

      i.e.:

    'lpadmin -p PDFprinter -E -v pdf:/tmp/pdf_out -m distiller.ppd'

 

13. As root add /tmp/pdf_out (rwxrwxrwx) and have samba export it with

    read only=no, guest ok=yes, guest only=yes.

 

14. Test the PDF output by manually printing to the new printer:

    'lpr -P PDFprinter test.txt'

    or use http://localhost:631 and use the admin tools to print a test page,

    I think I can set this up form hear alone, but have not tryed yet.

 

Troubleshooting each step:

 

1. If you're stuck on #1, find a more appropriate howto.

 

2. If that file is missing, beg someone for a copy.

 

7. I got stuck on this one. without renaming it "pdf", it didn't work at

all. No clue why. Try copying the file "pdfdistiller" the file to "pdf"

in the same folder. ('cp pdfdistiller pdf'). If these aren't working, go

no further. Make sure CUPS is installed properly and work on this first.

 

8. If this doesn't work, you'll need to install the latest "ESP

Ghostscript". It's available at:

        http://www.cups.org/software.php

 

9. Adobe doesn't distribute this file, so it could be tricky to find.

 

10. Same as #3. PPD files made for Macintosh and Windows computers will

need to be re-saved in un*x format.

 

11. There should be a number of PPD files in that folder already. Search

for "laserjet.ppd" if you have no idea where to find them.

 

12. If this fails, make sure you're specifying a valid PPD file from the

model folder in the "-m" part. Alternatively, you may use '-P <ppd>'

instead of '-m', but you must specify the entire path.

 

14. No go? Time to start logging everything. After the first line of

your backend file (pdf or pdfdistiller), add the line "set -x". Edit

your cupsd.conf and set "LogLevel debug". Restart CUPS and peruse the

information in /var/log/cups/error_log for good debugging info.

 

Now move to the windows box and connect the printer using "Apple Color LW 12/660 PS" printer driver. Print and then go get the pdf file from the samba the export.

 

UPDATE: I was using this to print PDF's from Windows, but it has limitations that I could not work around so I found PDFcreator on TheOpenCD which is working lots better for me.

 

http://www.theopencd.org/index.php?option=...pdfcreator.html

 

I can normally print PDF's on Linux, so its only a issue for programs like AutoCAD that I still need Windows for.

Edited by rsutherland
Link to comment
Share on other sites

in case someone tries it, in #13, create /tmp/pdf_out as a directory.

 

it works converting .txt , .ps or .jpg files, but not word or excel files.

does converting word/excel works for you?

do you know of a PPD that does this?

isn't a PDF virtual printer suppose to convert anything printable?

regards,

baudo

Link to comment
Share on other sites

I have the setup on some file servers for windows computers, which print to it through the samba service. Windows think its a "Apple Color LW 12/660 PS" postscript (PS) printer so CUPS will only see PS input, I have never tried others, like *.jpg...

From Linux/GNU/KDE you can print to PDF without this, at least as long as I have been using it...

I can print Word, AutoCAD, Eagle (makes Circuit Boards), IE, and some other random stuff I have tried. CUPS gets a PS file from the Apple print driver and runs it through the distiller, out pops a PDF. I only use the Apple driver because I have seen others say it makes clean PS files unlike the windows divers or even HP's

 

And some Samba /etc/samba/smb.conf notes that may help...

[PDFprinter]
       comment = PDFprinter
       path = /var/spool/samba
       read only = No
       create mask = 0700
       guest ok = Yes
       printable = Yes
       print command = lpr-cups -P %p -o raw %s -r   # using client side printer drivers.
       printer name = PDFprinter
       use client driver = Yes
       oplocks = No
[pdf_out]
       comment = PDF print output
       path = /tmp/pdf_out
       read only = No
       guest only = Yes
       guest ok = Yes

Note the "use client driver = Yes" is not default and makes a differance on WinNT/Win2k/WinXP for admin users. if (you= :-?) see(samba->doc's);

Edited by rsutherland
Link to comment
Share on other sites

  • 1 month later...

I played with this some more this weekend and got some other CUPS backend virtual printers working, including jpg, png, gif. The image size is part of the CUPS URI, i.e. the jpg backend has a Device URI like jpg:/image_output_dir@1600x1200. As with the pdf virtual printer CUPS needs to get a clean postscript input, so use the Apple Color LW 12/660 PS driver if you can find it. I used ImageMagick's convert function to do this, which is very forgiving and in Mandrake. Anyway the backend drivers are at http://epccs.com/indexes/Documents/VirtualPrinting/ which is only 256k DSL so it's a bit slow, but a nice play area.

Edited by rsutherland
Link to comment
Share on other sites

  • 3 weeks later...
  • 8 months later...

Hey thats a great how to.

 

I had to re-install my server (HDD crash) and thus had to set up, among other things, my virtual PDF printer.

 

Took me a few weeks when i first set it up a yr or so ago, but this time using this how-to all done in less then 5mins!! :D :banana:

 

The only suggestion is the exact permissions on the output folder.

777 is good to start with but a more appropriate setting should be had later.

As what user are the PDF's created (ie cups user) ?? It seems root so you could chmod 755 && chown root.root on the output folder.

Link to comment
Share on other sites

Guest billygoat32

The issue we are running into is that we have 2 users that log into the samba box one with write access one with out. The only thing that we can do to tell them apart is by the date/time. This isn't efficent for the users to have to wade though the files (say if a couple users print off 10 docs each) to see what ones are theirs.

 

Thanks.

Link to comment
Share on other sites

Guest billygoat32

Let em rephrase that. We have 2 accounts and about 70 users. We are only using the samba box for 1 share right now and do not want to input all the users into samba. So any thoughts on how to make the output name of the print job the same as the input?

Link to comment
Share on other sites

Guest billygoat32

Im making some head way... found this

 

"the job title is passed to all filters and backends as $3 by CUPS. It is

my experience that it is more reliable to use this, because the %%Title

is more often not present than $3. The complete list of parameters provided

by CUPS to all filters and backends is this:

 

$0 -- printername

$1 -- job-ID

$2 -- username

$3 -- job-title

$4 -- printjob-options

$5 -- requested copies

$6 -- <filename>; empty if taken from 'stdin'

 

They may be picked up by self-rolled custom backends and filters to

use for their purposes.x"

 

I will keep working with it to try and figure it out. If anyone has any input feel free to chime in :)

Link to comment
Share on other sites

Guest billygoat32

I found a solution... trying to grep $6 for the title worked, however I could not open the resulting PDF file, I got an error about their being no pages in the document. So what I did was this

 

cat $6 > /tmp/pdftitle.ps

TITLE=`grep -i title /tmp/pdftitle.ps`

 

Then later on ...

 

OUTPUTFILENAME="$PDFDIR/$TITLE-$PRINTTIME.pdf"

 

 

and finally commented out the if then else statement, to just print the file

 

#if [ $# -eq 6 ]; then

$PDFBIN /tmp/pdftitle.ps "$OUTPUTFILENAME"

#>& /dev/null

#else

# $PDFBIN - "$OUTPUTFILENAME" >& /dev/null

#fi

 

hopefully this will help someone someday :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...