LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums HCL Reviews Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-30-2011, 01:46 AM   #1
devmoc
Member
 
Registered: Sep 2005
Posts: 38

Rep: Reputation: 15
Printing to cups-pdf via command line with options?


I'm having a hard time trying to print documents to PDF via cups-pdf at the command line and get all of the nice formatting options that the GUI print spooler dialogs provide. I know how to do "lpr -P Generic-CUPS-PDF-Printer filename" to get a general file printed to a PDF, but this method clearly is missing all of the nice formatting options that get passed when using a GUI print spooler (margins, fonts, dpi, paper size, etc..). I tried to use ps to capture whatever command is being sent by the spooler but couldn't figure it out, since I'm not really sure what commands get called by the spooler. Any help would be appreciated.
 
Old 07-01-2011, 08:43 AM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,903

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Have you tried printing in the manner of Cups command-line, specifying the lpr options for margins, dpi, etc? Here is a link to the Cups documentation for command-line printing: http://www.cups.org/documentation.php/options.html
 
Old 07-02-2011, 09:11 PM   #3
devmoc
Member
 
Registered: Sep 2005
Posts: 38

Original Poster
Rep: Reputation: 15
Thanks! That helped a great deal, I have it down to this at the moment:

Code:
lpr -P PDF -o ppi=300 -o media=Letter -o fit-to-page -o page-left=18 -o page-right=18 -o page-top=18 -o page-bottom=18 filename
One last problem, how to specify the font? The Gnome print spooler GUI allows you to set a font and font size. Thanks!
 
Old 07-02-2011, 09:22 PM   #4
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1003Reputation: 1003Reputation: 1003Reputation: 1003Reputation: 1003Reputation: 1003Reputation: 1003Reputation: 1003
Hello,

You could always use a2ps... From the man page:
Code:
       -Fnum Changes  font size to this value. Default values for
             font size are 6.8 in landscape mode, 6.4 in twinpage
             portrait  mode and 9.0 in single page portrait mode.
             Try other sizes if you think that these  values  are
             too small (or big).
Read the man page for more information about that command. a2ps will be your best bet man... Hope that helps!

Cheers,

Josh
 
Old 07-03-2011, 04:12 AM   #5
devmoc
Member
 
Registered: Sep 2005
Posts: 38

Original Poster
Rep: Reputation: 15
a2ps is not bad except that it doesn't appear to support word wrapping which makes it a no go for me.
 
Old 07-04-2011, 04:53 PM   #6
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1003Reputation: 1003Reputation: 1003Reputation: 1003Reputation: 1003Reputation: 1003Reputation: 1003Reputation: 1003
Have you tried piping them together to try to get the desired results you need?
 
Old 07-06-2011, 02:05 AM   #7
devmoc
Member
 
Registered: Sep 2005
Posts: 38

Original Poster
Rep: Reputation: 15
Piping lpr to a2ps? How do you do that? lpr wants a device specified (-P) otherwise it just uses the system default printer.
 
Old 07-11-2011, 09:43 AM   #8
devmoc
Member
 
Registered: Sep 2005
Posts: 38

Original Poster
Rep: Reputation: 15
Thumbs up

I figured out 2 methods that work well and can be used in scripts:

Code:
enscript INPUT --word-wrap -B -o - | ps2pdf - OUTPUT.pdf
and

Code:
unoconv -f pdf INPUT
The unoconv program creates a slightly nicer looking PDF using DejaVuSansMono font. Other than that, these methods are the same; producing a formatted PDF with margins, word wrapping, letter paper size, etc..
 
Old 07-14-2011, 03:32 AM   #9
devmoc
Member
 
Registered: Sep 2005
Posts: 38

Original Poster
Rep: Reputation: 15
Just did some further research and came across something that addresses all of my needs. It's called a2pdf.

http://perl.jonallen.info/projects

It lets you change the font and font size, yay! It also does word wrapping by default, yay! Example with letter size paper and default 0.75" margins:

Code:
a2pdf --noline-numbers --noperl-syntax --noheader --nofooter --page-width 612 --page-height 792 --font-face arial INPUT -o OUTPUT.pdf
Very nice program!
 
  


Reply



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
Printing PDF letterhead via CUPS jetblackstar Linux - Software 17 02-01-2014 11:21 AM
Printing PDF Documents from command line with PCL commands. nivantha Linux - Newbie 5 02-15-2008 03:56 PM
cups-pdf command-line print .html pages without tags ? o5iri5 Linux - Software 1 08-06-2007 07:24 AM
Printing management (command line cups) grautu Slackware 3 10-20-2005 02:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:31 PM.

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