LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 01-26-2009, 10:52 AM   #1
jetblackstar
LQ Newbie
 
Registered: May 2005
Location: Bournemouth
Distribution: Fedora
Posts: 15

Rep: Reputation: 1
Printing PDF letterhead via CUPS


I'm not sure i'm going about this the right way.

Basic reqeirement:
To be able to print a PDF or PostScript letterhead/overlay onto any given document printed through cups.
I am trying to elimnate the need for pre printed stationary.

I know PCL has inbuilt functionality for "Overlays" that would do the job, but given that CUPS works in Postscript I was hoping to avoid locking myself into using only PCL printers.

It also means you can create letterheads or form overlays with one of hundreds of different applications like OpenOffice, Scribus, etc. Or take a PDF direct from a graphic artist and use that. And any application that can print to CUPS can use them.

Any pointers would be much apreciated. Including completly different Linux technologys or methods.

Thanks
-Jet
 
Old 01-26-2009, 11:36 AM   #2
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Lubuntu
Posts: 19,176
Blog Entries: 4

Rep: Reputation: 430Reputation: 430Reputation: 430Reputation: 430Reputation: 430
Could you not create a template in, say OO.o, and use that (it would have the logo and so on already set up. Then convert the document to pdf and then print it?
 
Old 01-26-2009, 12:41 PM   #3
jetblackstar
LQ Newbie
 
Registered: May 2005
Location: Bournemouth
Distribution: Fedora
Posts: 15

Original Poster
Rep: Reputation: 1
That would give me Letter heads from anything I made in OpenOffice, True.
But I was hoping to be able to get the letterheads printed on other applications too.
Like third party apps that print invoices, as well as for writing letters.

Thanks anyway.

I've just found the PSUtils programs. Might be able to get them to combine two Postscript documents on top of each other. Will post any solutions back here.
 
Old 01-27-2009, 06:30 AM   #4
jetblackstar
LQ Newbie
 
Registered: May 2005
Location: Bournemouth
Distribution: Fedora
Posts: 15

Original Poster
Rep: Reputation: 1
Ok, have tried two toolkits with a little better success. But nothing that will actually work.
Both are just command line at the moment, they could later be built into a filter for CUPS (God knows exactly how i'll actually do that)

psutils (ps to ps, etc):
This one is messy, but almost works. pstops allows you to merge postscript pages in the same document onto one page. So:
- Merge header onto top of document (with ghostscript in pdf because doing it in postscript screws up, then convert back to postscript :s )
- Get pstops to merge page 0 onto page 1. Fine for the first page, but the pstops spec "2:0+1" (A short regex like language for instructing pstops what to do) I wrote means it will merge every other page together. Not only can I not get the header on anything but page 1, but it screws up pages 3-4, 4-5 etc.

Unless I blow the doc apart and stack a copy of the header inbetween each page, this wont work.

So failed.

pdftk:
This seemed to work much better, except in terms of getting it back to Postscript for Cups to use. Got closer to being a filter.
- Convert incoming stdinput into PDF
- Pipe into pdftk with the following
pdftk - background testBanner.pdf output -
(The -'s are for using stdin and stdout, check man if you want files)
- Pipe out to pdf2ps to get back to Postscript for CUPS.

The resulting PDF is great at stage 2, but the resulting Postscript file at the end of stage 3 is buggered. The data is messed up and the pages are teenyly short.


So, help =/
With what is meant to be a paperless office how is printing a header via CUPS so hard?!
-Jet
 
Old 01-27-2009, 10:41 AM   #5
jetblackstar
LQ Newbie
 
Registered: May 2005
Location: Bournemouth
Distribution: Fedora
Posts: 15

Original Poster
Rep: Reputation: 1
Ok, ive got the second way working (pdftk). Turns out pdftops doesnt like pipes. So i've written up a script (That uses a temp file) that could potentially be used as a filter.

It sucks in PostScript and adds a parameterized PDF banner, adds that to each page, and spits out postscript (using stdin and stdout). Its a bit ugly that it has to make it into PDF first, work with it, then convert it back. But unless someone writes a util to merge a separate PS file to every page on an existing PS document, then i have to use pdftk.

Anyone know about CUPS filters? Ive vaguely read something about having to use/set mime types. Sounds scary.
 
Old 02-19-2009, 01:00 PM   #6
chr00ted
LQ Newbie
 
Registered: Feb 2009
Location: Southeast Florida
Distribution: Fedora 10
Posts: 3

Rep: Reputation: 0
Printing PDF letterhead via CUPS

Jetblackstar, would you mind posting your pdftk script please?
 
Old 02-20-2009, 06:11 AM   #7
jetblackstar
LQ Newbie
 
Registered: May 2005
Location: Bournemouth
Distribution: Fedora
Posts: 15

Original Poster
Rep: Reputation: 1
Cool

Hah, sry completely forgot about finishing this thread.
I Am my own worst nightmare, forum problem unresolver person.

I'm in the middle of tax returns right now, so this is a rushed copy paste, slap GPL on job. But apparently i left the script in mildly acceptable condition; Script and GPL attached.
ps Forum software wouldn't let me upload .sh so it's a .txt. Just rename when you've downloaded.

If anyone can come up with a full cups integration please send me a copy back.

Hope this helps.
-Jet
Attached Files
File Type: txt pdfheader.txt (1.4 KB, 35 views)
File Type: txt gpl-2.0.txt (17.6 KB, 19 views)
 
Old 03-29-2009, 02:50 PM   #8
ceekoe
LQ Newbie
 
Registered: Mar 2009
Posts: 3

Rep: Reputation: 1
Hello,
I would be interested in a cups integration as well.
Are the "-"'s only placeholders (so have I to change them) or the common way for using pipes in linux? And what is the "cat" command concretely doing?

Thank you
-ceekoe

Last edited by ceekoe; 03-29-2009 at 03:14 PM.
 
Old 04-02-2009, 12:55 PM   #9
jetblackstar
LQ Newbie
 
Registered: May 2005
Location: Bournemouth
Distribution: Fedora
Posts: 15

Original Poster
Rep: Reputation: 1
Cool

The "-"'s are the syntax of the various commands to represent stdin or stdout as the source or destination of the input/output where doing this isn't the default behavior. The "-" actually sits in place of the filename. In theory all of the commands should pipe in and out of each other like this, but i found one of the commands didn't like doing this. So i had to dump out to a temporary file and then cat it back into the next one.
Oh and the lonely cat command will be piping stdin into the first pdftk routine. IE its sucking up input for me and spewing it where i want.

No alteration of the commands is necessary, the only thing you need to alter in the script is the location of your header pdf. (Should have this as a command line param, but didn't get to do that).

It should be usable by just outputting your postscript to my script via stdin and the result will be spewed as output on stdout.

This can be done at command line with
Code:
  cat yourpostscript.ps | pdfheader.sh > destinationfile.ps
For the life of me i forget what i called the script so replace "pdfheader.sh" with the real name

While this is ready programatically to be a CUPS filter, i never quite got into how the hell you configure CUPS to actually use a custom filter. Docs were a pita. So never got a resolution. Still its something I'd still find useful so will look into it again.
If anyone has created CUPS filters please post here or PM me.

Sorry the uploaded is suck a hack.
-Jet
 
Old 04-05-2009, 06:40 AM   #10
ceekoe
LQ Newbie
 
Registered: Mar 2009
Posts: 3

Rep: Reputation: 1
Hello Jet,
thank you a lot for your concise explanation of the commands. Since I haven't much practise in writing shell scripts, your post took me far further.
I have read a lot on the cups-archtecture and have an idea how I might have to integrate it as a kind of own "mime-type" with the corresponding convertation. If I'm successful I'm will post a reply.

Kind Regards
ceekoe

Last edited by ceekoe; 04-05-2009 at 06:42 AM.
 
Old 04-05-2009, 12:53 PM   #11
ceekoe
LQ Newbie
 
Registered: Mar 2009
Posts: 3

Rep: Reputation: 1
Hello Jet,
good news. I was able to integrate the pdftk-toolkit into cups after several hour of trying and reading the CUPS Software Programmers Manual. If you are interested I can send the script to you. I developed and tried it on Debian Etch.

ceekoe
 
Old 04-06-2009, 09:10 AM   #12
jetblackstar
LQ Newbie
 
Registered: May 2005
Location: Bournemouth
Distribution: Fedora
Posts: 15

Original Poster
Rep: Reputation: 1
Thumbs up Wahoo

Absolutely fantastic!
I'd already spent many hours reading the CUPS programmers documentation but obviously didn't have the same sticking power you did.
Well done!

I will PM you my email address.
Unless, for the benefit of others following this you would be willing to post it here as an attachment. Your call, its your work.

Well done again!
-Jet
 
Old 05-15-2009, 09:31 AM   #13
EricPH
LQ Newbie
 
Registered: May 2009
Posts: 2

Rep: Reputation: 0
Quote:
Originally Posted by ceekoe View Post
Hello Jet,
good news. I was able to integrate the pdftk-toolkit into cups after several hour of trying and reading the CUPS Software Programmers Manual. If you are interested I can send the script to you. I developed and tried it on Debian Etch.

ceekoe
Too bad that you haven't post your script...
 
Old 05-15-2009, 11:05 AM   #14
jetblackstar
LQ Newbie
 
Registered: May 2005
Location: Bournemouth
Distribution: Fedora
Posts: 15

Original Poster
Rep: Reputation: 1
Smile

I havent had a chance to even try ceekoe's CUPS integration, or in fact help him with an other issue he was asking me about.
But I'm sure if you ask nicely he will email his scripts to you or post here if he is happy to.
Since it is not my code I'm not happy posting it. That is entirely up to Ceekoe.

-Jet
 
Old 05-18-2009, 02:17 PM   #15
chr00ted
LQ Newbie
 
Registered: Feb 2009
Location: Southeast Florida
Distribution: Fedora 10
Posts: 3

Rep: Reputation: 0
I found another solution thanks to my local linux user group: FLUX (flux.org). Member Kwan Lowe sent me the following:

I have done a similar thing to generate some automated PDFs. I used m4
and tex to do it...

--Example Report--
\documentclass[a4paper,10pt]{report}
\usepackage{graphicx}
\usepackage{eso-pic}

% Title Page
\title{TPS Report}
\author{Bob}

\begin{document}
\maketitle

\begin{abstract}
This is the TPS report to be submitted in triplicate to the three bosses.
\end{abstract}

\begin{center}
\includegraphics[width=120mm,bb=0 0 808 660]{Diagram1.png}
\end{center}

\begin{verbatim}
NEWS
The quick brown fox jumped over the lazy dogs.

\end{verbatim}
\end{document}

--End TPS Report--

You can create an m4 template from the above, then just use it as a
wrapper to your report. You may need to escape certain sequences in
the report text. If so, pipe it through sed to escape symbols like @,
for example.

Once complete you can run it through pdflatex to generate a PDF file.

Last edited by chr00ted; 05-19-2009 at 12:09 PM. Reason: addition recognition
 
  


Reply

Tags
cups, pdf


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
How to wget a webpage, and save as PDF (like cups-pdf) ? frenchn00b Programming 3 11-18-2008 03:48 PM
PDF printing to cups with many output problems! maginotjr Linux - Server 1 03-06-2008 05:44 AM
cups not printing pdf documents javeree Linux - Software 0 12-07-2004 05:55 PM
remote cups printing to a smb/cups print server? justanothergeek Linux - Networking 2 09-15-2004 08:31 AM
Printing option to letterhead johniccp Linux - Newbie 0 04-16-2004 10:24 AM


All times are GMT -5. The time now is 02:08 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration