public void Print_Preview(Print_content content) { PrintPreviewDialog dlgPrintPreview = new PrintPreviewDialog(); //dlgPrintPreview.Width = 3000; //dlgPrintPreview.Size = new System.Drawing.Size(2000, 3000); ToolStrip ts = (ToolStrip)dlgPrintPreview.Controls[1]; ToolStripItem printItem = ts.Items["printToolStripButton"]; ToolStripItem myPrintItem = null; myPrintItem = ts.Items.Add("Print", printItem.Image, new EventHandler(MyPrintItemClicked)); print_a = content; myPrintItem.DisplayStyle = ToolStripItemDisplayStyle.Text; //Relocate the item to the beginning of the toolstrip ts.Items.Insert(0, myPrintItem); ToolStripItem mySpaceItem = null; mySpaceItem = ts.Items.Add("-"); mySpaceItem.DisplayStyle = ToolStripItemDisplayStyle.Text; ts.Items.Insert(1, mySpaceItem); //print pdf (has not Print Setup menu) if (mGlobal.PrintPDF == true) { goto setup; } ToolStripItem myPageSetupItem = null; myPageSetupItem = ts.Items.Add("Print Setup...", printItem.Image, new EventHandler(MyPageSetupItemClicked)); myPageSetupItem.DisplayStyle = ToolStripItemDisplayStyle.Text; //Relocate the item to the beginning of the toolstrip ts.Items.Insert(2, myPageSetupItem); setup: ts.Items.Insert(3, mySpaceItem); PreparePrintDocument(content); __reload_PreviewDialog: //INSERT DATA dlgPrintPreview.ClientSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); dlgPrintPreview.MinimumSize = dlgPrintPreview.ClientSize; dlgPrintPreview.Location = new System.Drawing.Point(10, 10); dlgPrintPreview.UseAntiAlias = true; //smooth fonts. dlgPrintPreview.Document = prn_Document; prn_PreviewDialog = dlgPrintPreview; f_Refresh = false; //SHOW DIALOG prn_PreviewDialog.ShowDialog(); // Preview and print //if (f_Refresh == true) //{ // goto __reload_PreviewDialog; //} }
private void PreparePrintDocument(Print_content content) { dlgPrint = new PrintDialog(); PrintDocument print_document = new PrintDocument(); print_document.DefaultPageSettings.Margins.Top = 20; //mil=inch/100 print_document.DefaultPageSettings.Margins.Bottom = 20; //mil=inch/100 print_document.DefaultPageSettings.Margins.Left = 20; //mil=inch/100 print_document.DefaultPageSettings.Margins.Right = 20; //mil=inch/100 //print_document.DefaultPageSettings.PaperSize = print_document.PrinterSettings.PaperSizes[14]; PaperKind a = print_document.DefaultPageSettings.PaperSize.Kind; //print_document.DefaultPageSettings.PaperSize.PaperName = "Custom"; //print_document.DefaultPageSettings.PaperSize.Width = 1000; print_document.DefaultPageSettings.Landscape = true; prn_NumOfPage = 0; //// Select Case Content ////ORIGINAL LINE: Case Print_content.Print_Graph_and_Summary if (content == Print_content.Print_Graph_and_Summary) { print_document.PrintPage += Create_PrintPage_Graph_and_Summary; //Case Print_content.Print_general_information // AddHandler print_document.PrintPage, AddressOf Create_PrintPage_information } prn_Document = print_document; }