1

Is there any option for vertical text alignment within a line in Enscript?

I have to align the text in the vertical middle of the background. bggray

The text script:

push (@parts_section_array, sprintf(border("#")."%4s".'~bggray{0.85}'." Part Number %9s  Description %16s Qty. ". '~font{DejaVuSansMono-Bold10}' ."Unit Price  Ext. Price %4s Cost".'~font{default}~bggray{1.0}'." ".border("|")."\n",
                                    "", "", "", ""));

Or text is:

~bggray{0.85} Part Number       Description      Qty. ~font{DejaVuSansMono-Bold10} Unit Price  Ext. Price  Cost ~font{default}~bggray{1.0}

Enscript code:

 enscript -q \
    -f DejaVuSansMono@10 \
    -e~ \
    --no-header \
    -s 4.3 \
    --margins=10:2:14:10 \
    -L 73 "${pi}" \
    -o - \
| ps2pdf - "$BOOK_DIR"/"${filename}.pdf"
  • Maybe you should consider using a typesetting system like [Tex](https://en.wikipedia.org/wiki/TeX)/[LaTeX](https://en.wikipedia.org/wiki/LaTeX) which handles handles [tables and backgrounds](https://www.overleaf.com/learn/latex/tables#Colouring_a_table_.28cells.2C_rows.2C_columns_and_lines.29) very well. – Freddy May 07 '19 at 07:14

1 Answers1

1

If you find no other way, you can always edit the PostScript that is generated. My version of enscript puts at the start of the output the definition of the bgs function that is called to draw the background:

/bgs {  % x y height blskip gray str -> -  show string with bg color
  /str exch def
  /gray exch def
  /blskip exch def
  /height exch def
  /y exch def
  /x exch def
  gsave
    x y blskip sub str stringwidth pop height Box
    gray setgray
    fill
  grestore
  x y M str s
} def

You need to change the line x y ... Box in order to raise the y co-ordinate of the box, for example by height*0.2 so that it is:

x y  height .2 mul add  blskip sub str stringwidth pop height Box

Do this by adding a sed script in the pipe before the ps2pdf:

enscript ... |
sed '/^\/bgs /,/^}/{
       /x y blskip/s//x   y height .2 mul add   blskip/
    }' |
ps2pdf ...

Your enscript might generate a slightly different definition, so do compare them first.

meuh
  • 49,672
  • 2
  • 52
  • 114