Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Printing

Printing

Scheduled Pinned Locked Moved C#
graphicshelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mazdak
    wrote on last edited by
    #1

    I use this code for printpage:

    private void printDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
    {
    int x = e.MarginBounds.Left+70;
    int y = e.MarginBounds.Top;
    try
    {
    for (int i=0;i<100;i++)
    {
    e.Graphics.DrawString( i.ToString(), new Font("Arial", 10), Brushes.Red, x, y);
    y+=15;
    if (y >= e.MarginBounds.Bottom)
    {
    e.HasMorePages = true;
    return;
    }
    }
    e.HasMorePages = false;
    }
    catch(Exception myE)
    {
    MessageBox.Show("Problem!!" + myE.ToString());
    }

    }

    The problem is now I don't have two page from 1 to 100,my both pages in printpreview are the same and it draw second page the same as first one,not proceed it. I hope it is clear. Thanks Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
    Wish You Were Here-Pink Floyd-1975

    R 1 Reply Last reply
    0
    • M Mazdak

      I use this code for printpage:

      private void printDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
      {
      int x = e.MarginBounds.Left+70;
      int y = e.MarginBounds.Top;
      try
      {
      for (int i=0;i<100;i++)
      {
      e.Graphics.DrawString( i.ToString(), new Font("Arial", 10), Brushes.Red, x, y);
      y+=15;
      if (y >= e.MarginBounds.Bottom)
      {
      e.HasMorePages = true;
      return;
      }
      }
      e.HasMorePages = false;
      }
      catch(Exception myE)
      {
      MessageBox.Show("Problem!!" + myE.ToString());
      }

      }

      The problem is now I don't have two page from 1 to 100,my both pages in printpreview are the same and it draw second page the same as first one,not proceed it. I hope it is clear. Thanks Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
      Wish You Were Here-Pink Floyd-1975

      R Offline
      R Offline
      Rupel
      wrote on last edited by
      #2

      isn't that function called each time you print a page? and it is starting each time with i=0. so it appears correct to me, that each page looks the same. in fact: i'm wondering why it doesn't print infinitely when printing the second page, you should start the i-loop where the one for the first page stopped. ...but i'm new to c# and the corresponding class library...:rolleyes: :wq

      M 1 Reply Last reply
      0
      • R Rupel

        isn't that function called each time you print a page? and it is starting each time with i=0. so it appears correct to me, that each page looks the same. in fact: i'm wondering why it doesn't print infinitely when printing the second page, you should start the i-loop where the one for the first page stopped. ...but i'm new to c# and the corresponding class library...:rolleyes: :wq

        M Offline
        M Offline
        Mazdak
        wrote on last edited by
        #3

        Rüpel wrote: isn't that function called each time you print a page? and it is starting each time with i=0. so it appears correct to me, that each page looks the same. Yes,I know it and I beleive you are right,but how can I solve it,my code is just simple example,in more complecated text its not like this. Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
        Wish You Were Here-Pink Floyd-1975

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups