473,378 Members | 1,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Unable to print on the specified location on Labels

Ned
I'm having difficulty printing on a 4"x3" labels . I set the left margin to
0 but it always prints starting from the middle of the label on the X-axis
(no matter what the margin settings are.) I should note that I was able to
view the label fine in the PrintPreviewDialog.
I checked similar posting but it didn't work for me. I have the following
code prior of calling the Print():

PaperSize CustomSize = new PaperSize("CustomSize", 400, 300);
printID.DefaultPageSettings.PaperSize = CustomSize;
printID.PrinterSettings.PrinterName = IDLabelPrinter;
printID.DefaultPageSettings.PaperSize.Width = 400;
printID.DefaultPageSettings.PaperSize.Height = 300;
Margins margins = new Margins(0,0,0,0);
printID.DefaultPageSettings.Margins = margins;
printID.Print();

then in the PrintPageEventHandler I have what suppose to print a circle in
the upper left corner with a text inside it but the output is in the middle
of the label:

float X = 0.0F; // x-coordinate of the upper-left corner
float Y = 0.0F; // y-coordinate of the upper-left corner
float circleWidth = 64.0F;
float circleHeight = 64.0F;
// Create start and sweep angles.
float startAngle = 0.0F;
float sweepAngle = 360.0F;
// Fill pie to screen.
e.Graphics.FillPie(FillBrush, X, Y, circleWidth, circleHeight, startAngle,
sweepAngle);

StringFormat drawFormat = new StringFormat();
drawFormat.Alignment = StringAlignment.Center;
Font printFont = new Font("Microsoft Sans Serif", 10, FontStyle.Bold);
Y = (float)(printFont.GetHeight(e.Graphics));
float Y2 = (circleHeight/2.0F) - (Y/2.0F);
X = circleWidth/2.0F;
e.Graphics.DrawString(BxTypelabel.Text,printFont,B rushes.White,X,
Y2,drawFormat);
Any help would be greatly appreciated.
Thank you

Nov 17 '05 #1
2 1905
Ned

The label prints fine now. I added some code that offsets the marginbound
to the printer's Real margin bound.
But what really made the difference is commenting the following code that
sets the papersize. Although that's the actual size of the label being
printed.

PaperSize CustomSize = new PaperSize("CustomSize",400,300);
printID.DefaultPageSettings.PaperSize = CustomSize;

Thank you

"Ned" wrote:
I'm having difficulty printing on a 4"x3" labels . I set the left margin to
0 but it always prints starting from the middle of the label on the X-axis
(no matter what the margin settings are.) I should note that I was able to
view the label fine in the PrintPreviewDialog.
I checked similar posting but it didn't work for me. I have the following
code prior of calling the Print():

PaperSize CustomSize = new PaperSize("CustomSize", 400, 300);
printID.DefaultPageSettings.PaperSize = CustomSize;
printID.PrinterSettings.PrinterName = IDLabelPrinter;
printID.DefaultPageSettings.PaperSize.Width = 400;
printID.DefaultPageSettings.PaperSize.Height = 300;
Margins margins = new Margins(0,0,0,0);
printID.DefaultPageSettings.Margins = margins;
printID.Print();

then in the PrintPageEventHandler I have what suppose to print a circle in
the upper left corner with a text inside it but the output is in the middle
of the label:

float X = 0.0F; // x-coordinate of the upper-left corner
float Y = 0.0F; // y-coordinate of the upper-left corner
float circleWidth = 64.0F;
float circleHeight = 64.0F;
// Create start and sweep angles.
float startAngle = 0.0F;
float sweepAngle = 360.0F;
// Fill pie to screen.
e.Graphics.FillPie(FillBrush, X, Y, circleWidth, circleHeight, startAngle,
sweepAngle);

StringFormat drawFormat = new StringFormat();
drawFormat.Alignment = StringAlignment.Center;
Font printFont = new Font("Microsoft Sans Serif", 10, FontStyle.Bold);
Y = (float)(printFont.GetHeight(e.Graphics));
float Y2 = (circleHeight/2.0F) - (Y/2.0F);
X = circleWidth/2.0F;
e.Graphics.DrawString(BxTypelabel.Text,printFont,B rushes.White,X,
Y2,drawFormat);
Any help would be greatly appreciated.
Thank you

Nov 17 '05 #2
Ned

The label prints fine now. I added some code that offsets the marginbound
to the printer's Real margin bound.
But what really made the difference is commenting the following code that
sets the papersize. Although that's the actual size of the label being
printed.

PaperSize CustomSize = new PaperSize("CustomSize",400,300);
printID.DefaultPageSettings.PaperSize = CustomSize;

Thank you

"Ned" wrote:
I'm having difficulty printing on a 4"x3" labels . I set the left margin to
0 but it always prints starting from the middle of the label on the X-axis
(no matter what the margin settings are.) I should note that I was able to
view the label fine in the PrintPreviewDialog.
I checked similar posting but it didn't work for me. I have the following
code prior of calling the Print():

PaperSize CustomSize = new PaperSize("CustomSize", 400, 300);
printID.DefaultPageSettings.PaperSize = CustomSize;
printID.PrinterSettings.PrinterName = IDLabelPrinter;
printID.DefaultPageSettings.PaperSize.Width = 400;
printID.DefaultPageSettings.PaperSize.Height = 300;
Margins margins = new Margins(0,0,0,0);
printID.DefaultPageSettings.Margins = margins;
printID.Print();

then in the PrintPageEventHandler I have what suppose to print a circle in
the upper left corner with a text inside it but the output is in the middle
of the label:

float X = 0.0F; // x-coordinate of the upper-left corner
float Y = 0.0F; // y-coordinate of the upper-left corner
float circleWidth = 64.0F;
float circleHeight = 64.0F;
// Create start and sweep angles.
float startAngle = 0.0F;
float sweepAngle = 360.0F;
// Fill pie to screen.
e.Graphics.FillPie(FillBrush, X, Y, circleWidth, circleHeight, startAngle,
sweepAngle);

StringFormat drawFormat = new StringFormat();
drawFormat.Alignment = StringAlignment.Center;
Font printFont = new Font("Microsoft Sans Serif", 10, FontStyle.Bold);
Y = (float)(printFont.GetHeight(e.Graphics));
float Y2 = (circleHeight/2.0F) - (Y/2.0F);
X = circleWidth/2.0F;
e.Graphics.DrawString(BxTypelabel.Text,printFont,B rushes.White,X,
Y2,drawFormat);
Any help would be greatly appreciated.
Thank you

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: sammmista | last post by:
hello experts, Plz dont treat this as another newbie query , i did my homework but still getting nowhere :( :( :( Trying to learn PHP on Fedora core 1 (PHP 4.3,MySQL,HTTPD).Unable to post data...
5
by: David Webb | last post by:
The problem started when the Working Folder for a project was somehow set to the folder of another project. I set the correct working folder in VSS and deleted the .vbproj files that had been...
0
by: Matthew Belk | last post by:
I am trying to print some 2x6 labels on a SATO CL408e thermal label printer. The 2x6 labels are arranged in "landscape" mode with 2 labels per "sheet." When I attempt to print "x" copies of a 1...
2
by: ooooscar | last post by:
I'd like to make an application to print labels. I have to print an image and text, the label size is 10cm x 5 cm. I'm wandering how to do it in c#. My first thought is to make an acrobat "form"...
2
by: Michael | last post by:
Running DB2 v7 UDB ("DB2 v7.1.0.93", "n031208" and "WR21333") on Windows XP, I am unable to find out why the "Build for Debug" option within Stored Procedure Builder is not enabled on Java stored...
0
by: Carla | last post by:
I have Access 2000. I have gotten one of my databases imported into it and created a query and report. Now when I go try to change a record, I am getting "updating data in a linked table is not...
4
by: WebDev2 | last post by:
I have a web service created via Visual Web Developer Express Edition on a IIS Server with .NET 2.0 installed. The test page displays just fine when the URL of the .asmx page is entered into a...
6
by: Dave | last post by:
On my form I have combo boxes. These combo boxes, after updating them, populate respective listboxes that are located below the combo boxes on the same form. I am trying to use a "generate...
4
by: MicMic | last post by:
I have a label that needs to print out when a part comes in, but I want a message box to pop up to ask how many copies of the label do they want to print. This is my code so far. Where the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.