By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,780 Members | 1,549 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,780 IT Pros & Developers. It's quick & easy.

Unable to print on the specified location on Labels

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.