LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 01-22-2017, 01:45 PM   #1
Janvanl
Member
 
Registered: Apr 2015
Posts: 49

Rep: Reputation: Disabled
Printer for printing to files


Hi
after searching in all direction I ask it here.
Is there a "printerdriver" for printing to plain text files that get saved on disk.

I can hardly imagine being the first that needs this but on the internet I cannot find a solution.

Regards,
Jan
 
Old 01-22-2017, 02:03 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 17,466

Rep: Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273
Look at the print dialog box in your GUI text editor. There should be a print to file option in the printer list where you can save the output to one of several outputs like PDF. If this does not work then we need some additional information.
 
Old 01-22-2017, 02:54 PM   #3
Janvanl
Member
 
Registered: Apr 2015
Posts: 49

Original Poster
Rep: Reputation: Disabled
Thanks for the fast reply!

Ok
I found that I could define a printerque "raw" but that is no longer there, neither in Kubuntu 12.04
nor in 16.04.

What I would like is a printerque that I can print to but which saves plain textfiles without overwriting
the old ones like the PDF-printer does. (some name with date/time would do)

I know a lot is possible with lpr but did hope someone already did this.

kind regards,
Jan
 
Old 01-22-2017, 03:48 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 17,466

Rep: Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273
There should be a text box in the printer dialog where you can enter the filename of your choice.

What do you mean by saves plain text files. It seems like a bit of a paradox that you want to print to file a text file that saves as plain text.
 
Old 01-22-2017, 04:00 PM   #5
Janvanl
Member
 
Registered: Apr 2015
Posts: 49

Original Poster
Rep: Reputation: Disabled
You are right,

I want to print output from a programm to plain textfiles to produce csv-files that can be imported in another programm
because there is no functioning interface between the two. I have made several bash-scripts already to build a temporarily
solution.

We are working on the interface but that will take some time.

Some 20 years ago I did similar things with vaxvms, now openvms,
but even linux on the desktop runs so you do hardly need a command line anymore,
one gets rusty . . . .

Kind regards,
Jan
 
Old 01-22-2017, 04:18 PM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 20,530

Rep: Reputation: 5017Reputation: 5017Reputation: 5017Reputation: 5017Reputation: 5017Reputation: 5017Reputation: 5017Reputation: 5017Reputation: 5017Reputation: 5017Reputation: 5017
Quote:
Originally Posted by Janvanl View Post
You are right,
I want to print output from a programm to plain textfiles to produce csv-files that can be imported in another programm because there is no functioning interface between the two. I have made several bash-scripts already to build a temporarily solution. We are working on the interface but that will take some time.

Some 20 years ago I did similar things with vaxvms, now openvms, but even linux on the desktop runs so you do hardly need a command line anymore, one gets rusty
Check out the "FileDevice" directive in the CUPS configuration:
http://git.net/ml/printing.cups.deve.../msg00007.html

There is also CUPS-PDF, which will shovel it into a PDF...from there, you could use pdf2txt (intermediate step, yes, but it could work at least)
http://www.cups-pdf.de/

OR, you could write your own printer in Perl:
Code:
#!/usr/bin/perl
use IO::Socket::INET;
$myport=<put some port number here>;
$pserve=IO::Socket::INET->new(LocalPort => $myport,Type=>SOCK_STREAM,Reuse=>1,Listen=>1) or die "can't do that $!\n";
while ($pjob=$pserve->accept()) {
  open(J,">>/private/tmp/x") or print "having issues $!\n";
  print J "New job...\n";
  while (<$pjob>) {
  print J "$_";
  }
  close J;
  close $pjob;
}
And just add a print device in CUPS to print to port <whatever you specify> above. Easy enough to shove something in there to check for the existence of a file, and rename accordingly if one exists when you try to print. Or just name the print file the Unix epoch time, so each should be unique.
 
1 members found this post helpful.
Old 01-22-2017, 05:16 PM   #7
Janvanl
Member
 
Registered: Apr 2015
Posts: 49

Original Poster
Rep: Reputation: Disabled
Thanks T-Bone

That was what I was looking for!

Now I have something to do,
I like the perlscript.

Just added a rawprinter in cups and searching for the spooled files but the rst is for tommorow.

Kind regards,
Jan
 
Old 01-22-2017, 06:38 PM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 17,466

Rep: Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273
Here is some additional information about cups filters.

https://en.opensuse.org/SDB:Using_Yo...rint_with_CUPS

In addition I have also setup a samba printer using LPRNG that you can add to cups. The basic code is:

Code:
  [myprinter]
        comment = my printer
        printing= LPRNG
        path = /var/spool/samba
        printable = yes
        print command = /usr/local/bin/myscript %s
 
Old 01-24-2017, 02:59 PM   #9
Janvanl
Member
 
Registered: Apr 2015
Posts: 49

Original Poster
Rep: Reputation: Disabled
Almost there, the perlscript is perfect

Just, I need to get plain text instead of postscript and I cannot grasp where to put the right parameters.

sudo lpadmin -p tofile -E -v socket://localhost:12000 -m raw
gives a postscriptfile

sudo lpadmin -o document-format=text/plain -p tofile -E -v socket://localhost:12000 -m raw
gives a postscript file

I added -i, took away -p but no luck so far, what am i overseeing?

Knd regards,
Jan
 
Old 01-24-2017, 03:38 PM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 17,466

Rep: Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273
The -p is the name of the printer queue and the -i would be the name of the filter script.

The perl script does not alter the incoming print stream so your application is actually outputting Postscript?
 
Old 01-24-2017, 04:03 PM   #11
Janvanl
Member
 
Registered: Apr 2015
Posts: 49

Original Poster
Rep: Reputation: Disabled
I printed a textfile from Kate and if I choose "tofile" as a printer then this "printer" should use a PPD-file when appropriate doen't it?
Why it uses postscript I cannot see.

At least is that what I understand from "man lpadmin".

Kind regards,
Jan
 
Old 01-24-2017, 04:17 PM   #12
Janvanl
Member
 
Registered: Apr 2015
Posts: 49

Original Poster
Rep: Reputation: Disabled
If I print from the application it als sends a postscriptfile.

Kind regards,
Jan
 
Old 01-24-2017, 04:32 PM   #13
michaelk
Moderator
 
Registered: Aug 2002
Posts: 17,466

Rep: Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273
Your tofile printer will only use a PPD if specified one when it was created i.e. -P option.

It depends on the application / version / distribution but in the past the default file print format was postscript.

Last edited by michaelk; 01-24-2017 at 06:40 PM.
 
Old 01-25-2017, 02:40 AM   #14
Janvanl
Member
 
Registered: Apr 2015
Posts: 49

Original Poster
Rep: Reputation: Disabled
Thanks michaelk,

I know that and therefore I wonder that postscript is used.
This is Ubuntu 12.04 with KDE on top but that does not matter much.

Main thing is, I get a plain text file. what comes out as a ps-file is a perfect printout.
This hard to find in internet.

Kind regards,
Jan
 
Old 01-25-2017, 05:07 AM   #15
michaelk
Moderator
 
Registered: Aug 2002
Posts: 17,466

Rep: Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273
You can print from the command line using lpr which will use plain text or if you have to use kate add a PS to text conversion.
 
  


Reply

Tags
driver, printer, text


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
Continous printing with CUPS thermal printer (GeBE USB Printer N78) ThaRez Linux - Hardware 0 04-15-2014 03:44 PM
[SOLVED] How to set printer options when printing from Linux to Windows printer r_ranasinghe69 Linux - General 2 06-27-2011 12:54 AM
HP Laserjet 2300 dn printer (Internet Printer) keeps on printing multiple copies mayurmvegad Linux - Networking 0 09-15-2008 02:35 AM
printing to xp printer... moschi Linux - Newbie 3 03-30-2004 02:33 AM
keeping printer on at bootup keeps printer from printing (some printer modules loaded TheOneAndOnlySM Slackware 1 10-17-2003 07:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 02:39 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