【发布时间】:2014-01-01 14:11:26
【问题描述】:
我有一个 silverlight 应用程序,它允许人们进入可以打印的注释字段,用于执行此操作的代码是:
PrintDocument pd = new PrintDocument();
Viewbox box = new Viewbox();
TextBlock txt = new TextBlock();
txt.TextWrapping = TextWrapping.Wrap;
Paragraph pg = new Paragraph();
Run run = new Run();
pg = (Paragraph)rtText.Blocks[0];
run = (Run)pg.Inlines[0];
txt.Text = run.Text;
pd.PrintPage += (s, pe) =>
{
double grdHeight = pe.PrintableArea.Height - (pe.PageMargins.Top + pe.PageMargins.Bottom);
double grdWidth = pe.PrintableArea.Width - (pe.PageMargins.Left + pe.PageMargins.Right);
txt.Width = grdWidth;
txt.Height = grdHeight;
pe.PageVisual = txt;
};
pd.Print(lblTitle.Text);
这只是在页面上打印文本框的内容,但是一些注释的跨越比页面本身大,导致它被切断。如何更改我的代码以测量文本并添加更多页面,或者是否有更好的方法来执行上述操作,它会自动为我创建多个页面?
【问题讨论】: