Thermal printer using GDI print directives
#1202
12 May 18 03:28 PM
|
Joined: Aug 2001
Posts: 2,645
Herman Roehm
OP
Member
|
OP
Member
Joined: Aug 2001
Posts: 2,645 |
I have just written a program to print a prescription label and receipt on a form used in a thermal printer. I've been testing it on a laser printer so as not to use up all my sample labels. The label is now done and prints perfectly on the laser printer. When tried on the thermal printer, it comes out upside down. I was hoping for a GDI print directive that would simply rotate the label 180 degrees, but am unable to find one. I have used this long in the past by sending an esc sequence to a laser printer before using GDI. Finally, my question is, can this be done with GDI print directives? Any help would be appreciated.
|
|
|
Re: Thermal printer using GDI print directives
#1203
12 May 18 03:50 PM
|
Joined: Jun 2001
Posts: 11,645
Jack McGregor
Member
|
Member
Joined: Jun 2001
Posts: 11,645 |
First off, I would have hoped that you had used APEX for your development testing so as not to use up all your laser paper and toner either! (I'm also curious as to how well the APEX display when the label printer is selected matches up to the actual labels. In theory it should have appeared upside down too.) Unfortunately there is no GDI command to rotate 180 degrees. Perhaps it wouldn't be too difficult to create another option on the //ORIENTATION command (//ORIENTATION,UPSIDEDOWN ?) Seems weird though for the driver to be out of sync with the physical printer - that seems like either a bug in the driver, or a setting that has accidentally been tweaked. There is a //ESCAPE directive that allows you to pass ESC sequences to the printer even when otherwise using GDI mode. So if you have the ESC command to rotate the orientation, perhaps that will do it?
|
|
|
Re: Thermal printer using GDI print directives
#1204
12 May 18 06:19 PM
|
Joined: Aug 2001
Posts: 2,645
Herman Roehm
OP
Member
|
OP
Member
Joined: Aug 2001
Posts: 2,645 |
Come to think of it, I did use APEX and to the best of my recollection, it matched up very well. It was a few days ago, and at my age...well you should understand now I'll look at it again next week and let you know more. I did print a lot on plain paper too. I don't like the //ESCAPE because it then becomes printer dependent. I also was wondering if the fact that the label is only 3 inches wide, when it was rotated by a new //ORIENTATION directive , if the right edge of the label would then become the left edge or would the 5.5 inch white space of an 8.5 inch form now be on the left and the label would print well off to the right? Does that even make sense?
|
|
|
Re: Thermal printer using GDI print directives
#1205
12 May 18 06:31 PM
|
Joined: Aug 2001
Posts: 2,645
Herman Roehm
OP
Member
|
OP
Member
Joined: Aug 2001
Posts: 2,645 |
By the way, the rollout for this is a month away if that helps on my request for a new //ORIENTATION directive
|
|
|
Re: Thermal printer using GDI print directives
#1206
12 May 18 07:34 PM
|
Joined: Jun 2001
Posts: 11,645
Jack McGregor
Member
|
Member
Joined: Jun 2001
Posts: 11,645 |
Now let's see... what were we talking about again? :rolleyes: Oh right, the thermal labels. Ok, by my thinking the printer driver should allow you to select the correct label size, which I take to be 3 inches by something. And in that case, it should look that way in APEX. If that's true, then it should eliminate the issue about where all the extra margin will go. As for implementing a new GDI directive, probably //ORIENTATION is too limited. The generic approach to handling rotations and other effects is to create a transformation matrix that transforms any coordinate (x1,y1) to a new coordinate (x2,y2). By adjusting the components of the matrix, it can support rotation (by any amount and around any point), reflection (for mirror image decals perhaps?), shear, translation, etc. For this we need 6 parameters, something like: //SETTRANSFORM,m11,m12,m21,m22,dx,dy where the translation from (x1,y1) to (x2,y2) is based on: x2 = (x1 * m11) + (y1 * m21) + dx y2 = (x1 * m12) + (y1 * m22) + dy For a simple 180 degree rotation around the center point of the page, I think the parameters would be: xc = ### ! center point x coordinate
yc = ### ! center point y coordinate
m11 = -1 ! cos(180)
m12 = 0 ! sin(180)
m21 = 0 ! -sin(180)
m22 = m11
dx = 2 * xc ! xc - cos(180)*xc + sin(180)*yc
dy = 2 * yc ! yc - cos(180)*yc - sin(180)*yc
//SETTRANSFORM,m11,m12,m21,m22,dx,dy Now aren't you glad you took trig in high school? p.s. As if that wasn't beautiful enough by itself, but adjusting the parameters, you could also handle the problem of rotating and shifting the printing area within a larger page, although you may need to crack open a a college math book to figure out the parameters for that!
|
|
|
Re: Thermal printer using GDI print directives
#1207
12 May 18 09:25 PM
|
Joined: Aug 2001
Posts: 2,645
Herman Roehm
OP
Member
|
OP
Member
Joined: Aug 2001
Posts: 2,645 |
Well, trig and math in general, was my favorite subjects back in the day in that one room schoolhouse. I’ll have to study this a little closer, but think that would certainly do the job. Please don’t spend any more time on this this weekend. Thank you so much 😊
|
|
|
Re: Thermal printer using GDI print directives
#1208
14 May 18 04:00 PM
|
Joined: Aug 2001
Posts: 2,645
Herman Roehm
OP
Member
|
OP
Member
Joined: Aug 2001
Posts: 2,645 |
I wasn't able to study this or even go to work today. :rolleyes: It does, however, appear to be exactly what we need. I would promise to not bother you for 3 months if you would add this feature, but I'd just be telling a fib It would be greatly appreciated, though.
|
|
|
Re: Thermal printer using GDI print directives
#1209
14 May 18 04:25 PM
|
Joined: Jun 2001
Posts: 11,645
Jack McGregor
Member
|
Member
Joined: Jun 2001
Posts: 11,645 |
Well, when you manage to get out of your rocking chair, here's a beta version to test the aforementioned //SETTRANSFORM command with ... ash-6.5.1635.0-w32-upd.zip ash65notes.txt
|
|
|
Re: Thermal printer using GDI print directives
#1210
14 May 18 04:34 PM
|
Joined: Jun 2001
Posts: 11,645
Jack McGregor
Member
|
Member
Joined: Jun 2001
Posts: 11,645 |
As for making flimsy promises, I'd settle for (and I can imagine several others actually looking forward to) your 15 minute lecture at the next Conference on the wonders of the new //SETTRANSFORM directive!
|
|
|
Re: Thermal printer using GDI print directives
#1211
15 May 18 09:56 AM
|
Joined: Sep 2002
Posts: 5,450
Frank
Member
|
Member
Joined: Sep 2002
Posts: 5,450 |
Couldn't you just turn the bottle upside down??!
|
|
|
Re: Thermal printer using GDI print directives
#1212
15 May 18 10:09 AM
|
Joined: Aug 2001
Posts: 2,645
Herman Roehm
OP
Member
|
OP
Member
Joined: Aug 2001
Posts: 2,645 |
You're so cute, Frank. Go back to your tapioca. My neighbor offered me more tapioca yesterday. I said no thanks For anyone interested in this, the changes to A-Shell work great, rotating the form nicely. I now have to figure a way to calculate the Y coordinate of the lowermost text printed on the form. In some cases this could be a barcode rotated 90 degrees centered in a rectangle not completely filling the rectangle. You can't include the white space as this causes the top of the label to be shifted down when rotated. This is my challenge now.
|
|
|
|
|