Hot Topic (More than 10 Replies) Thermal Printing Tips (Read 1962 times)
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Thermal Printing Tips
Feb 18th, 2008 at 7:10pm
Print Post Print Post  
I'm fishing for tips on printing to a thermal printer.  I'm using a iTherm 280 via the USB port to print custom receipts.  I'm experiencing two problems:

1) For some reason, it generates an extended bottom margin.  But it only does this depending on how much I print to the printer.  i.e. if I print 30 lines to the printer, the printer spits out an extra 2" at the bottom.  But if I print 31 lines to the printer, it spits out an extra 6" on the bottom.  This generates a lot of paper waste.

2) I can't get long text to wrap properly.  It simply trails off the right side of the receipt.

I've tried tweaking a couple of different settings, including the NewPage() settings and the PrintPageMargin() settings, but have had no luck.  I've ended up leaving NewPage() to be 850, 1100, even though the paper is only 3 1/8" wide and I'm only printing 5 1/4" worth of data.  Right now, whenever I print, I get a 12 1/2" long receipt even though I only need around 6".

  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Thermal Printing Tips
Reply #1 - Feb 18th, 2008 at 7:15pm
Print Post Print Post  
What is the native resolution of the printer?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Thermal Printing Tips
Reply #2 - Feb 18th, 2008 at 7:20pm
Print Post Print Post  
According to the internet, the resolution of your printer is 203dpi, so you need to base your numbers on that res.

To define a "page" that is 3.125" by 6", try NewPage(634, 1218), which is 3.125 * 203 by 6 * 203.

You also want to choose your wrap size and font sizes based on 203dpi.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Re: Thermal Printing Tips
Reply #3 - Feb 18th, 2008 at 8:08pm
Print Post Print Post  
Hammer wrote on Feb 18th, 2008 at 7:20pm:
To define a "page" that is 3.125" by 6", try NewPage(634, 1218), which is 3.125 * 203 by 6 * 203.

When I try this, it starts printing exactly at the half way point of the width of the paper.  I guess I'm completely misunderstanding how NewPage controls the page layout.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Thermal Printing Tips
Reply #4 - Feb 18th, 2008 at 8:20pm
Print Post Print Post  
NewPage() creates a grid to position subsequent printing. If you use the NewPage I gave you, then printing something at 203, 203 should make it appear one inch from the left and one inch from the top since 203 units equals one inch. Printing at 101, 101 should be 1/2 inch from the left and 1/2 inch from the top.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Re: Thermal Printing Tips
Reply #5 - Feb 18th, 2008 at 9:14pm
Print Post Print Post  
Hammer wrote on Feb 18th, 2008 at 8:20pm:
NewPage() creates a grid to position subsequent printing. If you use the NewPage I gave you, then printing something at 203, 203 should make it appear one inch from the left and one inch from the top since 203 units equals one inch. Printing at 101, 101 should be 1/2 inch from the left and 1/2 inch from the top.

In practice, with this thermal printer, it doesn't work that way.  If I set it to (634,1218), printing at X=0 causes the printer to start printing at about the center of the receipt.  If I set it to (850,1100), printing at X=0 causes it to print at the left edge of the receipt.  I don't understand why the X=0 behavior is different simply because I changed the grid dimensions.  The nice thing was that the (634,1218) setting fixed the problem with the paper waste, but since it doesn't print to the left edge, it only solves one issue while creating another.  I'm sure it has something to do with how the USB driver for this printer handles the interface. But I've never dealt with thermal printers before this project, so I'm clueless here.  I suspect that you and the other good folks at Lantica probably don't have an easy answer to this, but I'm hoping...
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Thermal Printing Tips
Reply #6 - Feb 18th, 2008 at 9:18pm
Print Post Print Post  
I wonder if the printer has some sort of autoscaling or adjusts text that is outside its printable area. If you print something at 203, 203 where does it land?

Are the Y coordinates also misbehaving?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Re: Thermal Printing Tips
Reply #7 - Feb 18th, 2008 at 9:30pm
Print Post Print Post  
Hammer wrote on Feb 18th, 2008 at 9:18pm:
I wonder if the printer has some sort of autoscaling or adjusts text that is outside its printable area. If you print something at 203, 203 where does it land?

Unfortunately, the printer is at the client site, which I won't be back to now for at least a few days.  So it'll be a while before I can do any more hands on testing.

Hammer wrote on Feb 18th, 2008 at 9:18pm:
Are the Y coordinates also misbehaving?

They don't appear to be.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Thermal Printing Tips
Reply #8 - Feb 18th, 2008 at 9:35pm
Print Post Print Post  
This is probably going to be a case of messing with the width argument in NewPage() until the printer is happy. It sounds like adjusting the height argument took care of the paper length issue in a way that made sense. Now, we need to figure out what this thing is doing with the width. Try different numbers and see if you can find a width it likes.

You might also want to test to see if it is automatically centering what you give it. These little specialty printers can have all sort of built-in default behaviors that a normal page printer would not.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Re: Thermal Printing Tips
Reply #9 - Feb 19th, 2008 at 8:22pm
Print Post Print Post  
Well, I did take the time to go back to the client site and run some tests.  I setup a sample application so that I could quickly test.  And unfortunately, things regressed, so that now I'm always wasting paper.  I guess I'll have to chalk this up to a printer oddity.  What's really unusual is that the Y position varies depending on how much you print.  For example, if I set the NewPage to 850,1100 and then print to 0,1100, it only prints about two inches down.  But if I print at 0,700, 0,800, 0,900 , 0,1000 and 0,1000, it spaces out each thing evenly, except for the 0,0 to 0,700, which is only about double the spacing of between 0,800 and 0,900.

So the printer is apparently auto-adjusting in some manner.  But it doesn't say anything about doing it in the manual.  And the manual is geared towards sending custom codes, which is probably what the printer driver is doing after Sesame submits the document for printing.

Thanks attempting to help.

EDIT: Further digging into the printer manual allowed me to find an option that corrected the issue.  Thanks for helping me to better understand NewPage.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Thermal Printing Tips
Reply #10 - Feb 19th, 2008 at 8:56pm
Print Post Print Post  
MP wrote on Feb 19th, 2008 at 8:22pm:
EDIT: Further digging into the printer manual allowed me to find an option that corrected the issue.  Thanks for helping me to better understand NewPage.

Excellent! What was the option?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Re: Thermal Printing Tips
Reply #11 - Feb 19th, 2008 at 9:42pm
Print Post Print Post  
Hammer wrote on Feb 19th, 2008 at 8:56pm:
MP wrote on Feb 19th, 2008 at 8:22pm:
EDIT: Further digging into the printer manual allowed me to find an option that corrected the issue.  Thanks for helping me to better understand NewPage.

Excellent! What was the option?

There's an option called "Page Length" which sets the "default form feed page length".  Seemed obvious once I finally found it.  I turned the option off and everything worked fine using a NewPage of 850,1100.

The odd thing about this whole issue was how the printer reacted to the things I fed into it from Sesame.  Since it behaved differently based on different settings, and had a different form feed length depending on the printed output, it led me down the track of believing that the issue had to be a print configuration issue with the software and not a printer setting issue with the hardware.

In my prior software experience, I've rarely had to deal with peripherals.  I guess I should be glad.  What a headache.  I probably wasted a whole roll of thermal paper in an attempt to save paper.  And don't get me started on the headaches I had trying to resurrect a dot matrix printer.  Stupid government mandates...
  
Back to top
 
IP Logged