Need to print to label printer with formatted text.

mechwarrior3

Well-known member
Joined
Dec 19, 2005
Messages
67
Programming Experience
Beginner
Hello everyone,

Here is the situation: I have a DYMO label printer. Currently, it is using 4" x 2.31" labels. I need to have my application print a label from this printer at the push of a button. This label needs to be formatted as such:

Arial, regular, size 36 (centered)
Arial, regular, size 10 ___________________________________________________________________________________________________________________________________________ Arial, regular, size 10
Then there will be four more lines below this one that will also be in two-column format like the above line (minus the slew of underscores).
I do not know how to do this. I have spent the last several hours trying to find out how to do this. If anyone knows how to do this or has any suggestions, I would greatly appreciate it. Thanks. :)
 
So, that whole Designer->Printer Setup thing. Amazing. I feel really dumb for not using that first. However, my first piece of data is in the Page Header and it still shows up about 3/4 of the way down the label. Why? The margins are now set correctly and the paper size is correct.
 
Is there a report header section on your report? If so, suppress that section.
I'm not sure what's going on here, but I would do the printing in the detail section of the report and suppress/fit to size all the other sections.
Does the printer work correctly when you use a different app to print from (ie MS Word). Test that out to see if it is a printer setting or a vb.net setting.
 
No matter where I put the text (details, page header, report header), it always prints to the same spot on the label. I did try some test text in Word and when I scaled the paper size down to the correct size, everything worked just fine. Text showed up where it should and everything.

It seems like this one field is the first field for the page no matter what and the page is starting too low on the label so I'm even losing some data because it is considered to be on the other page because the page starts printing so low on this label.
 
Try viewing the report in a crystal reports viewer, see if it looks correct there. There has to be a simple explanation here. Portrait -vs- Landscape?
If it looks good in the report viewer print it from there. If no, redesign the report. Does the viewer print it correctly?
Try printing to a regular printer. Does it look good there? Does it print in the upper left corner like a label?
We need to establish if it is in the report design or if it is in the printer settings, my guess is printer settings - Portrait -vs- Landscape.
 
In the viewer it looks near perfect. And it prints out almost perfectly from the viewer. What does it mean? Why does it not print correctly from the code and the .PrintToPrinter function?

Also, how can I print from the viewer programmatically with no input from the user? This interface I'm working on has to be able to do this at the push of a print button. I can't have a print dialog popping up.
 
Man, I haven't got a clue. Seems to me it would most likely be a matter of the printer defaults being picked up because they are not specifically defined before printing.

Lets see your code:

 
Last edited:
I actually got it fixed. I don't know how. This is what my code looks like now:

VB.NET:
[SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] crMargins [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] CrystalDecisions.Shared.PageMargins(23, 4, 394, 225)[/SIZE]
[SIZE=2][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] rpt1 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] CrystalReport1
rpt1.SetParameterValue("MfgLotNum", strMfgLotNum)
rpt1.SetParameterValue("MixLotNum", strMixLotNum)
rpt1.SetParameterValue("VDGross", lngVDStartAmt)
rpt1.PrintOptions.PrinterName = "DYMO LabelWriter 330 Turbo-USB"
[SIZE=2]rpt1.PrintOptions.ApplyPageMargins(crMargins)
[SIZE=2]rpt1.PrintToPrinter(1, [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][SIZE=2], 1, 1)
[/SIZE][/SIZE][/SIZE][/SIZE]

All of the other settings for the printer are set at the printer level, not within code.

I'm not using the Report Viewer anymore. I am able to send it directly to the printer. I can't tell you why it is working but it is. Now the only thing I need to try to do is set up the table in the Details section. I don't know how to set up a table on a Crystal Report just yet. It's just a 5 by 6 (row by column) so it's not a complicated table. I just don't know how to do it.
 
Whole Issue Resolved!

David,

Thank you very much for your help with this problem. You were very awesome sticking with me through all of my silly questions and issues.

I have been able to take care of everything that related to this problem now. I did a lot of the formatting manually in the Crystal Report designer. The only thing I really did in the code was map the parameters to my form's data and then named the printer, applied its margins and then printed it.

Thank you again, so much. Your help was greatly appreciated.

And John,

Thank you for your assistance early on. It actually was really helpful in teaching me how PrintDocument works and how to deal with printing with that. It also was the first method that I got semi-working. However, formatting was a huge issue with that one. Then there were all of the invalid settings. In any case. Thank you very much for your help too.

To both of you gentlemen, thank you very much. I really appreciate it. :)
 
You are very welcome. I have received a lot of help from this site over the past year or so, and I am glad to be able to give some back.

Great to hear you have it working.
I am a fan of Crystal reports, the software I worked on has over 80 reports generated (from purchase orders and shipping labels to balance sheets and time cards), so I have just about tried it all. If you ever need help, just ask. Good luck with the programming, may all your code be error-free.
 
Back
Top