Help on Printpage in c#

Asked

Viewed 63 times

1

What are the processes to place a watermark (image) in the form that will be created by c#

  private void Imprimir_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
    {

        Font fonte = new Font("Arial", 30, FontStyle.Bold, GraphicsUnit.Pixel);


        e.Graphics.DrawString(DateTime.Now.ToString("HH:mm:ss"), fonte, Brushes.Black, 20, 20);

        e.Graphics.DrawString("TESTE DE LABEL",fonte,Brushes.Black,20,150);

        e.Graphics.DrawString(textBox1.Text, fonte, Brushes.Black, 300, 250);


    }
  • I thought to put the image in the form and make it invisible, only being visible in the print, like when I click to print it becomes visible in the form

  • Heavy drug user

1 answer

0


I imagine you’re wearing the Printdocument.

PrintDocument printDoc = new PrintDocument(); 
printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage); 

Then add the Graphics there:

Graphics g = e.Graphics; 
g.TranslateTransform(200, 200); 
g.RotateTransform(e.PageSettings.Landscape ? 30 : 60); 
g.DrawString("DRAFT VERSION", new Font("Arial", 75, FontStyle.Bold), 
             new SolidBrush(Color.FromArgb(64, Color.Black)), 0, 0);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.