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. Modfying Print Document

Modfying Print Document

Scheduled Pinned Locked Moved C#
questionjsontutorial
5 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.
  • E Offline
    E Offline
    Emmet_Brown
    wrote on last edited by
    #1

    Hi everyone; I want to add some information on my print document. To be precise I'm printing my DataGridView like this:

    private void button5_Click(object sender, EventArgs e)//YAZDIR
    {
    if (SetupThePrinting())
    MyPrintDocument.Print();
    }

    private bool SetupThePrinting()
    {
    PrintDialog MyPrintDialog = new PrintDialog();
    MyPrintDialog.AllowCurrentPage = false;
    MyPrintDialog.AllowPrintToFile = false;
    MyPrintDialog.AllowSelection = false;
    MyPrintDialog.AllowSomePages = false;
    MyPrintDialog.PrintToFile = false;
    MyPrintDialog.ShowHelp = false;
    MyPrintDialog.ShowNetwork = false;

            if (MyPrintDialog.ShowDialog() != DialogResult.OK)
                return false;
    
            MyPrintDocument.DocumentName = "Customers Report";
            MyPrintDocument.PrinterSettings = MyPrintDialog.PrinterSettings;
            MyPrintDocument.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings;
            MyPrintDocument.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40);
    
            if (MessageBox.Show("Verilerin sayfaya ortalanmasını istiyor musunuz?", "Baskı Özellikleri - Sayfa Ortalama", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                MyDataGridViewPrinter = new DataGridViewPrinter(dbGridView, MyPrintDocument, true, true, "KASA DÖKÜMÜ\\n\\nbakiye:"+label17.Text+" gelir:"+label19.Text+" gider:"+label18.Text+"", new Font("Tahoma", 10, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true);
            else
                MyDataGridViewPrinter = new DataGridViewPrinter(dbGridView, MyPrintDocument, false, true, "KASA DÖKÜMÜ\\n\\nbakiye:"+label17.Text+" gelir:"+label19.Text+" gider:"+label18.Text+"", new Font("Tahoma", 10, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true);
    
            return true;
        }
    

    So, I need to make two changes: 1. I need to add a line to the end of the document to put the information on my label#'s, how to put this line properly ( if possible such as: "The information is" +label7.text+ " format) 2. Because of the number of columns, my document prints 6 pages for a 3-paged information. also uses first 3 pages for first 4 columns, and the last 3 pages for the rest of the columns. Reducing the character size in the print document could be a solution, but I don't know how to do that either. Can anybo

    L E 2 Replies Last reply
    0
    • E Emmet_Brown

      Hi everyone; I want to add some information on my print document. To be precise I'm printing my DataGridView like this:

      private void button5_Click(object sender, EventArgs e)//YAZDIR
      {
      if (SetupThePrinting())
      MyPrintDocument.Print();
      }

      private bool SetupThePrinting()
      {
      PrintDialog MyPrintDialog = new PrintDialog();
      MyPrintDialog.AllowCurrentPage = false;
      MyPrintDialog.AllowPrintToFile = false;
      MyPrintDialog.AllowSelection = false;
      MyPrintDialog.AllowSomePages = false;
      MyPrintDialog.PrintToFile = false;
      MyPrintDialog.ShowHelp = false;
      MyPrintDialog.ShowNetwork = false;

              if (MyPrintDialog.ShowDialog() != DialogResult.OK)
                  return false;
      
              MyPrintDocument.DocumentName = "Customers Report";
              MyPrintDocument.PrinterSettings = MyPrintDialog.PrinterSettings;
              MyPrintDocument.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings;
              MyPrintDocument.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40);
      
              if (MessageBox.Show("Verilerin sayfaya ortalanmasını istiyor musunuz?", "Baskı Özellikleri - Sayfa Ortalama", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                  MyDataGridViewPrinter = new DataGridViewPrinter(dbGridView, MyPrintDocument, true, true, "KASA DÖKÜMÜ\\n\\nbakiye:"+label17.Text+" gelir:"+label19.Text+" gider:"+label18.Text+"", new Font("Tahoma", 10, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true);
              else
                  MyDataGridViewPrinter = new DataGridViewPrinter(dbGridView, MyPrintDocument, false, true, "KASA DÖKÜMÜ\\n\\nbakiye:"+label17.Text+" gelir:"+label19.Text+" gider:"+label18.Text+"", new Font("Tahoma", 10, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true);
      
              return true;
          }
      

      So, I need to make two changes: 1. I need to add a line to the end of the document to put the information on my label#'s, how to put this line properly ( if possible such as: "The information is" +label7.text+ " format) 2. Because of the number of columns, my document prints 6 pages for a 3-paged information. also uses first 3 pages for first 4 columns, and the last 3 pages for the rest of the columns. Reducing the character size in the print document could be a solution, but I don't know how to do that either. Can anybo

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      probably using PrintPage event from PrintDocument: http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx[^]

      E 1 Reply Last reply
      0
      • L Lost User

        probably using PrintPage event from PrintDocument: http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx[^]

        E Offline
        E Offline
        Emmet_Brown
        wrote on last edited by
        #3

        Thank you but it seems like PrintPage event is more likely used for adjusting the margins or determining the printable boundaries; generally features about the document. I think I just need to decrease the font size of the text in the printed document. any idea?

        L 1 Reply Last reply
        0
        • E Emmet_Brown

          Hi everyone; I want to add some information on my print document. To be precise I'm printing my DataGridView like this:

          private void button5_Click(object sender, EventArgs e)//YAZDIR
          {
          if (SetupThePrinting())
          MyPrintDocument.Print();
          }

          private bool SetupThePrinting()
          {
          PrintDialog MyPrintDialog = new PrintDialog();
          MyPrintDialog.AllowCurrentPage = false;
          MyPrintDialog.AllowPrintToFile = false;
          MyPrintDialog.AllowSelection = false;
          MyPrintDialog.AllowSomePages = false;
          MyPrintDialog.PrintToFile = false;
          MyPrintDialog.ShowHelp = false;
          MyPrintDialog.ShowNetwork = false;

                  if (MyPrintDialog.ShowDialog() != DialogResult.OK)
                      return false;
          
                  MyPrintDocument.DocumentName = "Customers Report";
                  MyPrintDocument.PrinterSettings = MyPrintDialog.PrinterSettings;
                  MyPrintDocument.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings;
                  MyPrintDocument.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40);
          
                  if (MessageBox.Show("Verilerin sayfaya ortalanmasını istiyor musunuz?", "Baskı Özellikleri - Sayfa Ortalama", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                      MyDataGridViewPrinter = new DataGridViewPrinter(dbGridView, MyPrintDocument, true, true, "KASA DÖKÜMÜ\\n\\nbakiye:"+label17.Text+" gelir:"+label19.Text+" gider:"+label18.Text+"", new Font("Tahoma", 10, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true);
                  else
                      MyDataGridViewPrinter = new DataGridViewPrinter(dbGridView, MyPrintDocument, false, true, "KASA DÖKÜMÜ\\n\\nbakiye:"+label17.Text+" gelir:"+label19.Text+" gider:"+label18.Text+"", new Font("Tahoma", 10, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true);
          
                  return true;
              }
          

          So, I need to make two changes: 1. I need to add a line to the end of the document to put the information on my label#'s, how to put this line properly ( if possible such as: "The information is" +label7.text+ " format) 2. Because of the number of columns, my document prints 6 pages for a 3-paged information. also uses first 3 pages for first 4 columns, and the last 3 pages for the rest of the columns. Reducing the character size in the print document could be a solution, but I don't know how to do that either. Can anybo

          E Offline
          E Offline
          Emmet_Brown
          wrote on last edited by
          #4

          no one :( ?

          1 Reply Last reply
          0
          • E Emmet_Brown

            Thank you but it seems like PrintPage event is more likely used for adjusting the margins or determining the printable boundaries; generally features about the document. I think I just need to decrease the font size of the text in the printed document. any idea?

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            in PrintPage event, you can draw anything what you want...

            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