Label Printer Problem

For several years we have used a Xojo program to print labels on a Zebra TLP3842 printer by sendings an image the same size as the label to the printer. Last week, the company bought a new Zebra GX430t printer and the letters are all printed 3 times as tall as they should. Only a small portion of the top left corner is printed. Zebra support was not able to offer any help other than suggest I rewrite the label generator in their ZPL printer language. Both printers are 300 dpi and the printer drivers are set for no dithering or other adjustments. I send the image (pic) by

g = OpenPrinter(ps) if g = nil Then exit sub g.DrawPicture(pic,0,0,LabelWidth, LabelHeight)
where LabelWidth and LabelHeight are constants equal to the size of the label in pixels (dots?). I have tried both multiplying and dividing LabelWidth and LabelHeight by 3 with no difference in the output.

have you expermented with setting the MAXHORIZONTAL and MAXVERTICAL resolutions?
Just an idea… but if maybe if you divide the max vertical by 3 it might work…

just an idea to think about.

I just tried it. I get the same result with it set to 100 or 300.

Can you get it working from another program (like word) to fit the label at the right size?

try with this–> https://www.dropbox.com/s/yv1eui5gfpth6sl/example.xojo_binary_project?dl=0
in App.Open event put this code

app.UseGDIPlus = true

in the draw() method pay special attention to the line that says p.graphics.DrawString(desired_text,50,50)
there you put the x, y coordinates. I print using A4 sheet but maybe you will have to adjust to your sheet size

please let me know if it works

I tried Julian’s suggestion. I saved my Xojo picture as a .bmp file, opened it in Microsoft Paint and printed it. What should have been 63.1 mm wide came out 72.2 mm.

The project Nicolas offered printed as expected. Putting his code in my project and printing without a stock specified resulted in a slightly wider version of what should have printed, but no reduction in the size of text printed. I am thinking this is a bug in the Zebra driver as the older version for our older printer works fine.

Thank you for your suggestions. I will keep working on this but have been pulled off this job temporarily for a more pressing one.

Are you using Xojo 2017r1 on Windows by any chance?

g.DrawPicture(pic,0,0,LabelWidth, LabelHeight)

This is generally not quite a good idea… Think of the Graphics you get from OpenPrinter as just a “virtual layout”. With 2017r1 on Windows, you’ll always get a Graphics with 96 DPI.
If you then do a g.DrawPicture(a300DPI_Picture, 0, 0) it’ll turn out to be printed too big - obviously.

You should instead use all parameters of .DrawPicture:

Graphics.DrawPicture(Image as Picture, X as Integer, Y as Integer [,DestWidth as Integer ] [, DestHeight as Integer ] [, SourceX as Integer ] [, SourceY as Integer ] [, SourceWidth as Integer ] [, SourceHeight as Integer])

DestWidth/Height: set this according to the print-graphics-DPI. you may need to calculate these appropriately.
SourceWidth/Height: of your 300DPI-to-be-printed-Picture.

→ Draw your full-blown-hi-res-picture on the “virtual layout”.

e.g. if “pic” is the Picture you created that is representing the full paper-page:

Graphics.DrawPicture(pic, 0, 0, g.Width, g.Height, 0, 0, pic.Width, pic.Height)

I’m also thinking of a zebra driver bug
by using the ZPL priting commands, you get through the zebra driver, so don’t suffer the bugs.
also you can print from many platforms the same way.
this is a good idea, althought it implies some coding work.