Question
· Mar 26, 2018

Printing from Caché Terminal - is there any way to send bold characters to the Windows default printer?

I'm converting a DTM system to Caché and trying to use the Caché Terminal as the UI. I've come across and removed some DTM formatting for printed text that does not do anything in Caché (actually, it caused errors). The printed output to the default Windows printer ("|PRN|") has been working and the printed documents in text-only format look fine. I am testing on a low-end HP laser printer and a Brother laser. The client has done a print test to his own older HP laser from his Caché  instance and the text renders fine. Come to find out the client needs the bolding of certain text within printed output (not the entire document - certain words). This would be the only format change to the printed text. I cannot find a way to accomplish the limited bolding and send it to the printer. Any ideas? And if you might ask why I didn't address potential formatting issues in my requirements notes, well, that would be the same question I'm currently asking myself.

Thanks for any suggestions.

John

Discussion (5)1
Log in or sign up to continue

Hi John,

I think you can do it using mnemonics:

write /SGR(1),"bold",/SGR(0)," normal"

Probably the printer will not understand this, but you can define another mnemonic for the printer, sending the correct escape sequence to it

http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GIOD_intro#GIOD_intro_definemnemomic

and then use the |PRN| device with your mnemonic:

USE "|PRN|"::"^%PCL"

For example, if printer is PCL you should send:

%PCL
  quit
SGR(%1)
  if %1=1 write $c(27),"(s3" // Bold
  if %1=0 write $c(27),"(s0" // Normal
  quit

Thanks to Manel Trèmols and Stylianos Chalkiotis. This does not work. I can get bolding to work in a terminal emulator like PuTTy, but when I send to the default Windows printer, "|PRN|", the characters that are used to indicate bolding come through as those characters. Nothing is bold. A friend and former colleague with decades of MUMPS and Caché experience said this: "It almost sounds like the BOLD/Not BOLD stuff was probably a custom macro of some kind in DTM that permitted this capability. If you can look into what DTM does when it sees the BOLD command; there must be something for it to interpret it. You may need to tweak the SMP setting to get this to work." If anyone reading this knows the "trick" that DTM did to pass BOLD/NOT BOLD, please let me know.
Thanks.

There is no default %PCL.int as mnemonics for PCL printing in Caché.
So according to the link

http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GIOD_intro#GIOD_intro_definemnemomic

you have to write it yourself.

But before this interesting exercise find a document on the control codes for your "low-end HP laser printer and a Brother laser"

Your description is just to vague to google for it. you depend on the type an level of PCL.
I tried and got 2.46 million hits on bold printing for Brother Laser.
This one looked useful but I didn't read all 531 pages and I don't know your printer version.
https://www.brother.com.au/pdf/support/controlcodes/PCL_Tech_Manual.pdf

This looked most useful:

5.2.11. Selecting the stroke weight
Esc(s#B (27)(40)(115)#(66) <1Bh><28h><73h>#<42h>
 This command designates the stroke weight of the primary font.
Esc)s#B (27)(41)(115)#(66) <1Bh><29h><73h>#<42h>
 This command designates the stroke weight of the secondary font
 # is an integer between –7 and 7. A value of 0 signifies a medium stroke weight, negative numbers signify
thin or light stroke weights and positive numbers signify bold stroke weights.
 If you select a light or bold stroke weight the command will only have an effect if the font is available in one of the three font locations.

that means you should try first if your printer is covered:

set bold1on=$c(27,40,115)_7_$c(66)
set bold2on=$c(27,41,115)_7_$c(66)
set bold1off=$c(27,40,115)_0_$c(66)
set bold2off=$c(27,41,115)_0_$c(66)
;; let's test it

open prt use prt  write #
     
write !,"test1 " , bold1on, "text with bold1on ", bold1off, "text with bold1off",!
     write !,"test2 " , bold2on, "text with bold2on ", bold2off, "text with bold12off",!

write # close prt

from the description, it is not clear if 7 and 0 are characters or if this are binaries.
you may need to replace it with $c(7) and $c(0). 

once you know the codes you may decide how to make use of it. 

 

Hi John,

My sample was using PCL but I don't know what printer are you using.

First thing should be to know what escape sequence do you need to send to the printer for to get bold.

Escape sequences are different if printer is HP, Epson, etc...

My suggestion is to check first doing an open printer, use printer, write escape sequence text, close printer if printer is doing bold.

After to get the correct escape sequence, you can write a mnemonic routine for to get bold in terminal, printer1, etc.. without change your code.

You will need different mnemonic routines for different printer types.

Hope this helps

Manel