@ TZacks-2728, Welcome to Microsoft Q&A, you could try the following code to divide pages by input value.
static void Main(string[] args)
{
foreach (var p in GetPage(38, 6))
{
string abc = p.ToString();
Console.WriteLine(abc);
}
Console.WriteLine("**");
foreach (var p in GetPage(35, 4))
{
string abc = p.ToString();
Console.WriteLine(abc);
}
}
public static IEnumerable<int> GetPage(int pagetotal, int userinput)
{
int size = pagetotal / userinput;
int rest = pagetotal % userinput;
int last_size = rest;
for (int i = 0; i < size; i++)
{
yield return userinput;
}
yield return last_size;
}
Also, I make another test for (35,4), It outputs 8 pdf with 4 pages and one pdf with 3 pages.
Result:
Best Regards,
Jack
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.