テキストボックスからシンハラ語テキストの印刷プレビューを表示したい。ここでは、印刷プレビューダイアログを使用しました
private void printDocument2_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs ev)
{
string strText = this.textBox1.Text; // read string from editor window
StreamReader myReader = new StreamReader(strText, System.Text.Encoding.ASCII, false);
int charactersOnPage = 5;
float linesPerPage = 0;
float yPosition = 0;
int count = 0;
float leftMargin = ev.MarginBounds.Left;
float topMargin = ev.MarginBounds.Top;
string line = null;
Font printFont = this.textBox1.Font;
SolidBrush myBrush = new SolidBrush(Color.Black);
// Work out the number of lines per page, using the MarginBounds.
linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics);
// Iterate over the string using the StringReader, printing each line.
while (count < linesPerPage && ((line = myReader.ReadLine()) != null))
{
// calculate the next line position based on the height of the font according to the printing device
yPosition = topMargin + (count * printFont.GetHeight(ev.Graphics));
// draw the next line in the rich edit control
ev.Graphics.DrawString(line, printFont, myBrush, leftMargin, yPosition, new StringFormat());
count++;
}
// If there are more lines, print another page.
if (line != null)
ev.HasMorePages = true;
else
ev.HasMorePages = false;
myBrush.Dispose();
}
これは機能しますが、私のテキストは「අම්මා」ですが、このように「අ්මමා」と表示されるので、正しい方法で表示するのを手伝ってください。
TextBox の内容を印刷したいので、TextBox から PrintDocument を作成しようとしています。しかし、単純な TextBox を PrintDocument に変換する方法が見つかりません。何か案は?