Create a text file and a pdf file from Linux command results.

Hello.

The task :
Using multiple commands like :

gdisk -l $SOME_DISK >> $SOME_FILE

I generate some text file.
For readiness I must insert page break.
When the program is finished I want to convert the final text file to a pdf file.
When finished, I got two files : One text file and One pdf file.
When printing both, you cannot differentiate them.

What I have done :
I build a single groff base file by copying data :
First I initialize the base document with :

#echo ".nf" > "$BASE_FILE"
echo ".sp 1" >> "$BASE_FILE"
echo "PROGRAM : $MY_PROG" >> "$BASE_FILE"
echo ".sp 1" >> "$BASE_FILE"

Then I fill the base file with the result of :

 while true ; doecho "$SOME_TEXT_AS_TITLE" >> "$BASE_FILE"

gdisk -l $SOME_DISK >> $BASE_FILE

if [[ "$FLAG_SET_PAGE_BREAK" == "true" ]] ; thenecho ".bp" >> "$BASE_FILE"
fi

if [[ "$IS_FINISHED" == "true" ]] ; thenbreak

fi

done
echo ".ex" >> "$BASE_FILE"
 

Then I build the pdf file like this :

ENSCRIPT="--no-header --font=$CUR_FONT  --word-wrap"
export ENSCRIPT
/usr/bin/enscript -p"$TEMP_FILE"  "$BASE_FILE" 

/usr/bin/ps2pdf  "$TEMP_FILE"  "$FILE_OUT_PDF"

 

Problem N°1
The page break is always at line 67.
I tried to change page length with :

.pl 29.0c

With different value but the page break arise always at the same place.
So How to change the page break.

Problem N°2
I want to use different fonts type and size.
This will certainly affect the presentation of the document.
How to fix the problem of page breaks.

Problem N°3
How to set page length by lines/per page ?

Problem N°4
With enscript you can explicitly set page format, font, .....

--lines-per-page= ?

--margins=?:?:?:?

--font=?

--media=?

This may contradict the presentation of the document generated by groff.

Problem N°5
I have look after hundreds of web page and I have not found a good tutorial to help me is that task that should be simple.

Any help is welcome.

The groff dot directives do not have any effect with Postscript.
Assuming that you are using letter size paper and not A4, there are 72*11 points vertically on the page, reduce that to 720 for half inch top and bottom margins, and you need to specify an 11 point font with a one point gap to get 60 lines per page.
If you want to add font changes and graphics within the finished pdf document then you have to add Postscript code into the text.
There are two files README and README.ESCAPES that come with the full enscript package, but they end up in /usr/share/doc/enscript, at least on Linux Mint.

1 Like