1

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.

8
  • IMO it would be extremely hard to find something similar, you should check if you can run the software under Wine. Commented Feb 25, 2021 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
    Commented Feb 25, 2021 at 15:32
  • I wonder if one could modify a laser printer to burn the holes in the paper? Commented Feb 25, 2021 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
    Commented Feb 26, 2021 at 1:45
  • Can you provide information about the document format? Page size, lines per inch, etc. Commented Feb 27, 2021 at 15:19

3 Answers 3

2

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
7
  • It's going great! And since no need to convert to jpg from pdf, your solution provides 100% accuracy! How is this achievable?
    – Krackout
    Commented Feb 28, 2021 at 11:10
  • I've edited my answer, but it would help if you would answer my question about the document. Commented Feb 28, 2021 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. Commented Feb 28, 2021 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
    Commented Feb 28, 2021 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
    Commented Feb 28, 2021 at 16:23
2

Somewhat late, but you can use this virtual line printer. https://github.com/racingmars/virtual1403

It was designed to emulate a real 1403 printer for Mainframes, to be used with the Hercules system, so serves as one of the output printers for emulated MVS or other mainframes OSs. The green bar paper size and design is the same as the real one. It handles directly EBIDC, but it has a stand-alone version (feature requested by me!) so you can feed any text file.

example of printed output from mainframe emulation

3
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Dec 14, 2023 at 19:50
  • Interesting! I'll have a look on it, specially since I've already got Go installed.
    – Krackout
    Commented Dec 16, 2023 at 7:46
  • Well that's nifty!
    – AJ Poulter
    Commented Apr 27 at 13:34
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 ;)

1
  • The OP didn't say the image was from a dot-matrix. Oh, you forgot the daisy-wheel? Commented Mar 16, 2022 at 16:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .