如 总共有10页,我光标点到其中的第3页中下部分,我就要将第3页光标所在位置的上部分的位置计算出来!行高可能不一样的!
通过this.textControl1.Selection.Text = "\f"; 可以进行强制换页 后我就要在新页面的上面空出和正常页面(第3页光标所在位置的上部分不打印的区域大小)相同大小的位置 !
版本我如何实现以下两个:
1、有办法取到这个精确的大小吗?
2、有办法在新页面上动态增加这个精确的大小的区域? 抛砖引玉,先给出一段代码看一看,实现强制换页并在新也上生成相应的空白区域,需要你建一个Bitmap1.bmp文件,并拷贝到bin目录下:
private void btnNewPage_Click(object sender, EventArgs e)
{
Graphics g = textControl1.CreateGraphics();
int DPI = (int)(1440 / g.DpiX);
TXTextControl.Line topLine = textControl1.Lines;
TXTextControl.Line bottomLine = textControl1.Lines;
this.textControl1.Selection.Text = "\f";
Rectangle rect = new Rectangle(
((topLine.TextBounds.X / DPI) ) - (textControl1.ScrollLocation.X / DPI),
(topLine.TextBounds.Top / DPI) - (textControl1.ScrollLocation.Y / DPI),
500,
(bottomLine.TextBounds.Bottom / DPI) - (topLine.TextBounds.Top / DPI));
textControl1.Images.Clear();
textControl1.Images.Add(new TXTextControl.Image(new Bitmap(Image.FromFile("Bitmap1.bmp"), 100, rect.Height)), new Point(topLine.TextBounds.X / DPI, topLine.TextBounds.Y / DPI), TXTextControl.ImageInsertionMode.FixedOnPage);
textControl1.Refresh();
}
页:
1
[2]