I have done this in passed you either have to work out how many pages by pre-reading the file, otherwise you will have to read the print file and update it, before printing, Neither option is pleasant, if you use forms software they may be able to perform this function.