Find the answer to your Linux question:
Results 1 to 3 of 3
Hi, I want to add a printer that automatically prints to postscript a file. (i.e. just an imaginary printer) I need to be able to call the print function from ...
  1. #1
    Just Joined!
    Join Date
    Nov 2006
    Posts
    5

    Printing to file

    Hi,

    I want to add a printer that automatically prints to postscript a file. (i.e. just an imaginary printer)

    I need to be able to call the print function from the cmd line.
    eg: print doc.pdf file.ps

    Does anyone know how I could go about doing this? How would I set up this printer, and what would the command be? I'm happy to do it in Ubuntu also if it's easier...

    Thank you,
    Rob

  2. #2
    Linux Enthusiast
    Join Date
    Apr 2004
    Location
    UK
    Posts
    658
    Does it absolutely have to be a printer?

    You ought to be able to script a PS backend for cups by ripping off one of the older pdf backend scripts (these days it uses an app instead of a script) but it won't be straight forward.

    The basic command line for printing in Linux is lpr.

    Code:
    lpr -P Deskjet test.pdf
    Will send test.pdf to the printer called Deskjet, however lpr will not be able to handle every eventuallity. E.g. It has no idea how to decipher word docs so it can't print them.

    Will it always be pdf files being printed? Can you use pdf2ps instead?

    If you want to try making a postscript backend the let us know and we can have a bash, but it will probably get tricky.

    Let us know how you get on,

    Chris...
    To be good, you must first be bad. "Newbie" is a rank, not a slight.

  3. #3
    Just Joined!
    Join Date
    Nov 2006
    Posts
    5
    Hey chris,

    Thanks for getting back to me. I've just about come up with a solution. The goal of the project is to convert uploaded documents (eml, doc, xls, ppt, rtf, pdf, jpeg etc.) to tiff. So I needed to convert those files to ps and then ghostscript them to tiff.

    For pdf files I'm using pdf2ps. For the rest of the file types I'm using open office for the conversion. I created a macro that prints the files passed to it to postscript. I can call openoffice to run invisibly from a command line and pass a file to the macro for conversion.

    It's still very buggy, especially when I try an execute it from php (using exec) I think it has something to do with permissions and users for apache. But it seems to be working!

    This is how I'm doing it if anyone is interested...

    --create a fake display 25
    $ Xvfb :25 -screen scrn 800x600x16 &

    --launch openoffice using that fake display, running invisibly and run the macro I created...
    $ DISPLAY=":25" openoffice -invisible "macro:///Standard.Module1.Main(/home/robh/Desktop/Infology V2.doc)"

    These are the errors I need to straighten out... if anyone has any ideas...
    I get the following error when launching Xvfb:

    robh@robh-ubuntu:~$ Could not init font path element /usr/share/X11/fonts/TTF/, removing from list!
    Could not init font path element /usr/share/X11/fonts/OTF, removing from list!
    Could not init font path element /usr/share/X11/fonts/CID/, removing from list!


    And when launching openoffice...
    FreeFontPath: FPE "/usr/share/X11/fonts/misc/" refcount is 2, should be 1; fixing.
    Could not init font path element /usr/share/X11/fonts/TTF/, removing from list!
    Could not init font path element /usr/share/X11/fonts/OTF, removing from list!
    Could not init font path element /usr/share/X11/fonts/CID/, removing from list!

    The good news is that soffice is being executed and is in my processes list - and it's converting file. I don't seem to be able to run the process more than once however (without restarting).

    If anyone has any info about the errors or would like any info from me, let me know.

    Cheers,
    Rob

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •