nwenar abbas

nwenar abbas

  • 1.5k
  • 108
  • 2.9k

Printing Multi - Page

Nov 22 2021 11:47 AM

I want to print multi page on winform as it's needed I have Found a solution on C#Corner but it prints  my Fonts meanwhile I want to print a Richtext box is Texts 

so ho can I print My rich textbox Within this code

public void pd_PrintPage(object sender, PrintPageEventArgs ev)  
{  
    ypos = 1;  
    float pageheight = ev.MarginBounds.Height;  
    //Create a Graphics object  
    Graphics g = ev.Graphics;  
    //Get installed fonts  
    InstalledFontCollection ifc =  
    new InstalledFontCollection();  
    //Get font families  
    FontFamily[] ffs = ifc.Families;  
    //Draw string on the paper  
    while (ypos + 60 < pageheight &&  
    fontposition < ffs.GetLength(0))  
    {  
        //Get the font name   
        Font f =  
        new Font(ffs[fontposition].GetName(0), 25);  
        //Draw string  
        g.DrawString(ffs[fontposition].GetName(0), f,  
        new SolidBrush(Color.Black), 1, ypos);  
        fontposition = fontposition + 1;  
        ypos = ypos + 60;  
    }  
    if (fontposition < ffs.GetLength(0))  
    {  
        //Has more pages??  
        ev.HasMorePages = true;  
    }  
}

 


Answers (2)