Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Print to TXT file

  1. #1
    Join Date
    Jun 2008
    Location
    Windhoek, NAMIBIA
    Posts
    42

    Default Print to TXT file

    How do I create a printer / driver that prints to a TXT file that I can pull into a spreadsheet? I need to export data from an application that has no ASCII export ability.

    Stef

  2. #2
    Join Date
    Mar 2008
    Location
    Phuket, Thailand
    Posts
    27,109
    Blog Entries
    40

    Default Re: Print to TXT file

    Quote Originally Posted by stefaug View Post
    How do I create a printer / driver that prints to a TXT file that I can pull into a spreadsheet? I need to export data from an application that has no ASCII export ability.
    Hmmm... reads very messy ...

    You could try print to a postscript file (easy to do with Linux). Then have a custom program to go in and remove the zillions of custom post script formatting characters. There may be some sort of ps2txt or ps2txt program for Linux that helps in that regard, .... I don't know (you will have to surf on this).

  3. #3
    Join Date
    Jun 2008
    Location
    Windhoek, NAMIBIA
    Posts
    42

    Default Re: Print to TXT file

    WOuld not work with a stock file that has it's own funny characters in place.

  4. #4

    Default Re: Print to TXT file

    Most applications nowadays are well know. What application has the text? Is the text in a tabular form and do you want to put that into Excel or what have you? If you can print to a ps or pdf file, there are utilities out here that convert the text into something useful. Also Unix is loaded with simple utilities just for this purpose.

  5. #5
    Join Date
    Jun 2008
    Location
    West Yorkshire, UK
    Posts
    3,611

    Default Re: Print to TXT file

    A lot depends on the format of the file. Kate will open almost any file and if you have the patience you can often find the text embedded in it somewhere. I've managed to extract text from MS Works and Publisher files that way.

    Tedious but it gets you there.

  6. #6
    Join Date
    Jun 2008
    Location
    Windhoek, NAMIBIA
    Posts
    42

    Default Re: Print to TXT file

    I need to extract data from an application to port to another app. The data is the complete stock list, the debitor and creditor data, etc. The application deliberately does not cater for ascii data output (maybe in an attempt to "lock customers in"?)

    Once the data is out and in some ascii format, I will be able to manipulate it into a form that the other app can read.

  7. #7
    Join Date
    Jun 2008
    Location
    West Yorkshire, UK
    Posts
    3,611

    Default Re: Print to TXT file

    You haven't said what the application is or what export facilities it does have. Sometimes you can get an indirect export via a third program.

  8. #8
    Join Date
    Jun 2008
    Location
    Earth - Denmark
    Posts
    10,730

    Default Re: Print to TXT file

    does the application run native in Linux?

    does it print to a printer at all?

    will it 'print' to a file? in any format at all, or is all 'output' to a
    monitor?

    when you look at the data files (stock list, etc) with a plain text
    editor (like maybe kwrite, kate, emacs, vim, mc etc) can you see the
    text? is it in some kind of logical order....if so, someone (smarter
    than me) can probably write a Perl script to strip out all the
    non-ascii, control characters and etc....in fact, i'd guess if you
    google on the name of that application and some other stuff you might
    find someone else has already solved your problem....maybe google

    [appName] export ascii Perl

    good luck, let us know if you find _the_ solution is easier than writing
    a new printer driver..

    --
    DenverD (Linux Counter 282315)
    A Texan in Denmark

  9. #9
    Join Date
    Jun 2008
    Location
    Windhoek, NAMIBIA
    Posts
    42

    Default Re: Print to TXT file

    Sorry Denver, I failed to mention: It is cobol base application. You now in good ole unix it was so easy to just set up a printer (mkdev lp) and the go into the spool directory and take most of the script out and voila! - text file printer!

  10. #10
    Join Date
    Jun 2008
    Location
    Oklahoma, US
    Posts
    822

    Default Re: Print to TXT file

    stefaug wrote:

    >
    > Sorry Denver, I failed to mention: It is cobol base application. You
    > now in good ole unix it was so easy to just set up a printer (mkdev lp)
    > and the go into the spool directory and take most of the script out and
    > voila! - text file printer!
    >
    >


    Always interesting to watch the discussions...

    To set up a (temporary) text only printer in cups:

    - Install the 'cups-backend' package via yast
    - in a browser, open 'http://localhost:631' to access the built-in
    administration services for cups
    - When asked, the username/password is root and your current root password
    - Click on the 'Administration' tab
    - on the right, click on 'Edit Configuration File'
    - Add the following line, best if near the top of file

    FileDevice on

    - Save the changes, cups server will restart
    - On the left, should see 'Add Printer', click it.
    - Give it an appropriate name 'textonly', 'test1', 'savemylife', whatever.
    location / description are optional, click 'continue'
    - Device is 'Printing to any command via pipe' (we're going to change this
    actually) 'Continue'
    - in the 'Device URI' field, remove 'pipe' and enter the following:

    file:/home/user/filename

    - of course, substitute your proper username, and desired output filename as
    needed. Created/Written by root, thus can send it ANYWHERE!! BE CAREFUL
    NOT TO OVERWRITE IMPORTANT FILES!
    - 'continue'.... !
    - Make is 'raw', list is alphabetical... 'continue'
    - Model is 'Raw Queue...' ... 'Add Printer'
    - Should see 'Printer xxx has been installed successfully' briefly, then it
    goes to some options for the new printer. these may be ignored.
    - click on 'Printers' tab, find your new printer, click on 'Set as Default'.

    Some things to be wary of

    if program uses LPD to talk to printers, you will need to enable LPD
    connections in the cups global settings, found in Yast -> Hardware ->
    Printer -> Global Settings (on left) -> third option down, "enable LPD
    clients"

    the file: backend will overwrite the output file each time it's used, rename
    or move the created file before printing additional items.

    the output file is owned by root, you'll either need to be root, or change the
    ownership to view / edit it.

    this is a very simplistic solution. a better, long-term solution, would be to
    create a proper backend which would not overwrite files, so large batches
    could be printed. Please let me know if you need that, it's relatively
    simple to write, but lengthy to put here.

    Setting the printer as default is important, since most programs (especially
    lpd based) tend to just output to the 'default queue', usually 'lp'. you may
    want to name the new textonly printer 'lp' for exactly this reason.

    Remember to reset your default printer, or remove (or disable) this printer
    queue, so you don't "lose" documents you would really like to print. {Grin}

    Hope this helps, kinda lengthy.

    Loni
    lornix@lornix.com


    --
    L R Nix
    lornix@lornix.com

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •