[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1557
  • Last Modified:

customizing fonts in Dbase/Clipper

I would like to know how to choose font sizes when printing using Dbase code compiled with Clipper in DOS environment.

 thanks
0
Chuckbuchan
Asked:
Chuckbuchan
  • 4
  • 2
  • 2
  • +1
3 Solutions
 
JesterTooCommented:
You need to "embed" the printer codes within your stream of data going to the printer (or to a file if you choose to create the printer output in a file before sending it to the actual printer/printer queue).  Here's a fragment from an old program I wrote long ago that demonstrates the technique using printer codes for an HP Laserjet.  Most of these codes aren't "font sizes" but the technique is the same.  If you need to support more than one kind of printer, then you should obtain/build a dbf of the various printers and their codes that you need instead of hard-coding them into your app as my demo does.  There used to be several of these freely available on the web.  You probably can still find one or two at  http://www.the-oasis.net/


// value of HP LaserJet printer
local reset     := chr(27) + "E"
local letter    := chr(27) + "&l2A"
local port      := chr(27) + "&l0O"
local topmarg   := chr(27) + "&l3E"
local lftmarg   := chr(27) + "&l0L"
local txtlnth   := chr(27) + "&l66F"
local roman8    := chr(27) + "(8U"
local courier   := chr(27) + "(s3T"
local fixedfont := chr(27) + "(s0P"
local cpi10     := chr(27) + "(s10H"
local cpi17     := chr(27) + "(s16.67H"
local lpi6      := chr(27) + "&l6D"
local boldon    := chr(27) + "(s3B"
local boldoff   := chr(27) + "(s0B"
local italon    := chr(27) + "(s1S"
local italoff   := chr(27) + "(s0S"

   set printer to ( cPrintFile )
   set printer on
   set device  to printer
   set console off
   set margin  to 0

   // initialize printer mode...
   ?? reset + port + letter + topmarg + lftmarg + txtlnth + lpi6 + roman8 + courier + fixedfont + cpi10

   // begin reading Claims and creating report...
   use Claims new
   Claims->( ordsetfocus( "SSN" ) )
   Claims->( dbgotop() )

   while !Claims->( eof() )
      ?? boldon
      ?? Date + "  " + Time
      ?? space(9)    + "WORKERS COMPENSATION SUMMARY"
      ?? space(10)   + "Claim: " + claims->claimnum
      ?;?
      ?? space(3) + "Employee: "
      ?? boldoff
      ?? transform( claims->empssn, "@R 999-99-9999" ) + "  "
      ?? boldon
      ?? space(3) + "DOB: "
      ?? boldoff
      ?? dtoc( claims->empdob ) + "  "
      .
      .
      .
      .
      Claims->( dbskip() )
   end

HTH,
Lynn
0
 
CarlWarnerCommented:
You have to know the Printer you will print to and the Control Code sequences to send to that printer which allows you to send numerous combinations where you can change fonts, change the pitch, do subscript, superscript, bolding, change page orientation from portrait to landscape and back, etc.

One example of an Escape code sequence to produce landscape orientation on standard HP PCL printers:

SET PRINT ON
?? CHR(27)+"&l1O"      &&  OR @ 0,0 SAY CHR(27)+"&l1O"
SET PRINT OFF

To set it back to portrait mode:

SET PRINT ON
?? CHR(27)+"&l0O"
SET PRINT OFF

Here is a pretty extensive link to HP PCL Commands:

HP LaserJet Series Printers - PCL Commands, Basic Page Formatting, and Font Selecti
http://h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?objectID=bpl02705

Obvious or not, if you have different printers and they don't support Hp PCL escape commands, you will have to hunt down similar codes specific to those printers at the printer manufacturer's web site.
0
 
ChuckbuchanAuthor Commented:
- AS far as I understood, clipper program depends on the Print device you are using, that means the commands may change from one type of printer to another.
- I noticed also you used chr(27) +
could you tell me what that means? does it have to be in front of every printing command?


Let's say I want the following sentence to be printed  in courrier type, font size 14, bold, Italic, and printed out in a landscape form.


" This is a font test"


thank you
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
CarlWarnerCommented:
CHR(27) is the equivalient of Escape (Esc).  That is why they call these the Escape commands.

Many non-HP printers still seem to support the HP PCL escape commands in their printer emulation mode.  But, there is no guarantee which printers have that and how compatible they are if they do.  You would have to check the non-HP printers you want to use.  Before laser printers came along, dot matrix printers were in wide use and Epson had the de facto standard for printer control commands.
0
 
CarlWarnerCommented:
With your printer set as the device and on, the simple depiction of this could be something like:

courier = CHR(27) + "(s3T"
cpi8 = CHR(27)  + "(s8H"
bold = CHR(27) + "(s3B"
italic = CHR(27) + "(s1S"
landscape = CHR(27) + "&l1O"

?? courier + cpi8 +bold + italic + landscape

You can mix and match, even within a single line if you wish.  Of coutse, the more you use, the uglier it gets. <s>  And don't forget to use the reset command when you're finished so the next printer user coming along is assured of not getting affected by your non-default settings.  Reset would be CHR(27)+"E" or <Esc> E.

Check out the documentation to get the combinations you may need:

HP LaserJet Series Printers - PCL Commands, Basic Page Formatting, and Font Selection
http://h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?objectID=bpl02705
0
 
JesterTooCommented:
In additon to the PCL command sets (there are more than one... PCL4, PCL5, PCL6, etc) there was/is also a couple of other polular printer command languages... Epson (again, multiple models) and IBM Proprinter.  Less common (except in the business environment) is the Xerox command language.  Many printers are capabile of emulating multiple command languages, often being able to do it "on the fly" such that they can be mixed within the same document being printed.

DOS apps (run from within a Windows Command window) will write their output to the PRN (lpt1) logical device by default.  They do not use the "Windows default printer" setting.  Instead, you need to issue the "NET USE  lpt1 \\server\printername /persistent:yes" command at the command prompt (one time... windows will retain the setting until you change it).

You can also specify more LPTx mappings so that multiple printers can be defined on multiple ports.  This gives you a bit more flexibility since you can "set printer to lptx" where x is 1, 2, or 3.  Even though Windows supports more lpt ports I don't think Clipper recognizes any above 3.

However, I always wrote my Clipper apps to capture the print commands to a file as the reports were being produced.  Then, when the "report" was totally built I simply copied the file to the printer.  In a network environment this avoids the posibility of the print queue "timing out" due to long pauses in the app as it finds/builds the next piece of data to be printed and causing the printer to produce incomplete pages (with the possibility of other user's output interspersed between the pages of your own report).  Also, you can archive the file if desired and use it to print more copies, or partial copies, if needed.

Another possibility I've seen used is to simulate how Windows programs deal with printing... instead of using actual printer codes make up a set of "pseudo" codes for each of the real codes shared by any of the printers you're targeting.  Capture the report data with the pseudo codes to a file.  Then, instead of a simple "copy file to prn" (or any of its equivalents) process the file through another program that finds each pseudo code and substitutes the correct "real" code for whichever printer the user chooses (from a menu) and print the line normally.

Finally, you can avoid the entire problem with DOS printing in Windows environment by switching from Clipper to a Win32 equivalent compiler such as xHarbour ( free from http://www.xharbour.org/ ).

HTH,
Lynn
0
 
Jaime OlivaresCommented:
> I would like to know how to choose font sizes when printing using Dbase code compiled with Clipper in DOS environment.

I think your best alternative is to create an .HTML or .RTF files "by hand". Since both are really ascii text files, you can learn proper tags to give your text from simple to advanced formatting tags.
0
 
Jaime OlivaresCommented:
BTW. With my suggestion, you will need Windows to print them (with Internet Explorer or Worpad applications, respectively)
0
 
ChuckbuchanAuthor Commented:
though you said somewhere above that:
- CHR(27) is the equivalient of Escape (Esc), but Ijust wonder what 's the  functionality of it.
- As for Clipper programmer, are the last version fo Clipper has web application capability? and is it a client/server application?  I know that foxpro uses DBase/Clipper language, but I don't know which of them(Clipper Or Foxpro) is more powerfull in the modern world.


0
 
CarlWarnerCommented:
The escape part is just a trigger to the printer to tell the printer what follows are specific instructions.

I personally use Visual FoxPro 9 at this moment.  This particular version was released in December of 2004 and is really a nice piece of work.  I currently am using what is called Web Connection to do web work on the cheap where I can query .dbf data right on a live server to actively populate web page requests.

Visual FoxPro Home Page
http://msdn.microsoft.com/vfoxpro/

Microsoft® Visual FoxPro 9.0 Professional (from FoxToolBox.com)
http://www.foxtoolbox.com/itemgroup.dbx?sku=340-01230

West Wind Web Connection
http://www.west-wind.com/

Web Connection
http://www.west-wind.com/webconnection/

Internet enabling Visual FoxPro applications
http://www.west-wind.com/presentations/internetenabling/InternetEnabling.htm
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now