LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 07-26-2016, 05:35 AM   #1
Casey
LQ Newbie
 
Registered: Feb 2007
Location: Durban, South Africa
Distribution: Ubuntu / Debian / Suse
Posts: 9

Rep: Reputation: 0
Need bold or clearer font when converting text file to PDF.


We are running legacy software on OpenSUSE 12.1 32-bit.
Unfortunately we cannot move onto a newer operating system as the software gives floating point exception errors and will not run.

Currently the legacy software will output files in text or HP PCL formats only. However I have yet to find a way to convert PCL to PDF.

So currently the software will create a plain text file which I then run through the CUPS-PDF printer to convert it to pdf using the following script:

{legacyreportsystem with plain text output} > example.txt
cat example.txt | lp -dCUPS-PDF -o cpi=18 -o landscape -o Resolution=1200dpi
cp /var/spool/cups-pdf/$USER/_stdin_.pdf $HOME/result.pdf
pdftk $HOME/result.pdf background $HOME/Inv_Template.pdf output $HOME/Invoice.pdf


This works fine but the default font is very light and hard to read.
Is there any way that I can make the font more bold?


So far my investigating has revealed the following:

It is impossible to change the default font in CUPS-PDF from Courier to Courier-Bold as that will have been ideal.

There is also no way of specifying in the lp command to make the font bold. I will be quite happy to change the DEFAULT font for the lp command in the entire system from Courier to Courier-Bold but I do not know how.

I also looked into using enscript to convert the text file to postscript and make it bold and then use pstopdf to create the pdf. My problem here is that there does not seem to be a way to disable the wrap feature in enscript. (My document is in landscape).

Note that I do not mind running the file through multiple filters and processes, i.e. does not have to be elegant.

Any help or ideas that could steer me in the right direction will be highly appreciated ...
 
Old 07-26-2016, 06:19 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Can you put a document through the CUPS-PDF which contains the correctly sized Courier-Bold text and will that work? If so, then find a way to convert the document you have, text or otherwise, to be using the correct font before you do the CUPS-PDF conversion.
 
Old 07-27-2016, 10:36 AM   #3
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
Hi there,

Welcome to LQ.

Have a look at GhostPCL at http://ghostscript.com/download/gpcldnld.html. It might be able to convert your PCL-format files to PDF.

Regards,

Clifford
 
1 members found this post helpful.
Old 07-27-2016, 10:56 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by Casey View Post
We are running legacy software on OpenSUSE 12.1 32-bit.
Unfortunately we cannot move onto a newer operating system as the software gives floating point exception errors and will not run.

Currently the legacy software will output files in text or HP PCL formats only. However I have yet to find a way to convert PCL to PDF. So currently the software will create a plain text file which I then run through the CUPS-PDF printer to convert it to pdf using the following script:
Code:
{legacyreportsystem with plain text output} > example.txt
cat example.txt | lp -dCUPS-PDF -o cpi=18 -o landscape -o Resolution=1200dpi
cp /var/spool/cups-pdf/$USER/_stdin_.pdf $HOME/result.pdf
pdftk $HOME/result.pdf background $HOME/Inv_Template.pdf output $HOME/Invoice.pdf
This works fine but the default font is very light and hard to read. Is there any way that I can make the font more bold? So far my investigating has revealed the following:

It is impossible to change the default font in CUPS-PDF from Courier to Courier-Bold as that will have been ideal. There is also no way of specifying in the lp command to make the font bold. I will be quite happy to change the DEFAULT font for the lp command in the entire system from Courier to Courier-Bold but I do not know how. I also looked into using enscript to convert the text file to postscript and make it bold and then use pstopdf to create the pdf. My problem here is that there does not seem to be a way to disable the wrap feature in enscript. (My document is in landscape).

Note that I do not mind running the file through multiple filters and processes, i.e. does not have to be elegant.

Any help or ideas that could steer me in the right direction will be highly appreciated ...
The enscript command has a flag to
From the enscript man page:
Code:
-c, --truncate-lines
Cut lines that are too long for the page. As a default, enscript wraps long lines to the next line so no information is lost. You can also use the --slice option which slices long lines to separate pages.
...and you can also specify the font using the "-f or--font-name" flag in enscript. The font specification name contains two parts: the name of the font and its size in PostScript points. For example, "Times-Roman12" selects the "Times-Roman" font with size 12pt (from the man page). So try CourierBold12.
So....
Code:
enscript -c -f CourierBold12 -p example.ps example.txt
ps2pdf example.ps example.pdf
...should work. Or, the ps2pdf command takes the same options as Ghostscript, which will let you specify a font.

But this:
Quote:
Originally Posted by Casey
Unfortunately we cannot move onto a newer operating system as the software gives floating point exception errors and will not run.
..is NOT good. This application needs to be updated ASAP. OpenSUSE is a short-development/release cycle system, and won't be supported for a long time, like other 'server grade' distros. Staying on old stuff isn't a good idea, ever.

Last edited by TB0ne; 07-27-2016 at 10:58 AM.
 
Old 07-27-2016, 11:00 AM   #5
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
Hi again,

If you prefer the plain text input file, one option might be to convert it to a simple markup language (like Markdown/ReStructuredText/etc) with some shell/perl code, and then convert that to PDF or LaTeX for printing using pandoc. You should be able to accomplish basic formatting like bold text this way.

Alternately you could probably just convert the text straight to something like LaTeX with a home grown filter ;-)

Good luck!
 
Old 07-28-2016, 12:52 AM   #6
Casey
LQ Newbie
 
Registered: Feb 2007
Location: Durban, South Africa
Distribution: Ubuntu / Debian / Suse
Posts: 9

Original Poster
Rep: Reputation: 0
Hi Everyone,

Thanks for all the advice.
Note that the objective is not to print it per say but rather to merge it with a pdf background that provides all the company logos and layouts.
Decided to use a2ps instead of enscript as it provides an option to designate chars-per-line and avoid the wrap/truncate problem I had with enscript.

I have come up with the following code:
{legacyreportsystem with plain text output} > example.txt
a2ps --output=$HOME/result.ps --prologue=bold --chars-per-line=165 --lines-per-page=40 --font-size=8 --no-header --landscape --columns=1 --borders=no $HOME/example.txt 2> /dev/null
ps2pdf $HOME/result.ps $HOME/result.pdf 2> /dev/null
pdftk $HOME/result.pdf background $HOME/Inv_Template.pdf output $HOME/Invoice.pdf

The font is now much more bold and easier to read and horizontally all is good with a font-size of 8.
My only real problem now is line spacing as the background template is based upon 6 lines per inch.
a2ps will scrunch all the lines up at the top of the page.

I have been sifting through the massive manual available from the command line with `info a2ps` but cannot find any way to designate line spacing!

Thanks again for the help.
Linuxquestions.org is just awesome!
 
Old 07-28-2016, 01:33 AM   #7
Casey
LQ Newbie
 
Registered: Feb 2007
Location: Durban, South Africa
Distribution: Ubuntu / Debian / Suse
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by cliffordw View Post
Hi there,

Welcome to LQ.

Have a look at GhostPCL at http://ghostscript.com/download/gpcldnld.html. It might be able to convert your PCL-format files to PDF.

Regards,

Clifford
Thank you for the heads-up on this.
It might just be what I need.
Will look into it right now.
 
Old 08-05-2016, 02:28 AM   #8
Casey
LQ Newbie
 
Registered: Feb 2007
Location: Durban, South Africa
Distribution: Ubuntu / Debian / Suse
Posts: 9

Original Poster
Rep: Reputation: 0
Just an update.
I got nowhere with either a2ps or with enscript.

However GhostPCL turned out to be just what I needed - thanks Clifford!

Here is my solution for posterity:

Simple Script:
{legacyreportsystem with PCL output} > $HOME/example.pcl
ghostpcl -o $HOME/output.pdf -sDEVICE=pdfwrite $HOME/example.pcl
pdftk $HOME/output.pdf background $HOME/Inv_Template.pdf output $HOME/Invoice.pdf

And here are the initialisation PCL codes that I used in my legacy system:
ESC,E, {Initialise}
ESC,&,l,3,O {Reverse Landscape}
ESC,&,a,0,L {Set left margin to 0}
ESC,&,s,1,C {Disable Line Wrap}
ESC,&,k,2,G {Line Termination = CR}
ESC,(,s,5,B {BOLD - Woohoo - The reason for all this}
ESC,&,l,6,D { 6 lines per inch }
ESC,(,s,19,H { 19 chars per inch }

Note: the ghostpcl command is the precompiled runtime from the link that Clifford supplied above that I just renamed and added to my path.

Thank you all.
 
  


Reply

Tags
cups, pdf, texttopdf



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem converting chm file to pdf rng Linux - General 1 01-24-2014 01:24 AM
how to print part of text of a text file in bold and color using shellscript swapna sree Linux - Newbie 25 07-12-2011 11:19 AM
Converting PDF to text, rtf doc format saurya_s Linux - Software 2 06-16-2005 01:48 PM
How to the text in mendrake clearer RunToFreeForFly Linux - Newbie 1 08-26-2004 06:12 PM
The reason for partitions becomes clearer & clearer... Nu-Bee Linux - General 2 11-27-2003 01:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

All times are GMT -5. The time now is 02:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration