Sponsored Content
Top Forums Shell Programming and Scripting Create a text file and a pdf file from Linux command results. Post 303042514 by jcdole on Friday 27th of December 2019 01:25:22 PM
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.
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
CGI::Pretty(3pm)					 Perl Programmers Reference Guide					  CGI::Pretty(3pm)

NAME
CGI::Pretty - module to produce nicely formatted HTML code SYNOPSIS
use CGI::Pretty qw( :html3 ); # Print a table with a single data element print table( TR( td( "foo" ) ) ); DESCRIPTION
CGI::Pretty is a module that derives from CGI. It's sole function is to allow users of CGI to output nicely formatted HTML code. When using the CGI module, the following code: print table( TR( td( "foo" ) ) ); produces the following output: <TABLE><TR><TD>foo</TD></TR></TABLE> If a user were to create a table consisting of many rows and many columns, the resultant HTML code would be quite difficult to read since it has no carriage returns or indentation. CGI::Pretty fixes this problem. What it does is add a carriage return and indentation to the HTML code so that one can easily read it. print table( TR( td( "foo" ) ) ); now produces the following output: <TABLE> <TR> <TD> foo </TD> </TR> </TABLE> Tags that won't be formatted The <A> and <PRE> tags are not formatted. If these tags were formatted, the user would see the extra indentation on the web browser caus- ing the page to look different than what would be expected. If you wish to add more tags to the list of tags that are not to be touched, push them onto the @AS_IS array: push @CGI::Pretty::AS_IS,qw(CODE XMP); Customizing the Indenting If you wish to have your own personal style of indenting, you can change the $INDENT variable: $CGI::Pretty::INDENT = " "; would cause the indents to be two tabs. Similarly, if you wish to have more space between lines, you may change the $LINEBREAK variable: $CGI::Pretty::LINEBREAK = " "; would create two carriage returns between lines. If you decide you want to use the regular CGI indenting, you can easily do the following: $CGI::Pretty::INDENT = $CGI::Pretty::LINEBREAK = ""; BUGS
This section intentionally left blank. AUTHOR
Brian Paulsen <Brian@ThePaulsens.com>, with minor modifications by Lincoln Stein <lstein@cshl.org> for incorporation into the CGI.pm dis- tribution. Copyright 1999, Brian Paulsen. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Bug reports and comments to Brian@ThePaulsens.com. You can also write to lstein@cshl.org, but this code looks pretty hairy to me and I'm not sure I understand it! SEE ALSO
CGI perl v5.8.0 2002-06-01 CGI::Pretty(3pm)
All times are GMT -4. The time now is 08:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy