Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4571270
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:28:48+00:00 2026-05-21T19:28:48+00:00

I have a WinForm for creating Labels. It calls a PrintPreviewDialog and displays information

  • 0

I have a WinForm for creating Labels.

It calls a PrintPreviewDialog and displays information using the PrintPageEventArgs in the PrintDocument‘s PrintPageEventHandler.

void Document_Printed(object sender, PrintPageEventArgs e) {
  // Code goes here
}

If the Label is a small address label going to an 8.5×11 Letter, instead of seeing a single Label in the PrintPreviewDialog, I want to see the number of Labels that fit on that PageSettings.PaperSize.

Example: Say four (4) items fit on the selected media (Avery Printer Label or anything).

  • If my End User specifies from 1 to 4 Copies to be printed, I want my Print Preview Dialog to display all copies.

  • If my End User specifies more than four (4) items, the Print Preview Dialog should show multiple pages (I’ve never tackled multiple pages before).

I can size my data to fit my Label size, but I do not know how to get my PrintPageEventHandler to display more than 1 Label on the PrintPreviewDialog.

Could someone show me how this is done? How do I display and print multiple Labels (Documents?) per Sheet?

EDIT: Here is my code, which is based on 2 RectangleF objects: pageRect and LabelRect:

void Document_Printed(object sender, PrintPageEventArgs e) {
  if (printPreview == null) return;
  int labelSupport = 1;
  RectangleF pageRect = new RectangleF(0, 0, printPreview.Document.DefaultPageSettings.PaperSize.Width, printPreview.Document.DefaultPageSettings.PaperSize.Height);
  float fW = (pageRect.Width < LabelRect.Width) ? (pageRect.Width / LabelRect.Width) : (LabelRect.Width / pageRect.Width);
  float fH = (pageRect.Height < LabelRect.Height) ? (pageRect.Height / LabelRect.Height) : (LabelRect.Height / pageRect.Height);
  // START Portion I need HELP with!
  if (1 < LabelsPerPage) {
    if (Landscape) {
    } else {
    }
  } else {
    if (Landscape) {
    } else {
    }
  }
  // END (I think) Portion I need HELP with!
  SizeF ratio = new SizeF(fW, fH);
  Graphics G = e.Graphics;
  foreach (Label item in labelList) {
    Console.WriteLine(item.Name);
    using (SolidBrush b = new SolidBrush(Color.Black)) {
      using (Pen p = new Pen(b)) {
        float x = ratio.Width * (float)item.Location.X;
        float y = ratio.Height * (float)item.Location.Y;
        float w = ratio.Width * (float)item.Size.Width;
        float h = ratio.Height * (float)item.Size.Height;
        RectangleF r = new RectangleF(x, y, w, h);
        G.DrawString(item.Text, item.Font, b, r);
      }
    }
  }
}

EDIT 2: I need a way to print 2 or more documents on 1 page. Nothing has addressed this key point as of yet. That’s the answer I need.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T19:28:48+00:00Added an answer on May 21, 2026 at 7:28 pm

    Printing pages after the first is actually really easy to do: just set the PrintPageEventArgs HasMorePages property to true.

    The tricky part is knowing when to stop this by setting HasMorePages to false. I’ve done this by storing the data for each print job in a List and using an index value to track where I am on this list.

    Each time the PrintPage event fires I increment my index which I use in my List to feed the PrintPage event the particulars of the page I want to print, and if I’m on the last element I set HasMorePages to false.

    void Document_Printed(object sender, PrintPageEventArgs e) { 
       // Get data for this page.
       //xxx =  pageDataList[indexValue];
    
       // Code to print stuff.
    
       indexValue++;
       e.HasMorePages = (pageDataList.Length == indexValue);
    }
    

    This approach can work for you too, perhaps with the labelList I see in your code. Since you’re going to be printing in batches of four you’ll obviously have to adjust the logic a bit but I think you get the idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a C# .NET 2.0 winform in 2010, I have added the
I have a Winform Gui that serves various purposes. I am creating an additional
I have a winform app that has tabcontrols that are 3 layers deep. I
I have a winform app that fills a lot of its dropdomn fields fram
I have a winform program that uses Merge Replication to keep a local SQL
I have a Winform app which lists a batch of invoices in a gridview.
I have a WinForm containing a bindingNavigator at the top and a splitContainer with
I have applications(WinForm) that gets some objects from webservice. After receiving array I transform
I have a winform project which lists all the files in a specified folder.
I have a WinForm project that contains a form called MainUI. You can see

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.