Re: Hello All!
Travis Beaty wrote:
> when printing from an MLE using Mr. Cuny's win32lib.ew,
> what should I end each "string" with in order to get the
> printer to perform a line feed?
No, that's the wrong approach. Imagine that the printer is a bitmap: you
have to position the string on the page at a specific location. Take a look
at how GENERIC.EXW works. The untested code I've hacked together should give
you some idea how it works.
Hope this helps!
-- David Cuny
integer charsPerLine, linesPerPage
sequence fontSize, printerSize
if getPrinter() then
-- pick a fixed width font
setFont( Printer, "Courier New", 10, Normal )
-- get the font metrics
fontSize = getFontSize( Printer )
-- get the size of a printer page
printerSize = getExtent( Printer )
-- how many characters can fit on a line?
charsPerLine = floor(printerSize[1]/fontSize[1])
-- how many lines can fit on a page?
linesPerPage = floor(printerSize[2]/fontSize[2])
-- start up the document
if startDoc( "My Print Job" ) then
-- top of page
line = 0
-- print until text is empty
while length( text ) do
-- get a line of text
if length( text ) < charsPerLine then
-- get remaining text
lineOfText = text
text = ""
else
-- get one line of text
lineOfText = text[1..charsPerLine]
-- remove from remaining text
text = text[charsPerLine+1..length(text)]
end if
-- position text on page
setPosition( Printer, 0, line*fontSize[2] )
-- write the text
wPuts( Printer, lineOfText )
-- move down one line
line += 1
-- at bottom of page?
if line > linesPerPage then
-- print page
if not endPage() then
exit
end if
-- start a new page
if not startPage() then
exit
end if
-- reset counter
line = 0
end if
end while
end if
-- end of document
endDoc()
-- release the printer
releasePrinter()
end if
|
Not Categorized, Please Help
|
|