Hello,
Thanks for your inquiry!
You can first mark the page index by some unique information like names which contained in the first page of each of your customer information, and then draw the pages of each customer to a new PDF according to the page index. Here I attached a simple demo.
- Code: Select all
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(filepath);
PdfTextFind[] findResult = null;
List<int> index = new List<int>();
foreach (PdfPageBase page in pdf.Pages)
{
//Find text
findResult = page.FindText(findString, TextFindParameter.WholeWord).Finds;
foreach (PdfTextFind find in findResult)
{
int pageindex = find.SearchPageIndex;
index.Add(pageindex);
}
}
for (int i = 0; i < index.Count; i++)
{
int currentIndex = index[i];
int nextIndex = 0;
if (i.Equals(index.Count - 1))
{
nextIndex = pdf.Pages.Count;
}
else
{
nextIndex = index[i + 1];
}
PdfDocument newpdf = new PdfDocument();
for (int j = currentIndex; j < nextIndex; j++)
{
PdfPageBase page = pdf.Pages[j];
PdfPageBase newPage = newpdf.Pages.Add(page.ActualSize, new PdfMargins(0));
page.CreateTemplate().Draw(newPage.Canvas, new PointF(0, 0));
}
newpdf.SaveToFile("custom" + i + ".pdf", FileFormat.PDF);
newpdf.Dispose();
}
To help us make a demo that meets your needs better, please provide us with your input file for reference. To protect your privacy, you can overwrite or delete the sensitive information in your file, and then attached there or send it to us via email (
[email protected]). Thanks in advance.
Sincerely,
Marcia
E-iceblue support team