Visit Our UNIX and Linux User Community


How to convert TXT to PDF in RHEL 6?

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat How to convert TXT to PDF in RHEL 6?
# 1  
Old 10-06-2015
RedHat How to convert TXT to PDF in RHEL 6?

Hello friends,

I need to convert ASCII text to PDF on RHEL 6 so I did the below and could generate PDF but it has lot of junk/special characters.

Code:
yum install enscript ghostscript

enscript -p output.ps input.txt

ps2pdf output.ps output.pdf

So I download latest source of Ghostscript (ver 9.18) and I'm able to see ps2pdf and other commands that I got after installing from the source (after compiling/installing etc.). How can I generate PDF from these utilities (or how can I generate PS file from them so I can later run ps2pdf?)?

Code:
[root@lnxtst01 bin]#  file *
dvipdf:      POSIX shell script text executable
eps2eps:     POSIX shell script text executable
font2c:      POSIX shell script text executable
gpcl6:       ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
gs:          ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
gsbj:        POSIX shell script text executable
gsdj:        POSIX shell script text executable
gsdj500:     POSIX shell script text executable
gslj:        POSIX shell script text executable
gslp:        POSIX shell script text executable
gsnd:        POSIX shell script text executable
gxps:        ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
lprsetup.sh: POSIX shell script text executable
pdf2dsc:     POSIX shell script text executable
pdf2ps:      POSIX shell script text executable
pf2afm:      POSIX shell script text executable
pfbtopfa:    POSIX shell script text executable
pphs:        POSIX shell script text executable
printafm:    POSIX shell script text executable
ps2ascii:    POSIX shell script text executable
ps2epsi:     POSIX shell script text executable
ps2pdf:      POSIX shell script text executable
ps2pdf12:    POSIX shell script text executable
ps2pdf13:    POSIX shell script text executable
ps2pdf14:    POSIX shell script text executable
ps2pdfwr:    POSIX shell script text executable
ps2ps:       POSIX shell script text executable
ps2ps2:      POSIX shell script text executable
unix-lpr.sh: POSIX shell script text executable
wftopfa:     POSIX shell script text executable
[root@lnxtst01 bin]#

Please advise, many thanks!!

---------- Post updated at 12:31 PM ---------- Previous update was at 11:54 AM ----------

Further investigation shows that output PDF has many lines with special control characters like \033 (escape sequences) like below

\033&k2G\033(s12h10V

Code:
$ file input.txt
input.txt:       ASCII English text, with escape sequences

So is there any possibility to remove those escape sequences from source text file OR using enscript command itself (which I used to convert TXT to PS)
# 2  
Old 10-07-2015
Did you try a2ps ?

If you don't have it, you can install using yum install a2ps
This User Gave Thanks to prvnrk For This Post:
# 3  
Old 10-08-2015
Have you tried pcl2ps. Your source document is a PCL5 print file.
This User Gave Thanks to jgt For This Post:
# 4  
Old 10-08-2015
Quote:
Originally Posted by jgt
Have you tried pcl2ps. Your source document is a PCL5 print file.
Excellent! You are absolutely right. I used this source file as PCL and able to generate PDF without any special/junk characters using gpcl6 from ghostpcl 9.18. But there's some small issue of getting more number of pages than source ( I tried 650 pages source file and it generated 810 pages of PDF). Few last lines of a page skipping to next page and pushing the next page further. Each page starts with a "Print Date" & "Page xxx" (in the first line). Can we use this pattern to adjust each page OR gpcl6 has any parameter that can define this? I tried few but no luck.

Could you please suggest any ideas on how to fix this?

Again, many thanks for your correct direction Smilie
# 5  
Old 10-08-2015
The page length is incorrect for the paper size. You need to set the top and bottom margins, and the printable lines per page so that the pdf file matches the original output.

Previous Thread | Next Thread
Test Your Knowledge in Computers #323
Difficulty: Easy
In most programming languages, the operator ++ is equivalent to the statement -= 1;.
True or False?

10 More Discussions You Might Find Interesting

1. Linux

Need software details that can convert PDF to PS

we have been trying to convert PDF into PS for one of the projects. Our PDF files are little big and we use PDFTOPS which takes long time to convert it and it's a freeware. Is there any licensed version of such kind of tool? Responses are really appreciated. (2 Replies)
Discussion started by: venureddy
2 Replies

2. Solaris

How to convert pdf file to txt?

Hello Unix gurus, I am learning unix. I have lots pdf data files. I need to convert them into txt files. Can you please guide me how to do that? Thanks in advance. Rao (1 Reply)
Discussion started by: raopatwari
1 Replies

3. Shell Programming and Scripting

Download pdf's using wget convert to txt

wget -i genedx.txt The code above will download multiple pdf files from a site, but how can i download and convert these to .txt? I have attached the master list (genedx.txt - which contains the url and file names) as well as the two PDF's that are downloaded. I am trying to have those... (7 Replies)
Discussion started by: cmccabe
7 Replies

4. Shell Programming and Scripting

.PDF and .TXT to .XML. Is it possible?

Hi! I need to realize this task. In folder i have such files: name1.txt name1.pdf name2.txt name2.pdf etc... I want to scan this folder, match files with same name (name1.txt with name1.pdf, name2.txt with name2.pdf) and create files name1.xml and name2.xml, based on it. i.e: i want... (13 Replies)
Discussion started by: optik77
13 Replies

5. Shell Programming and Scripting

convert solaris file to pdf

Hi Guys, How to convert a unix text file into pdf? Please Help!!!!!!!!!!!!!!!!!! Thanks (2 Replies)
Discussion started by: Phuti
2 Replies

6. Shell Programming and Scripting

Perl - Convert html to pdf - PDF::FromHTML

Hi, I am trying to convert html to pdf using perl module PDF::FromHTML, am getting the error as given below. not well-formed (invalid token) at line 2, column 17, byte 56 at C:/Perl/lib/XML/Parser.pm line 187 at C:/Perl/site/lib/PDF/FromHTML.pm line 140 The perl code is as given... (2 Replies)
Discussion started by: DILEEP410
2 Replies

7. HP-UX

pdftotext / PDF conversion to .txt binaries

Good day, I've been trying to look for a way to compile the Xpdf sources in our HP-UX server, but have been failing to do so because there is no GCC installed, and I don't have privileges to install GCC. I was looking for a functionality to convert PDF files to .txt, which is exactly like the... (2 Replies)
Discussion started by: mike_s_6
2 Replies

8. UNIX and Linux Applications

looking for convert rtf to pdf utility

Hello all i have server that needs to add the ability to convert rtf files to pdf what you recommend me to use ( not open office please ) its spouse to process lots of files . something i can wrap in code and use (2 Replies)
Discussion started by: umen
2 Replies

9. Windows & DOS: Issues & Discussions

convert pdf's to word

Does anyone know any good tools to convert a pdf to word, I can usually cut & paste without a hitch but I have a pdf that doesn't like that and surrounds text with lines as though a table or prints tables in miniscule text. It's only one pdf file so I'm reluctant to buy a product. (3 Replies)
Discussion started by: gefa
3 Replies

10. HP-UX

Convert PCL to PDF

We're looking for a program that can convert Text and PCL formats into a PDF. We're not looking to spend a fortune so my search so far has come up empty handed as everyone wants an arm and a leg. I found txt2pdf, but that doesn't support PCL formats. Any help would be appreciated. TIA (2 Replies)
Discussion started by: Randle2I
2 Replies

Featured Tech Videos