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

Print Labels C#

P: n/a
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" with the image and text, but I
have to send a date in the label so I need to open the pdf and send the date
into a field (variable), then I have to print n times the same label.

Can anyone help me ?

Thank's.
Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I don't understand your comment.
Sorry.
"Ron Allen" <rallen@_nospam_src-us.com> escribió en el mensaje
news:%2******************@TK2MSFTNGP12.phx.gbl...
I'd just write the drawing code to draw the label and then offset it n
times for each label on a row and the add the row spacing to the start and
repeat until the page is filled. Put all this into a PrintDocument subclass and make sure to account for the printer 'hard' margins and everything
should work easily. If you need to get very precise alignment setup your
calling program to provide x/y offsets and then store them in application
settings. Just put the varying fields on the form into an ArrayList and
loop through it until all are printed.

Ron Allen
"ooooscar" <os*********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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" with the image and text, but I
have to send a date in the label so I need to open the pdf and send the
date
into a field (variable), then I have to print n times the same label.

Can anyone help me ?

Thank's.


Nov 17 '05 #2

P: n/a
I'm normally used to doing all my own drawing in print jobs so thats how
I explained it. I'd write a custom PrintDocument class and then pass in an
ArrayList (or something) with all the label data. A brief outline of the
code for the OnPrintPage would be
protected override void OnPrintPage(PrintPageEventArgs e)
{
base.OnPrintPage(e);
float cury = 1.0f; // or whatever is needed (everything in
inches)
float bottom = 10.0f; // bottom of labels
float labelht = 1.0f; // height of a label top of one to the next
float leftx = 1.0f; // leftmost label position
float curx = leftx; // current x position
float rightx = 7.5f; // rightmost position
float colwidth = 2.0f;
// nLabel is a integer declared as a class variable -- index into the
ArrayList
while ((nLabel < labelCount) && (cury < bottom))
{
DrawLabel(e, nLabel, cury, curx, Labels[nLabel]);
curx += colwidth;
if (curx > rightx)
{
cury += labelht;
curx = leftx;
}
}
if (nLabel < labelCount) // more labels to print
e.HasMorePages = true;
else
e.HasMorePages = false; // done printing
}
DrawLabel would just take the Graphics from the supplied PrintPageEventArgs,
the x/y position and the data in the Labels list (a group of strings or
whatever) and draw it on the page as desired. Labels spread across the page
from left to right and then top to bottom. You could pass in the variables
for top of page, right of page, column width, and label height to the
subclass to make this more general. DrawLabel would just be something that
printed each supplied string seperated by a specified height on the label.

Ron Allen

"ooooscar" <os*********@hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP15.phx.gbl...
I don't understand your comment.
Sorry.
"Ron Allen" <rallen@_nospam_src-us.com> escribió en el mensaje
news:%2******************@TK2MSFTNGP12.phx.gbl...
I'd just write the drawing code to draw the label and then offset it
n
times for each label on a row and the add the row spacing to the start
and
repeat until the page is filled. Put all this into a PrintDocument

subclass
and make sure to account for the printer 'hard' margins and everything
should work easily. If you need to get very precise alignment setup your
calling program to provide x/y offsets and then store them in application
settings. Just put the varying fields on the form into an ArrayList and
loop through it until all are printed.

Ron Allen
"ooooscar" <os*********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
> 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" with the image and text, but > I
> have to send a date in the label so I need to open the pdf and send the
> date
> into a field (variable), then I have to print n times the same label.
>
> Can anyone help me ?
>
> Thank's.
>
>



Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.