LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-10-2008, 02:45 PM   #1
nivantha
LQ Newbie
 
Registered: Apr 2006
Distribution: Fedora
Posts: 17

Rep: Reputation: 0
Question Printing PDF Documents from command line with PCL commands.


Hi,
I have a program that prints PDF documents using the lp command. I convert the PDF document into PCL using the following command;[/FONT]

gs -sDEVICE=ljet4 -sOutputFile=test.pcl -q -dBATCH -sPAPERSIZE=a4 -dNOPAUSE test.pdf

and then add a PCL tray selection command using 'sed'. The whole idea of converting it to PCL is the need to embed a tray selection command into the file.

Recently I needed to do duplex printing and I added the PCL duplexing command into the PDF to PCL converted file. And the duplexing is also working now. However there is a problem. The left margin of the second page is indented towards the right than where the original left margin should be.

I'm able to send the document to the printer as a pdf itself without converting. But then I don't know how to set the tray selection and duplexing options. If there is a method to set the tray selection and duplexing options rather than needing to convert and embed the commands into the doc, I think it would be much easier.

The target printer is a HP LaserJet that supports PCL commands. And the linux environment is Redhat Enterprice Linux Version 3.

Any comments?
 
Old 02-10-2008, 03:27 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,877

Rep: Reputation: 350Reputation: 350Reputation: 350Reputation: 350
The only method that comes to mind is to pipe the output of gs through enscript instead of lpr. The method allows enscript to be used as a print filter to format output.

See the man page for more detailed info. See especially the --margins= option.
 
Old 02-12-2008, 11:20 AM   #3
nivantha
LQ Newbie
 
Registered: Apr 2006
Distribution: Fedora
Posts: 17

Original Poster
Rep: Reputation: 0
I managed to set the duplexing option using the driver options. I used a generic PCL 5e driver hpijs. Now I can print a pdf document directly using lp -d <printer name> <document name> without a pcl conversion and the duplexing works fine. However one problem still remains. That's selecting the source trays.

This also can be setup from the driver options itself. However, I need my program to have the control of deciding the source tray based on the document name. One option is to maintain two separate queues defined in the system for the same printer. where different source trays are configured for each of them. But it's not convenient to do so because my program only receives one printer name.

So is there anyway that I can dynamically setup the source tray of the printer at the time of printing?

The printer is configured as a Jetdirect printer. Driver is 'Generic PCL 5e Printer hpijs.

Last edited by nivantha; 02-12-2008 at 11:22 AM.
 
Old 02-12-2008, 11:49 AM   #4
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,877

Rep: Reputation: 350Reputation: 350Reputation: 350Reputation: 350
With CUPS you can define virtual printers for one physical printer. For example: I have 6 printers defined (but only one physical printer): draft_color, draft_greyscale, normal_color, normal_greyscale, photo_color, hiqual_greyscale.

You might be able to do something similar be defining printers based on the paper tray needed.
 
Old 02-12-2008, 12:17 PM   #5
nivantha
LQ Newbie
 
Registered: Apr 2006
Distribution: Fedora
Posts: 17

Original Poster
Rep: Reputation: 0
I know that I can define multiple virtual printers for one physical printer. What I'm looking for is a way to set the tray selection option at printing time. I mean there has to be a way to set options for the printer driver at printing time. Isn't it?
 
Old 02-15-2008, 03:56 PM   #6
nivantha
LQ Newbie
 
Registered: Apr 2006
Distribution: Fedora
Posts: 17

Original Poster
Rep: Reputation: 0
Thumbs up Eureka!

Found a method to do this. In CUPS you can set options in the printer driver at printing time. You just have to select an appropriate driver for the printer which is compatible.


lpoptions -p <printer name> -l (e.g: lpoptions -p laserjet -l)

This command will give you the available options for the printer.

With the -o option of lp command you can provide these options.

For example to set double sided printing with long edge binding you can have;

lp -o sides=two-sided-long-edge -d <printer name> <filename>


And if you want to specify the paper source (Say the option is Tray1 for Tray 1 in the driver) you can have

lp -o sides=two-sided-long-edge -o media=Tray1 -d <printer name> <filename>

I found this from the CUPS Software Users Manual. There are lot more options that can be used in this.

Thanks for the helpful tips.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Linux PDF editor for manipulating PDF documents LXer Syndicated Linux News 0 12-19-2007 10:50 AM
PDF to Command line format Tux-O-Matic General 6 10-04-2006 08:05 AM
transfere a pcl stream to pdf files hjl Linux - Software 0 11-04-2005 11:21 AM
command line text to pdf conversion waskelton4 Linux - Software 4 02-14-2005 06:38 PM
cups not printing pdf documents javeree Linux - Software 0 12-07-2004 06:55 PM


All times are GMT -5. The time now is 09:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration