Hello all,
I am presently having a problem with printing in C#.
The problem is my customer provided me a pre printed paper and I
need to print value into some specific positions. But problem is C# for its
generic autofit to page nature dont let me doing this. Every time it is
decreasing whole page's size and also altering my value position into some
specific ratio. Can anyone tell me how can I come over that problem.
This is my code
I am presently having a problem with printing in C#.
The problem is my customer provided me a pre printed paper and I
need to print value into some specific positions. But problem is C# for its
generic autofit to page nature dont let me doing this. Every time it is
decreasing whole page's size and also altering my value position into some
specific ratio. Can anyone tell me how can I come over that problem.
This is my code
Code:
//I AM USING PrintDocument COMPONENT private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { //panelPrintData IS A PANEL CONTAING MY PRINTING PICTUREBOX,TEXTBOX,COMBO AND OTHERS NEED TO PRINT printDoc(panelPrintData, e); } public void printDoc(Panel p,PrintPageEventArgs e) { try { foreach (object obj in p.Controls) { if (obj is TextBox) { TextBox txt = (TextBox)obj; e.Graphics.DrawString(txt.Text, new Font("Arial", 10, FontStyle.Regular), Brushes.Black, txt.Left , txt.Top ); } if (obj is Utility.LSInterfaces.IImagePrintable) { Utility.LSInterfaces.IImagePrintable img = (Utility.LSInterfaces.IImagePrintable)obj; e.Graphics.DrawImage(img.Picture, img.Left , img.Top , img.Width, img.Height); } if (obj is LogiSoftUserControl.ResizableComponent.ResizablePictureBox) { LogiSoftUserControl.ResizableComponent.ResizablePictureBox img = (LogiSoftUserControl.ResizableComponent.ResizablePictureBox)obj; e.Graphics.DrawImage(img.Picture, img.Left , img.Top , img.Width, img.Height); } if (obj is PictureBox) { PictureBox img = (PictureBox)obj; e.Graphics.DrawImage(img.Image, img.Left , img.Top , img.Width, img.Height); } } } catch (ArgumentNullException) { } } //THIS IS BUTTON FOR PRINT private void btnPrint_Click(object sender, EventArgs e) { DialogResult r = printDialog1.ShowDialog(); if (r == DialogResult.OK) printDocument1.Print(); }
Comment