Find the answer to your Linux question:
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 24
Happy Christmas Eve. Perhaps this would work: Code: convert FILE.png FILE.ps and then use rastertohp on the FILE.ps? On my system convert can do postscript. But there's also the issue ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Linux User
    Join Date
    Dec 2011
    Location
    Turtle Island West
    Posts
    457

    Happy Christmas Eve.

    Perhaps this would work:
    Code:
    convert FILE.png FILE.ps
    and then use rastertohp on the FILE.ps?

    On my system convert can do postscript. But there's also the issue of making sure the image is the correct size for printing. I've used gimp to tweak the image size to what I want, then save as postscript. That worked nicely.

  2. #12
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,257
    Quote Originally Posted by Miven View Post
    Happy Christmas Eve.

    Perhaps this would work:
    Code:
    convert FILE.png FILE.ps
    and then use rastertohp on the FILE.ps?

    On my system convert can do postscript. But there's also the issue of making sure the image is the correct size for printing. I've used gimp to tweak the image size to what I want, then save as postscript. That worked nicely.
    I don't have convert, but I've found I can do exactly the same thing using the cups imagetops filter. I've just compared two prints of the same png file - one done using cups and the other using imagetops|gstoraster|rastertohp. They are identical. All the same it would be nice to be able to do it in two steps, not three.

    I am working on a script that will identify the type of a file by its suffix and carry out the necessary filtering operations so that a single command will print any file - just like the cups lp command!
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  3. #13
    Linux User
    Join Date
    Dec 2011
    Location
    Turtle Island West
    Posts
    457
    No convert? It's part of ImageMagick, very very handy and flexible with a gajillion command line options. I don't know what I'd do without convert, I use it all the time.

    Don't forget 'file' for identifying files if they have oddball extensions or none at all. You just have to parse the output a bit.

    # file bv3
    bv3: JPEG image data, JFIF standard 1.01

    Awesome that you're playing with the filters, I hadn't done that yet. I found imagetops and texttops in /usr/lib/cups/filter. They seem useful.

    imagetops works on png but not jpg:

    ERROR: Unable to open image file for printing!

    So I have to convert to png anyway, I might as well convert straight to ps. Otherwise it does a nice job, converts to grayscale automatically because my printer is monocrome laser.

    # convert FILE.jpg -geometry 516x800 -colorspace gray FILE.ps

    does the same thing, and I can control the output size. There's also 'identify':

    # identify bv3
    bv3 JPEG 307x476 307x476+0+0 8-bit DirectClass 37.5KB 0.000u 0:00.000

    texttops works great, but enscript works better IMHO. More flexible.

    # enscript -f "Courier@9" --no-header -o FILE.ps FILE.txt

    does a beauty job, and I can control the font/font size, print a header if I like, do word wrap, tons of options.

    I'm very glad you're making good progress avoiding CUPS.

    Peace and Cheer

  4. $spacer_open
    $spacer_close
  5. #14
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,257
    Quote Originally Posted by Miven View Post
    No convert? It's part of ImageMagick, very very handy and flexible with a gajillion command line options. I don't know what I'd do without convert, I use it all the time.
    Well in that case I'll install imagemagic in Slackbody. That's where I do graphical stuff when I need to.

    Don't forget 'file' for identifying files if they have oddball extensions or none at all. You just have to parse the output a bit.
    Yes, I'm working on a script that does that. The relevant lines are:
    Code:
    if [ -z $type ]; then
    if file $filename|grep -q text; then type=text
    elif file $filename|grep -q ps; then type=ps 
    elif file $filename|grep -q PDF; then type=pdf
    elif file $filename|grep -q image; then type=image
    fi
    fi
    if [ -z type ] echo "File type could not be found"
    imagetops works on png but not jpg:

    ERROR: Unable to open image file for printing!
    I get a different error. The conversion goes through with warnings about errors that were repaired or ignored, and imagetopdf producing output that doesn't correspond to Adobe standards. But the printer chokes on the file.

    texttops works great, but enscript works better IMHO. More flexible.
    # enscript -f "Courier@9" --no-header -o FILE.ps FILE.txt
    Yes, I'm thinking of installing that one on AntiX, which is where I do my text work.

    btw I cleared hplip, cups and all their orphan dependencies out of Slackbody and the disk usage went down from 76% to 59%!
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  6. #15
    Linux User
    Join Date
    Dec 2011
    Location
    Turtle Island West
    Posts
    457
    Cool. Pretty much the exact thing I did.

    I don't know if you use OpenOffice, but I have a macro and a little bash script called doc2pdf. It uses OO invisibly to turn MS doc files, and pretty much any other recognizable document format (sxw, odf, etc) into a PDF.

    # doc2pdf FILE.doc
    outputs FILE.pdf. Very handy. All you need is oowriter running somewhere, otherwise it seems to think really hard for a while and then segfault. Could be a bug in my version of OO(v1.1, pretty old).

    Here's the script:
    Code:
    #!/bin/sh
    
    DIR=$(pwd)
    DOC=$DIR/$1
                                                                                   
    /usr/bin/oowriter -invisible "macro:///Standard.Module1.ConvertWordToPDF($DOC)"
    
    exit 0
    
    cat << EOF
    #First, start up OpenOffice.org, perhaps as oowriter. Then, from the 
    #Tools menu, select Macros, Organize Macros, OpenOffice.org Basic.
    #A window will popup. Navigate, in the Macro from area, to My Macros, 
    #Standard, Module1. Click on Edit to edit the Main module to
    #include just the following code: 
    REM  *****  BASIC  *****
    
    Sub ConvertWordToPDF(cFile)
       cURL = ConvertToURL(cFile)
          
       ' Open the document.
       ' Just blindly assume that the document is of a type that OOo will
       '  correctly recognize and open -- without specifying an import filter.
    
       oDoc = StarDesktop.loadComponentFromURL(cURL, "_blank", 0, Array(MakePropertyValue("Hidden", True), ))
       Dim comps
       comps = split (cFile, ".")
    
       If UBound(comps) > 0 Then
           comps(UBound(comps)) = "pdf"
           cfile = join (comps, ".")
       Else
           cfile = cFile + ".pdf"
       Endif
    
       cURL = ConvertToURL(cFile)
    
       ' Save the document using a filter.
       oDoc.storeToURL(cURL, Array(MakePropertyValue("FilterName",
       "writer_pdf_Export"), ))
        
       oDoc.close(True)
                                                                      
    End Sub
    
    Function MakePropertyValue( Optional cName As String, Optional uValue
           ) As com.sun.star.beans.PropertyValue
       Dim oPropertyValue As New com.sun.star.beans.PropertyValue
       If Not IsMissing( cName ) Then
           oPropertyValue.Name = cName
       EndIf
       If Not IsMissing( uValue ) Then
           oPropertyValue.Value = uValue
       EndIf
       MakePropertyValue() = oPropertyValue
    End Function
    
    
    #Save and exit from OpenOffice.org.
    EOF
    
    #fin
    I cannot recall where I got it from. It was a rather intensive google-fest I know. Those macros are wacky. I've never been able to write one myself.

    btw I cleared hplip, cups and all their orphan dependencies out of Slackbody and the disk usage went down from 76% to 59%!
    Awesome. I should do that. I've never itemized how much disk space the stuff actually takes up, but I've compiled the stuff from source a couple times and still have the original rpms installed.

  7. #16
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,257
    I use Libreoffice which is pretty similar to OOo. But if I wanted to print something out of LO without using cups, I wouldn't file it as odt. I'd either export it as a pdf or, better still, use "print to file", which gives a postscript file directly.

    Your module is very clever but why not have your file in a printable format to start with?
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  8. #17
    Linux User
    Join Date
    Dec 2011
    Location
    Turtle Island West
    Posts
    457
    I've never used LibreOffice, I assumed it was just another name for OpenOffice. Actually, I just checked, it's a fork of OO started in 2010. Still way too new for my 2005 Mandrake10 system.
    I'd either export it as a pdf or, better still, use "print to file", which gives a postscript file directly.
    I agree that the results of 'print to file' work well, I just don't like the click-fest required to do it. It's fine if you only have to do it once, but if you have 8 documents to print, it's a pain opening each one, clicking around here there and everywhere. And also, 'print to file' doesn't automatically fill in a filename or use the current working directory, so I have to click-click-click to get into the correct dir, and then type the filename in and give it a ps extension. Like I say, it's an error-prone pain in the mouse. A lot of my filenames are like 'g1313_120222-151158.sxw' and stuff like that.

    ...but why not have your file in a printable format to start with?
    Well, my wife is no computer guru. She's a good writer, but she gets confused between PDF, doc, sxw, blah blah etc etc. So when I say, "Just export it as PDF and drop it in the spooler." her eyes kinda glaze over It's faster for me to grab it through nfs and print it (which will call doc2pdf if need be) myself. Then she can just keep writing and not break her stride trying to remember how to do it. Takes me 1 minute, takes her forever if her mind is on a different channel.

    Also, I have some programs than build their own fancy documents with tables and stuff from command line arguments with bash scripts, then doc2pdf them and print them automagically. It saves me a lot of time and effort.

    Peace and Cheer.

  9. #18
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,257
    I have now removed cups from AntiX as well; I have kept the cups-filters package, which includes most of the filters but unfortunately not the all-important rastertohp filter; that belongs to cups itself. Keeping it as an orphan means it will not be updated automatically. I shall have to keep my eyes open for new cups versions and update the file by hand when necessary.

    I attach the latest version of my print script, which I have named lp. It's not a daemon like Miven's because my circumstances are quite different. I am the only user of my computer and I only use my printer occasionally, so a simple user command is more appropriate.

    I originally hoped I could do the whole job with pipe-lined filters; that seems to me to be very much the Unix way. But that only really works for postscript files, so I have taken a leaf out of Miven's book and used utilities to convert everything to ps first.

    I'm glad I've dumped cups. I really hated it.
    Attached Files Attached Files
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  10. #19
    Linux User
    Join Date
    Dec 2011
    Location
    Turtle Island West
    Posts
    457
    Nice script. Simple and elegant. Shows off some good programs like a2ps, which, by the way, I just tried. I had tried it before but it failed. Probably something to do with that Fontmap issue. It does a lovely job. 2 pages per sheet and landscape by default it seems.

    I had to chuckle. That basename bit is actually snipping the extension off the filename. IMHO a faster and more elegant way to accomplish the same thing could be:
    Code:
    basename=${filename%.*}
    would grab 'file.tar' out of 'file.tar.gz'
    and to grab the extension:
    Code:
    short_extension=${filename##*.}
    long_extension=${filename#*.}
    would grab 'gz' and 'tar.gz' out of 'file.tar.gz' correspondingly.
    Built right into bash, fast as light, no pipes and echoes.
    Parameter Substitution

    This is awesome. You just replaced that CUPS monstrosity with a 42 line bash script, a few standard utilities, and a couple borrowed filters. That puts a smile on my face.

    And this, my dear linux compatriots, has got to be the #1 reason why I love linux: If you're fed up with something like CUPS, at least with linux you can do it yourself and learn something in the process, instead of just suffering the chronic headache brought on by badly designed software that wastes your time and does everything BUT what you want it to do.

    Peace and Cheer, and Happy New Year.

  11. #20
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,257
    Quote Originally Posted by Miven View Post
    I had to chuckle. That basename bit is actually snipping the extension off the filename. IMHO a faster and more elegant way to accomplish the same thing could be:
    Code:
    basename=${filename%.*}
    would grab 'file.tar' out of 'file.tar.gz'
    and to grab the extension:
    Code:
    short_extension=${filename##*.}
    long_extension=${filename#*.}
    would grab 'gz' and 'tar.gz' out of 'file.tar.gz' correspondingly.
    Built right into bash, fast as light, no pipes and echoes.
    Parameter Substitution
    Actually I've just realised I don't actually need the basename. That was part of an earlier scheme to determine the filetype from the suffix, but file does it much better. Your method is very neat though; I must admit I'm not familiar with the finer points of bash syntax.

    I'd like to turn this thread in a more philosophical direction. You can find flamefests on the Web about whether systemd is or is not "the Unix way", yet no one seems to be much concerned about cups. This package forms part of every Linux distro. It is a huge, complex Swiss army knife that interacts with practically everything else on your system. How can that be the Unix way?

    Cups is very convenient when it works but it is totally incomprehensible. Surely the preference for unthinking convenience over comprehensibility and simplicity is the way of Windows, not Linux. If I was the sysadmin for an office with several different printers, some networked, some local, I should be glad of cups, but for a home user, it's a sledgehammer used to crack a nut.

    Many distros have smaller, simpler alternatives for big complex desktops like gnome and kde; why aren't there small simple alternatives to cups? I mean, I know they exist - there's PDQ for a start - but why are they not in common use in distros?
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

Page 2 of 3 FirstFirst 1 2 3 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
  •