Пример #1
0
        public void Print()
        {
            if (!myHasWriteLine)
            {
                return;
            }

            myStreamWriter.Close();

            myStreamReader = new StreamReader(myFilePath);

            try
            {
                myTextFont = new Font("Arial", 9);
                TextFilePrintDocument pd = new TextFilePrintDocument(myStreamReader);
                //PrintDocument pd = new PrintDocument();

                //	pd.DefaultPageSettings.PaperSize.Height= myTextFont.Height;
//				pd.DefaultPageSettings.PaperSize= new System.Drawing.Printing.PaperSize("PaperA4",76,9000);


//				pd.DefaultPageSettings.PaperSize=auto;//new PaperSize("new size", myStreamReader.PageSize.Width, myStreamReader.PageSize.Height);
//				pd.DefaultPageSettings.Margins =auto;//new Margins(pd .PageMargins.Left, myStreamReader.PageMargins.Right, myStreamReader.PageMargins.Top, myStreamReader.PageMargins.Bottom);
                pd.PrintPage += new PrintPageEventHandler
                                    (this.pd_PrintPage);

                pd.Print();
            }
            catch (System.ComponentModel.Win32Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                myStreamReader.Close();
                File.Delete(myFilePath);
            }
        }
Пример #2
0
        public void Print2()
        {
            try
            {
                myStreamWriter.Close();
                StreamReader streamToPrint = new StreamReader(myFilePath);
                try
                {
                    myTextFont = new Font("Arial", 9);
                    TextFilePrintDocument pd = new TextFilePrintDocument(streamToPrint);                     //Assumes the default printer

                    PrintDialog dlg = new PrintDialog();
                    pd.PrintPage += new PrintPageEventHandler
                                        (this.pd_PrintPage);
                    dlg.Document = pd;

                    //	pd.Print();

                    DialogResult result = dlg.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        pd.Print();
                    }
                }
                finally
                {
                    streamToPrint.Close();
                    File.Delete(myFilePath);
//
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occurred printing the file - " + ex.Message);
            }
        }
Пример #3
0
        public void Print2()
        {
            try
            {
                myStreamWriter.Close();
                StreamReader streamToPrint = new StreamReader (myFilePath);
                try
                {
                    myTextFont = new Font("Arial", 9);
                    TextFilePrintDocument pd = new TextFilePrintDocument(streamToPrint); //Assumes the default printer

                    PrintDialog dlg = new PrintDialog() ;
                    pd.PrintPage += new PrintPageEventHandler
                        (this.pd_PrintPage);
                    dlg.Document = pd;

                //	pd.Print();

                                        DialogResult result = dlg.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        pd.Print();
                    }
                }
                finally
                {
                streamToPrint.Close();
                File.Delete(myFilePath);
            //
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show("An error occurred printing the file - " + ex.Message);
            }
        }
Пример #4
0
        public void Print()
        {
            if (!myHasWriteLine) return;

            myStreamWriter.Close();

            myStreamReader = new StreamReader(myFilePath);

            try
            {
                myTextFont = new Font("Arial", 9);
                TextFilePrintDocument pd = new TextFilePrintDocument(myStreamReader);
                //PrintDocument pd = new PrintDocument();

            //	pd.DefaultPageSettings.PaperSize.Height= myTextFont.Height;
            //				pd.DefaultPageSettings.PaperSize= new System.Drawing.Printing.PaperSize("PaperA4",76,9000);

            //				pd.DefaultPageSettings.PaperSize=auto;//new PaperSize("new size", myStreamReader.PageSize.Width, myStreamReader.PageSize.Height);
            //				pd.DefaultPageSettings.Margins =auto;//new Margins(pd .PageMargins.Left, myStreamReader.PageMargins.Right, myStreamReader.PageMargins.Top, myStreamReader.PageMargins.Bottom);
                pd.PrintPage += new PrintPageEventHandler
                    (this.pd_PrintPage);

                pd.Print();
            }
            catch (System.ComponentModel.Win32Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                myStreamReader.Close();
                File.Delete(myFilePath);
            }
        }