3

I have the following issue when trying to draw a string and then printing it to PDF by Amyuni Printer :

enter image description here

where I couldn't select the text when pressing (Ctrl+A) , I need this PDF file to use it into another PDF reader , and it seems that the reader , tries to read the selected area not the actual text area .

I'm using the following code to do this stuff :

   Font printFont = new Font("Simplified Arabic Fixed", (float)11, FontStyle.Regular);
StreamReader Printfile;
using (StreamReader Printfile = new StreamReader(@"C:\20_2.txt", Encoding.Default))
            {
                try
                {
                    PrintDocument docToPrint = new PrintDocument();
                    PaperSize ps = new PaperSize("A4", 827, 1169);               
                    bool bolFirstPage = true;
                    docToPrint.DefaultPageSettings.PaperSize = ps;
                    docToPrint.DefaultPageSettings.Landscape = true;
                    docToPrint.DocumentName = "docName" + DateTime.Now.Ticks.ToString(); //Name that appears in the printer queue
                    string FirstLine = Printfile.ReadLine();
                    bool bIsArabic = true;
                    docToPrint.PrintPage += (s, ev) =>
                    {
                        float nFontHight = printFont.GetHeight(ev.Graphics);
                        bIsArabic = true;
                        float linesPerPage = 0;
                        float yPos = 0;
                        int count = 0;
                        float leftMargin = 1008;
                        float topMargin = 120;
                        string line = null;
                        //Calculate the number of lines per page.
                        linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics) + 2;
                        Image img = Image.FromFile(@"C:\image.bmp");
                        ev.Graphics.DrawImage(img, 6, 1, 1095, 728);
                        //***Image Reslution is Working good -->***
                        StringFormat format = new StringFormat()/*arabic*/;
                        line = Printfile.ReadLine();
                        format = new StringFormat(StringFormatFlags.DisplayFormatControl | StringFormatFlags.DirectionRightToLeft)/*arabic*/;
                        do
                        {
                            yPos = topMargin + ((count) * printFont.GetHeight(ev.Graphics) * (float)0.91);
                            line = " تجربة تجربة تجربة تجربة تجربة";
                            ev.Graphics.DrawString(line, printFont, Brushes.DeepPink, leftMargin, yPos, format);
                            count++;
                        } while ((line = Printfile.ReadLine()) != null && !line.Contains(''));// lines contains \0 as UniCode

                        // If more lines exist, print another page. 
                        if (line != null)
                            ev.HasMorePages = true;
                        else
                            ev.HasMorePages = false;
                    };
                    docToPrint.Print();
                }
                catch (System.Exception f)
                {
                    MessageBox.Show(f.Message);
                }
            }
        }

when I'm using another font type like "Arial" I can select near to 90% of the text, but unfortunately I have to use only the font type "Simplified Arabic Fixed" , and I'm using windows server 2003.

one more thing , when i try to print directly Arabic text from notepad it's work fine.

0 Answers0