通过以下代码删除空页没有问题
TXTextControl.PageCollection.PageEnumerator pageEnum =
textControl1.GetPages().GetEnumerator();
pageEnum.MoveNext();
int pageCounter = textControl1.GetPages().Count;
for (int i = 0; i < pageCounter; i++)
{
TXTextControl.Page curPage = (TXTextControl.Page)pageEnum.Current;
if (curPage.Length == 1 || curPage.Length == 0)
{
textControl1.Select(curPage.Start - 1, 1);
textControl1.Selection.Text = "";
}
else
pageEnum.MoveNext();
}
但是下面这个附件(保存为字节文件,通过 textControl1.Load(bBytes, BinaryStreamType.InternalFormat);加载),里面有个空页,这个空页的page.Length = 0,现在要删除该页怎么也删不了。也就是说我要实现删除指定的页。
说明一下,这个空白页是控件自动分裂产生的新页。第2页,第4页才是代码控制产生的新页.
其中产生新页的代码:
public int AddNewPage()
{
int newPage = this.m_stx.Pages + 1;
InputPosition inputPosition = new TXTextControl.InputPosition(newPage, 1, 0);
Selection pSelect = new Selection(m_stx.Text.Length, 0);
this.m_stx.Selection = pSelect;
this.m_stx.Selection.Text = "\f";
this.m_stx.Selection.Length = 0;
//this.m_stx.InputPosition.ScrollTo();
//this.textControl1.InputPosition = inputPosition;
//Point ScrollPosition = new Point(0, inputPosition.Location.Y);
//this.textControl1.ScrollLocation = ScrollPosition;
return newPage;
}
|
|