Question
How to find out beforehand the number of pages in the input document?
Answer
To do this, use the GetNumberOfPagesInImageFile method of the Engine object. For example, the following code snippet demonstrates how to recognize the last 3 pages of a multipage document:
// C#
string imagePath = "...";
FREngine.FRDocument document = engineLoader.Engine.CreateFRDocument();
int totalNumberOfPages = engineLoader.Engine.GetNumberOfPagesInImageFile(imagePath);
FREngine.IIntsCollection pagesToProcess = engineLoader.Engine.CreateIntsCollection();
if (totalNumberOfPages >= 4) {
// The indexing of Pages collection starts with 0
int lastPageNumber = totalNumberOfPages - 1;
for (int i = lastPageNumber; i > lastPageNumber - 3; i--) {
pagesToProcess.Add(i);
}
document.AddImageFile( imagePath, null, pagesToProcess);
}
Comments
0 comments
Please sign in to leave a comment.