3

尝试绘制字符串然后通过 Amyuni Printer 将其打印为 PDF 时出现以下问题:

在此处输入图像描述

在按下 (Ctrl+A) 时无法选择文本的地方,我需要此 PDF 文件将其用于另一个 PDF 阅读器,并且似乎阅读器试图阅读所选区域而不是实际文本区域。

我正在使用以下代码来执行此操作:

   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);
                }
            }
        }

当我使用另一种字体类型(如“Arial”)时,我可以选择接近 90% 的文本,但不幸的是,我只能使用“Simplified Arabic Fixed”字体类型,而且我使用的是 Windows Server 2003。

还有一件事,当我尝试从记事本直接打印阿拉伯语文本时,它工作正常。

4

0 回答 0