Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > .NET Frameworks (точка нет фреймворки) > Общие вопросы .NET
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 09.03.2010, 16:22   #1
Linore
Пользователь
 
Регистрация: 18.01.2010
Сообщений: 95
По умолчанию При печати не воспринемаются табуляции

Помогите плиз не воспринимаются табуляции при печати
Код:
System.IO.StreamReader fileToPrint;
        System.Drawing.Font printFont;
        private void button3_Click(object sender, EventArgs e)
        {
            Form1 frm1 = (Form1)Owner;
            frm1.path = Application.StartupPath + "/" + "Проверка_ЦДУ18_" + DateTime.Now.ToShortDateString() + "_" + DateTime.Now.Hour.ToString() + "." + DateTime.Now.Minute.ToString() + ".txt";                     //"C:/Dannii.txt";
            frm1.sw = new StreamWriter(frm1.path);
            for (int i = 0; i < frm1.listBox1.Items.Count; i++)
            {

                frm1.sw.WriteLine(frm1.listBox1.Items[i].ToString());


            }
            frm1.sw.Close();

           // string printPath = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            string text = ( "/Проверка_ЦДУ18_" + DateTime.Now.ToShortDateString() + "_" + DateTime.Now.Hour.ToString() + "." + DateTime.Now.Minute.ToString() + ".txt");
            fileToPrint = new StreamReader(Application.StartupPath + @text);
            //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            
         //   printFont = new System.Drawing.Font("Arial", 10);
            //Create a StreamReader object
            

            printFont = new System.Drawing.Font("Arial", 8);

        
            //=============================================================================

        
            //var printer = new System.Diagnostics.Process();

            //printer.StartInfo.FileName = fileToPrint;
            //printer.StartInfo.UseShellExecute = true;
            //printer.StartInfo.Verb = "print";
            //printer.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;
            //printer.Start();
            //Close();
            PrintDocument pd = new PrintDocument();
            pd.PrintPage += new PrintPageEventHandler(this.printDocument1_PrintPage);
            pd.Print();
            fileToPrint.Close();
            frm1.Close();
           // System.Drawing.Font.FromHfont
            
        }

        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Form1 frm1 = (Form1)Owner;
            float yPos = 0f;
            int count = 0;
            float leftMargin = e.MarginBounds.Left;
            float topMargin = e.MarginBounds.Top;
            string line = null;
            float linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics);
            while (count < linesPerPage)
            {

                line = fileToPrint.ReadLine();
                if (line == null)
                {
                    break;
                }
                yPos = topMargin + count * printFont.GetHeight(e.Graphics);
                e.Graphics.DrawString(line, printFont, Brushes.Black, topMargin, yPos, new StringFormat());//
                count++;
            }
            if (line != null)
            {
                e.HasMorePages = true;
            }
        }

Последний раз редактировалось Sazary; 16.03.2010 в 15:42.
Linore вне форума Ответить с цитированием
Старый 10.03.2010, 10:54   #2
Linore
Пользователь
 
Регистрация: 18.01.2010
Сообщений: 95
По умолчанию

Ура нашла сама решение
StringFormat myStringFormat = new StringFormat(); // перемнная используемая в данном случае для восприятия шрифтом табуляций
float[] tabStops = { 50.0f, 50.0f }; //подключение табуляций
e.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, myStringFormat);// задание основных параметров печати
count++;
Linore вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
серый фон при печати. SKS Компьютерное железо 10 02.04.2013 18:06
Изменение шрифта при печати Linore Общие вопросы .NET 2 09.03.2010 16:17
Дублирование при печати pavel.ignatenko Microsoft Office Excel 1 03.03.2010 23:39
Упорядочить при печати на принтер valerij Софт 5 08.10.2009 14:32
Сохранение документа при печати vovk Microsoft Office Word 2 12.09.2008 10:12