CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2009
    Posts
    3

    Lightbulb C# printing problem

    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
    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();
    #         }

  2. #2
    Join Date
    Apr 2004
    Posts
    102

    Re: C# printing problem

    The problem is my customer provided me a pre printed paper and I
    need to print value into some specific positions.
    Wouldn't it be easier to use the printer in RAW mode and use PCL commands to position the printing??? This would give you total control over print positioning.

  3. #3
    Join Date
    Dec 2009
    Posts
    3

    Re: C# printing problem

    Actually If you can provide me some codes, that will be very helpful.
    Thanks.

  4. #4
    Join Date
    Apr 2004
    Posts
    102

    Re: C# printing problem

    Quote Originally Posted by babaidebnath View Post
    Actually If you can provide me some codes, that will be very helpful.
    Thanks.
    Check this link out.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured