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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Create a text file and a pdf file from Linux command results.
# 1  
Old 12-27-2019
Create a text file and a pdf file from Linux command results.

Hello.


The task :
Using multiple commands like :
Code:
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 :
Code:
#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 :
Code:
 while true ; do
echo "$SOME_TEXT_AS_TITLE" >> "$BASE_FILE" gdisk -l $SOME_DISK >> $BASE_FILE if [[ "$FLAG_SET_PAGE_BREAK" == "true" ]] ; then
echo ".bp" >> "$BASE_FILE"
fi if [[ "$IS_FINISHED" == "true" ]] ; then
break
fi
done echo ".ex" >> "$BASE_FILE"

Then I build the pdf file like this :
Code:
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 :
Code:
.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.
# 2  
Old 12-28-2019
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.
This User Gave Thanks to jgt For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Setting Password For PDF File--Linux

Hi, I am in need of help. My requirements are : 1) To convert the existing files (irrespective of their format) in a directory to PDF format 2) To make the converted files password protected. I did the attempt to do the same. Though the existing files (irrespective of their format) are... (1 Reply)
Discussion started by: MKR
1 Replies

2. Shell Programming and Scripting

Create invoice pdf file

Hi all, I'm trying to create a script to merge a csv or txt file with a pdf template. So i have a pdf template with company logo and i want to merge it with a csv or txt file so i can create a complete invoice in pdf. now i do find some command line tools to do this but i need a pro version... (3 Replies)
Discussion started by: dicenl
3 Replies

3. Shell Programming and Scripting

Create a file from ls -l command and append additional info to results

I need to be able to take the results from ls -l command and modify the output as follows: I will run ls -l *.mak My results will be aa.mak bb.mak cc.mak I then need to take those results and create a file that has the following info: dsjj/ubin/aa dsjj/ubin/bb dsjj/ubin/cc ... (3 Replies)
Discussion started by: jclanc8
3 Replies

4. Red Hat

create pdf of text file help

Can someone please tell me why this is not working? I have created numerous pdf's from text files by following these instructions and this time it is not working. Convert jpeg files to PDF under Linux | bitPrison.net convert /home/liveuser/Documents/hw7 /home/liveuser/Documents/hw7.pdf... (5 Replies)
Discussion started by: cokedude
5 Replies

5. UNIX for Dummies Questions & Answers

Text file + image/form/overlay file to PDF

Hi, We have an app specific legacy environment running SCO Openserver 5.0.7. I need to be able to (1) scan a pre-existing “form” consisting of logo/boxes/lines/static text as an image , (2) lay a print file from the app "on top of the image" and (3) output the "merge" as a PDF file. Scanning... (1 Reply)
Discussion started by: 65bit
1 Replies

6. Shell Programming and Scripting

Print some results in a text file using script in linux

hello everyone, i really need your help to write a script which would just print following kind of result into a text file (result.txt) XYZ test Results ID: <unique-id> Date: <date> ------------------------------------------------- | Task | Result | Time |... (3 Replies)
Discussion started by: viriimind
3 Replies

7. HP-UX

Convert text file into pdf on HP-UX platform

I am looking for a tool to convert text file into pdf on HP-UX platform. Current version of OS - $ uname -a HP-UX XXXXXXX B.11.23 U ia64 4125393404 unlimited-user license I'm able to get "ClibPDF-2.02"; A library for creating PDF files on HP-UX 11.00, PA-RISC 1.1 Not sure if... (2 Replies)
Discussion started by: mail4usr
2 Replies

8. SCO

Create a PDF file

Currently own an SCO OpenServer 6 system. Will like to know how to convert files printed to PDF so they can be sent to customers via e-mail. Ex. account statements. (4 Replies)
Discussion started by: RicardoM
4 Replies

9. Shell Programming and Scripting

Create multiple text file from a single text file on AIX

Hi I need to create multiple text files from onc text file on AIX. The data of text files is as below: ********************************************** ********************************************** DBVERIFY: Release 10.2.0.4.0 - Production on Tue Nov 10 13:45:42 2009 Copyright (c) 1982,... (11 Replies)
Discussion started by: lodhi1978
11 Replies

10. AIX

How convert PCL or PDF file to text in AIX

I need to conver a PCL or PDF file to text in AIX, and I don´t know how. (0 Replies)
Discussion started by: 10789
0 Replies
Login or Register to Ask a Question