Page 1 of 1 1
Topic Options
#211923 - 2016-08-31 09:14 PM Printing
AlanDLaird Offline
Just in Town

Registered: 2009-02-01
Posts: 3
Loc: Canada
Has anyone tried to create a text file with embedded printer codes and then have that file printed to a windows printer?

Here is the code I was testing with which does not seem to work...

Break On
Color w+/b
Cls

; Printer Codes

$esc = Chr(27)
$norm = $esc + "(10U" + $esc + "(s0p10.00h12.0v0s0b0T" + $esc + "&d@@"
$cond = $esc + "(10U" + $esc + "(s0p16.67h8.5v0s0b0T"
$bold = $esc + "(s3B"
$italic = $esc + "(s1S"
$und = $esc + "&d0D"

$filename = "C:\Admin\KixPrint.txt"
Del $filename
If Open(1,$filename,5) = 0
$text = $norm + "Testing for " + $bold + " a laser Printer" + $norm Gosub PrintLine
$text = $norm + @DATE + " " + @TIME Gosub PrintLine
$text = $norm + "Normal" Gosub PrintLine
$text = $cond + "Condensed" + $norm Gosub PrintLine
$text = $bold + "Bold" + $norm Gosub PrintLine
$text = $italic + "Italic" + $norm Gosub PrintLine
$text = $und + "Underline" Gosub PrintLine
$text = $italic + $und + "Underlined Italic" + $norm Gosub PrintLine
$rc = Close(1)
?
? "Done..."
Sleep 2
Else
?
? "Cannot open $filename..."
Get $x
Endif

Exit


:PrintLine
$rc = WriteLine(1,$text + @CrLf)
Return



Thanks,

Alan

Top
#211924 - 2016-08-31 09:51 PM Re: Printing [Re: AlanDLaird]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Welcome to KORG, Alan!

I used a slightly different method:
 Code:
Break On
Color w+/b
Cls

; Printer Codes

$esc = Chr(27)
$norm = $esc + "(10U" + $esc + "(s0p10.00h12.0v0s0b0T" + $esc + "&d@@"
$cond = $esc + "(10U" + $esc + "(s0p16.67h8.5v0s0b0T"
$bold = $esc + "(s3B"
$italic = $esc + "(s1S"
$und = $esc + "&d0D"

$filename = "C:\Temp\KixPrint.txt"
Del $filename
If Open(1,$filename,5) = 0

  $text = $norm + "Testing for " + $bold + " a laser Printer" + $norm + @CRLF
  $text = $text + $norm + @DATE + " " + @TIME + @CRLF
  $text = $text + $norm + "Normal" + @CRLF
  $text = $text + $cond + "Condensed" + $norm + @CRLF
  $text = $text + $bold + "Bold" + $norm + @CRLF
  $text = $text + $italic + "Italic" + $norm + @CRLF
  $text = $text + $und + "Underline" + @CRLF
  $text = $text + $italic + $und + "Underlined Italic" + $norm + @CRLF

  Len($text) ' characters to write' ?

  $rc = WriteLine(1, $text)
  @SERROR ?

  $rc = Close(1)
  ?
  "Done..." ?
Else
  ?
  ? "Cannot open $filename..."
  Get $x
Endif

'File contains: ' ?
Display $Filename


Use LPT1: \\PrintServer\HPLJ4200m
@SERROR ?

Copy $Filename LPT1:
This worked fine! Note that I mapped the printer to a DOS identity, which allows a direct copy operation. All of the intended text formats printed correctly.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#211927 - 2016-09-01 12:40 PM Re: Printing [Re: Glenn Barnas]
AlanDLaird Offline
Just in Town

Registered: 2009-02-01
Posts: 3
Loc: Canada
Thanks Glenn. I forgot about having to set up LPT1: \:\)

Edited by AlanDLaird (2016-09-01 12:40 PM)

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1178 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.053 seconds in which 0.023 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org