Print Labels C#

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ooooscar

    Print Labels C#

    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.


  • ooooscar

    #2
    Re: Print Labels C#

    I don't understand your comment.
    Sorry.
    "Ron Allen" <rallen@_nospam _src-us.com> escribió en el mensaje
    news:%23%23Uw1P WVFHA.3176@TK2M SFTNGP12.phx.gb l...[color=blue]
    > 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[/color]
    subclass[color=blue]
    > 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" <oscarjofre1@ho tmail.com> wrote in message
    > news:%23KEANeSV FHA.3840@tk2msf tngp13.phx.gbl. ..[color=green]
    > > I'd like to make an application to print labels. I have to print an[/color][/color]
    image[color=blue][color=green]
    > > and text, the label size is 10cm x 5 cm. I'm wandering how to do it in[/color][/color]
    c#.[color=blue][color=green]
    > > My first thought is to make an acrobat "form" with the image and text,[/color][/color]
    but[color=blue][color=green]
    > > 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.
    > >
    > >[/color]
    >
    >[/color]


    Comment

    • Ron Allen

      #3
      Re: Print Labels C#

      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(Pri ntPageEventArgs e)
      {
      base.OnPrintPag e(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 PrintPageEventA rgs,
      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" <oscarjofre1@ho tmail.com> wrote in message
      news:%23IX%23sS fVFHA.3540@TK2M SFTNGP15.phx.gb l...[color=blue]
      >I don't understand your comment.
      > Sorry.
      > "Ron Allen" <rallen@_nospam _src-us.com> escribió en el mensaje
      > news:%23%23Uw1P WVFHA.3176@TK2M SFTNGP12.phx.gb l...[color=green]
      >> 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[/color]
      > subclass[color=green]
      >> 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" <oscarjofre1@ho tmail.com> wrote in message
      >> news:%23KEANeSV FHA.3840@tk2msf tngp13.phx.gbl. ..[color=darkred]
      >> > I'd like to make an application to print labels. I have to print an[/color][/color]
      > image[color=green][color=darkred]
      >> > and text, the label size is 10cm x 5 cm. I'm wandering how to do it in[/color][/color]
      > c#.[color=green][color=darkred]
      >> > My first thought is to make an acrobat "form" with the image and text,[/color][/color]
      > but[color=green][color=darkred]
      >> > 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.
      >> >
      >> >[/color]
      >>
      >>[/color]
      >
      >[/color]


      Comment

      Working...