Printing text, image, text, image, ...

Printing text, image, text, image, ...

Post by William Par » Sun, 25 Jun 2006 09:01:01

I have bunch of text files (about 20 lines) and bunch of image files.
Is there a clean way to print text, then image, then text, then image,
..., as though there are in single continuous document?


ThinFlash: Linux thin-client on USB key (flash) drive
BashDiff: Super Bash shell


Printing text, image, text, image, ...

Post by Dances With Crow » Sun, 25 Jun 2006 10:07:10

["Followup-To:" header set to comp.os.linux.misc.]
On Fri, 23 Jun 2006 20:01:01 -0400, William Park staggered into the
Black Sun and said:

Quote:> I have [a] bunch of text files (about 20 lines) and [a] bunch of image
> files.  Is there a clean way to print text, then image, then text,
> then image, as though [they were a] single continuous document?


#!/usr/bin/perl -w
open(OFP,">temp.html") or die "cannot open temp.html: $!";
print OFP "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 ".
print OFP "<html><head><title> A title </title></head><body>\n";

# NOTE:  The glob() builtin may or may not help you out with that.
# Keep track of how many files you have, put that number in N.
# Deal With It if you have more images than text, or more text than
# images.  That's beyond the scope of this message.

for($i=0;$i<$N;$i++) {
    print OFP "<p>\n";
    open(IFP,$textfiles[$i]) or die "couldn't open ".$textfiles[$i].
         " : $!";
    while($line=<IFP>){ print OFP $line; }
    print OFP "</p>\n";
    print OFP "<img src=\"".$imagefiles[$i]."\">";
print OFP "</body></html>\n";
# end hackish Perl script temp.html in your favorite web browser, make sure it looks OK,
File->Print.  Modify the code to your taste in scripting languages if
you don't like Perl--this'd be fairly easy to do in Python or bash

Matt G|There is no Darkness in Eternity/But only Light too dim for us to see
Brainbench MVP for Linux Admin /    mail: TRAP + SPAN don't belong     /    "He is a rhythmic movement of the
-----------------------------/      penguins, is Tux." --MegaHAL


1. Use lpd/Samba to provide generic text print to text file for windows apps?

I would like to use linux to make an automated equivalent to the windows
"Generic/Text Only" printer, set to FILE: output. I have some clunky windows
apps that lack export features, so I want to capture their print output and
parse that in a print queue scenario.

I have been looking for documentation or a tutorial on the following:
1) whether I can use lpd to output a print job to a text file, instead of a
device. I'll need to do some scripting to give the output unique filenames
before handing postprocessing of the text file of to a daemon which would
monitor or be notified of the output.

2) whether some configuration of lpd can ignore everything in the print
stream besides ascii (or unicode). The windows text driver leaves some
garbage control characters in the output. Alternatively, I'd like to learn
how to write a 'print processor' that does this and more, since the windows
text driver often makes a mess of things trying to make layout decisions.

3) What would a Samba printer configuration supporting the above appear like
to a windows app? Is it a specific device (driver), or do I have to choose a
'real windows' printer driver (like an HP PCL) and Samba only provides the
\\host\share port?

Thanks for any info on any of the above questions you can provide.

2. Does XBF_i740 work with XFree86-

3. text and images just slightly blurry/fuzzy/ghosted in X (GeForce3, Redhat9, ViewSonic P95f+)


5. Adding graphical text to an image

6. Clean Linux install... how do I do this?

7. Embedding post-script images in troff text

8. mandrake 7.2 with secure kernel and /proc

9. How to capture a text console as an image into a file

10. Title Bar text for images

11. Q: How to convert text to image?

12. poor text and image on my laptop when running xwindow--help needed!!!!

13. overlaying text in an image (webcam)