0

Is there any way to achieve this PDF output on Linux?
By this I mean the alternate blue/green bars, which used to be pre-printed on paper for dot-matrix printers. The guides/holes in the sides would be a nice bonus!

enter image description here

There is a program in Windows, HercPrt which produces this result, either from Hercules emulator or by a text to PDF converter. I'm looking for a CUPS virtual printer perhaps, to produce the bars, or a text to PDF converter, or even a template in LibreOffice. Other ideas are welcome of course.

Krackout
  • 103
  • 5
  • IMO it would be extremely hard to find something similar, you should check if you can run the software under Wine. – Arkadiusz Drabczyk Feb 25 '21 at 12:16
  • Thanx for the suggestion @ArkadiuszDrabczyk. I've already tried to run the converter on Wine, but I get `abnormal program termination`. – Krackout Feb 25 '21 at 15:32
  • I wonder if one could modify a laser printer to burn the holes in the paper? – Gerard H. Pille Feb 25 '21 at 16:51
  • 1
    It is a bit far fetched, but if you can run through a PostScript "printer", it should be possible to run some pre-printing code which creates page templates (or watermarks). Then use Ghostscript to create the PDF. You might look at some old documents about PostScript trickery. – Max Wyss Feb 26 '21 at 01:45
  • Can you provide information about the document format? Page size, lines per inch, etc. – Gerard H. Pille Feb 27 '21 at 15:19
  • I don't have a particular format in my mind; mainly A4, perhaps an occasional A3; lines per inch, something giving a reasonable screen and print quality, I can't tell what would that be. That's why I didn't answer initially, don't have any clues. – Krackout Feb 28 '21 at 14:35
  • Would you mind sharing why you'd want something that looks like a printout from a while ago? I've still got a matrix printer and some paper on which I could have done this much faster ;-) – Gerard H. Pille Feb 28 '21 at 15:10
  • Well, it helps readability on long printouts, even on screen; plus it's aesthetically pleasing! For my tastes of course. – Krackout Feb 28 '21 at 16:21

2 Answers2

1

Using Postscript, one can generate something like:

Pseudo Continuous Form

The "perforations" are round, but when converting the PDF to a JPG, they became square :-(. The text on the white background isn't bold either.

The output you see is created by a postscript program that follows. Don't look too close, it's my maiden postscript speech. It constructs a background (the contform procedure) at the beginning of each page, reads a text file (/tmp/passwd) and prints it at 6lpi on your default page format (in my case A4). To execute this script, start it with ghostscript (gs) or ghostview (gv). When you save the script as /tmp/contform.ps, then

gs /tmp/contform.ps

or

gv /tmp/contform.ps.

The script:

/CP /closepath load def
/MT /moveto load def
/LT /lineto load def
/S /stroke load def
/F /fill load def
/s 20 string def

/pw { currentpagedevice /PageSize get 0 get } def
/ph { currentpagedevice /PageSize get 1 get } def

.83 1 1 setrgbcolor

% 0 ph MT pw ph LT pw ph 36 sub LT 0 ph 36 sub LT CP F

/contform
{
  gsave
  .83 1 1 setrgbcolor
  ph -1 mul 72 0 {
    /i exch def
    ph i add
    dup
    12 exch MT
    dup
    pw 12 sub exch LT
    dup
    pw 12 sub exch 36 sub LT
    dup
    12 exch 36 sub LT CP F
    pop
  } for
  0 setgray
  ph -1 mul 72 0 {
    /i exch def
    /perf { 3 0 360 arc CP F } bind def
    ph i add 18 add
    dup 6 exch % left perforation center
    perf
    dup 36 sub 6 exch % 2nd left perforation center
    perf
    dup pw 6 sub exch % right perforation center
    perf
    dup 36 sub pw 6 sub exch % 2nd right perforation center
    perf
    pop
  } for
  grestore
} bind def

/bottom 12 def
/lineshow                      % (string) lineshow -
{ %def
        % works like show, but checks for bottom
        % of page and also moves current point
        % down one line after each call
        currentpoint exch pop % just the Y coord
        bottom lt { %if
                showpage
                contform
                12 ph 24 sub moveto % top of new page
        } if
        gsave show grestore
        0 -12 rmoveto          % down one line
} bind def

%list the /tmp/passwd file
/Courier findfont 10 scalefont setfont
0 setgray

contform
12 ph 24 sub  moveto
/datafile (/tmp/passwd) (r) file def
/buffer 256 string def
{ %loop
        datafile buffer readline { %ifelse
                 lineshow
        }{ %else
                 datafile closefile
                 exit
        } ifelse
} bind loop

showpage
Gerard H. Pille
  • 1,346
  • 1
  • 8
  • 8
  • It's going great! And since no need to convert to jpg from pdf, your solution provides 100% accuracy! How is this achievable? – Krackout Feb 28 '21 at 11:10
  • I've edited my answer, but it would help if you would answer my question about the document. – Gerard H. Pille Feb 28 '21 at 14:27
  • Let me know how you get on with this. Just tried this on my HP Smart Tank Plus 655, and it looks I need to account for some margins: a text line is missing between two pages and so is the right hand perforation. – Gerard H. Pille Feb 28 '21 at 15:20
  • It works! Some notes: No Unicode, I tried some Greek text, garbage output. I don't have a printer available now, so I'm using pdf output. I had to change `-dSAFER` to `dNOSAFER` in `ps2pdf` script, to produce the pdf file. If input text file has longer than page lines `ps2pdf` produces errors. I had to insert line feed to get pdf output. Also I'd prefer bigger fonts, for example two lines of text per colour row and yes, some margins, left-right, would be welcomed. Perhaps adding some comments in your code to locate where to change these settings. I haven't noticed missing text line. – Krackout Feb 28 '21 at 16:17
  • The initial goals are accomplished so I accepted the answer, yet if you have any idea especially for Unicode it'll be more than welcomed! – Krackout Feb 28 '21 at 16:23
  • Please add a couple of sample texts to your question, preferably a bit more than a single page. Greek and Unicode may depend on selecting the correct font, Courier certainly can't handle those. I'll start by adding comments and trying to solve the margins problem. "two lines of text per colour row" would mean changing 6lpi to 4lpi (never heard of). Only this line needs changing: "0 -12 rmoveto". Hint: 72 points = 1 inch. – Gerard H. Pille Feb 28 '21 at 20:12
  • I prefer not to add a sample text 2 pages long in the question, it'll probably confuse possible future readers. On the other hand, it's easy to locate some text for testing. If you want it to try greek, copy `αβγδ ΑΒΓΔ`. I'll experiment with sizes and fonts. Thanx for staying around! – Krackout Mar 01 '21 at 16:40
1

...By the way - the printout on that picture is not from a dot-matrix printer. That is either a Chain, Train, or Band printer. They were high-speed impact printers you'd used by mainframe computers... https://www.pcmag.com/encyclopedia/term/chain-printer Not that it matters for the paper or your virtual printout, but I thought I'd make a comment ;)

Braino
  • 41
  • 1