Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Mar 24, 2017 9:04 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Sending esc codes to a parallel printer
PostPosted: Wed Feb 27, 2013 5:24 pm 
Offline

Joined: Wed Feb 27, 2013 4:57 pm
Posts: 7
Dear all:

I'm writing a program in Real Studio 2011 r4 (Win XP SP3) using a POS printer, an Epson TM-U220PB dot-matrix printer and I'm already printing on it via the g.drawstring (characters look very big but it´s working).

Now I need to send ESC CODES to change font and in general to have more control about the format of my printing. The problem is that I can't find anywhere an example of sending esc codes (epos) to a parallel printer from Real Studio! An example would be very appreciated.

I don’t need anything complicated; even direct printing would be great but need a way to send the codes to change the font/size.

I already used the PageSetupDIalog dialog to setup the printer; it works excellent with almost all of the parameters bot not with the font/font's size selection. When trying to configure the printer from window’s control panel it let me choose any font from the printer and even print a test page with it but it warns me saying that choosing fonts or changing the font size must be done from inside my application, not from the control panel, and it only could be done sending esc codes.

Please help me !


Top
 Profile  
 
 Post subject: Re: Sending esc codes to a parallel printer
PostPosted: Wed Feb 27, 2013 7:47 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
A) You don't need to send escape codes, just change g.TextSize and/or g.Bold. The windows driver will do the right thing.

B) If you want to print direct, you can declare into winspooldrv.dll.


Top
 Profile  
 
 Post subject: Re: Sending esc codes to a parallel printer
PostPosted: Wed Feb 27, 2013 8:26 pm 
Offline

Joined: Wed Feb 27, 2013 4:57 pm
Posts: 7
Timhare, thanks a lot for your suggestion.

Sincerely I don't have any idea about how to deal with "winspooldrv.dll", :( but first I'll try your g.TextSize idea because I don't really want to change the font, just the size. Actually when I print something from my aplication to the printer it uses a font size by default that allows me to print just ... let say about 20 characters long by line, but I need to fit 40 characters in an line and I know the printer is perfectly capable of doing that because I saw it when working with the old software that I'm replacing (developed by someone else in FoxPro I must say).

I don't have the printer with me right now but tomorrow's first thing in the morning I´ll try. I think that will do it.

Just another thing, do you know how to send a tab? I'm printing a 3 column listbox and I would like to keep that format, the first column is "Quantity", the second "Article" and the third is "Price", it's a restaurant ticket.

Thanks again ! :)


Top
 Profile  
 
 Post subject: Re: Sending esc codes to a parallel printer
PostPosted: Thu Feb 28, 2013 12:48 am 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
In RB, everything is graphics. Basically pixels. You specifiy the X and Y coordinates of everything. Everything with the same Y coordinate is on a line. Assuming the default 72 dots/inch, if you want 6 lines/inch, you would print a line and then add 12 (72/6) to the Y coordinate for the next line. To line text up on a "tab stop", use the same X coordinate for the data that goes in that column.

For example

Y = 12
X = 0
g.DrawString quantity, X, Y
X = 72 // 1 inch
g.DrawString description, X, Y
X = 252 // 3.5 inch
g.DrawString price, X, Y

Y = Y + 12 // next line
X = 0
g.DrawString quantity2, X, Y
X = 72
g.DrawString description2, X, Y
X = 252
g.DrawString price2, X, Y

Y = Y + 12
//etc


Top
 Profile  
 
 Post subject: Re: Sending esc codes to a parallel printer
PostPosted: Thu Feb 28, 2013 4:56 pm 
Offline

Joined: Wed Feb 27, 2013 4:57 pm
Posts: 7
Now I understand, I'm going to modify my program and I will do it this way. Thank you very much, really appreciated! Stay cool! 8)


Top
 Profile  
 
 Post subject: Re: Sending esc codes to a parallel printer
PostPosted: Mon Mar 04, 2013 2:50 pm 
Offline

Joined: Wed Feb 27, 2013 4:57 pm
Posts: 7
Dear friend timhare, I just wanted to thank you and to let you know that everything works as you told me. It's great! Just needed to use g.textfont = "PrinterFont" where PrinterFont is the font of the printer i want to use, in my particular case "FontB11" and NOT a font of the system (Helvetica, Arial etc.). This note just for the record in case someone else need to do the same and read this post.

Now I can keep working in my project.

Thanks again! 8)


Top
 Profile  
 
 Post subject: Re: Sending esc codes to a parallel printer
PostPosted: Mon Mar 04, 2013 7:30 pm 
Offline
User avatar

Joined: Sun Jan 25, 2009 5:11 pm
Posts: 576
Location: Guatemala, Central America
Tim helped me with the exact same problem 4 years ago.

// I think Tim is a bot
:lol:

_________________
Future RS guru.
Ride the world!


Top
 Profile  
 
 Post subject: Re: Sending esc codes to a parallel printer
PostPosted: Mon Mar 04, 2013 7:36 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
That does not compute.


Top
 Profile  
 
 Post subject: Re: Sending esc codes to a parallel printer
PostPosted: Sun Apr 07, 2013 12:10 am 
Offline

Joined: Wed Feb 27, 2013 4:57 pm
Posts: 7
Dear friend Timhare and all of you guys, hello again. I finished making my app for ticket printing for restaurant tables and I'm testing it since april 1st. It's working good, but today I had a big table (70 guys) and my program was not able to print the complete ticket, it printed about only 50 rows or so and noting more. The table's database had more than 100 rows. I think the problem is the size of the graphic objet I'm using to print, may be It's not long enough. Do you have any idea? Remember that it's difficult to know how long a ticket is going to be, and the database and the on-screen list displays all the rows perfectly to the end. It's just the printed ticket the one that doesn't prints complete, and I doesn't reports any error.

I thought that I could print lines indefinitely adding 12 points to the vertical coordinates and using drawstring for each row but it's not :( Please help.

Best regards.


Top
 Profile  
 
 Post subject: Re: Sending esc codes to a parallel printer
PostPosted: Sun Apr 07, 2013 2:37 am 
Offline

Joined: Mon May 30, 2011 12:56 am
Posts: 702
Quote:
oday I had a big table (70 guys) and my program was not able to print the complete ticket, it printed about only 50 rows or so and noting more. The table's database had more than 100 rows. I think the problem is the size of the graphic objet I'm using to print, may be It's not long enough. Do you have any idea? Remember that it's difficult to know how long a ticket is going to be


Yup.
This is still 'dos based printing thinking', in a way.
In a DOS application, where you sent codes to the printer which change font size, spool paper feeds, etc etc, you could just keep throwing words and carriage returns (hear that old 'typewriter' speak there?) until you finished.
On a dot matrix printer, paper just kept churning out.

In graphics based printing land you really DO need to be aware of where you have got to on the 'page'
You get a page sized graphic from the printer to print upon.

If all your text is the same size, then the number of line you can get on it is basically (page height / text height)

keep a count of how many rows you have produced so far (or how far down the page you are)
If you reach the bottom, you do g.nextpage and it prints the first page and gives you a shiny new one to play with.


Top
 Profile  
 
 Post subject: Re: Sending esc codes to a parallel printer
PostPosted: Sun Apr 07, 2013 7:45 pm 
Offline

Joined: Wed Feb 27, 2013 4:57 pm
Posts: 7
You are right Kermit, there's a way to figure out how long the ticket is going to be just counting the rows of the database I want to print and in my case just multiply that number of rows by 12 and I will know the lenght in pixels it's going to take.

Another thing you are right is that I could split the ticket in "pages" or many tickets but that's not what I would like to do. Can you imagine receiving in a restaurant a multipage ticket saying on top "1 of 3", "2 of 3", "3 of 3"?

The tickets are not always the same lenght, it depends on the quantity of items that it includes. The problem comes when a ticket is long, 80 or 100 rows for example ... there must be a way to print it in just one continuous piece of paper, question is HOW???

May be pre-calculating the requierd lenght and creating or resizing a special-custom-made-extra-large "g." object before drawing the items on it? Any suggestion will be VERY welcome :)

I really need help because this case (large tickets) is a common thing in my business because I receive medium size and large size groups very often.

Thanks 8)


Top
 Profile  
 
 Post subject: Re: Sending esc codes to a parallel printer
PostPosted: Sun Apr 07, 2013 9:48 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
The graphics object is sending a "page eject" when you close the printer, so my guess is that the printer is set to not do anything at page eject. So you can send a NextPage and just continue printing on the next logical page. The printer won't actually skip any distance down the paper.


Top
 Profile  
 
 Post subject: Re: Sending esc codes to a parallel printer
PostPosted: Mon Apr 08, 2013 1:23 pm 
Offline

Joined: Wed Feb 27, 2013 4:57 pm
Posts: 7
Dear Tim and Kermit, I'm speechless ... It simply worked excellent!

I included in my code a counter while printing each row and when the counter reaches 50 (rows printed), it uses a "g.NextPage" command and it just keeps printing, just as you guys said.

Simple, clean and elegant. Cheers to you guys! 8)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group