Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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.
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?
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.
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
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.
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.
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?
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.
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.
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.
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.
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.
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.
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.
\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 01:09 PM.
Reason: addition recognition
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.