How to recognize the first and the last pages of the document

Question

How can I recognize only the first and the last page without knowing total page count in advance and recognizing all of them?

Answer

To do this, you could use MoveById and DeleteById methods of Pages Object. For example:

// C#
var pages = Document.Pages;
int p_count = pages.Count;
if (p_count > 2)
{
pages.MoveById(pages.Item(p_count-1).Id, pages.Item(1).Id)
for (int i = p_count; i>2; i--)
{
pages.DeleteById(i)
}
}

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.