public void Print(int printItem = 1) { PrintDocument recordDoc; // Create the document and name it recordDoc = new PrintDocument(); recordDoc.DocumentName = "Inventory Receipt"; PaperSize ps = new PaperSize(); ps.RawKind = 119; ps.Width = 200; recordDoc.DefaultPageSettings.PaperSize = ps; recordDoc.DefaultPageSettings.Margins.Top = 1; recordDoc.DefaultPageSettings.Margins.Left = 1; if (printItem == 1) { recordDoc.PrintPage += new PrintPageEventHandler(this.PrintReceiptPage); CalculatePrint(); } else { recordDoc.PrintPage += new PrintPageEventHandler(this.PrintUtangPage); CalculateUtangPrint(); } ps.Height = m_ReceiptSize; // Preview document System.Windows.Forms.PrintPreviewDialog dlgPreview = new System.Windows.Forms.PrintPreviewDialog(); dlgPreview.Document = recordDoc; Profile _myProfile = new Profile(); _myProfile.ReadXML(); if (_myProfile.EnablePreview == true) { dlgPreview.ShowDialog(); } else { recordDoc.Print(); dlgPreview.Close(); } // Dispose of document when done printing recordDoc.Dispose(); }