@Allan_Zimmermann
I got the error while running c# code in openRPA after installing iTextsharp package in openRPA. here is the code :
using iTextSharp.text;
using iTextSharp.text.pdf;
string inputFilePath = “Documents\outs6.pdf”;
int pagesPerSplit = 1; // Number of pages per split PDF
using (PdfReader reader = new PdfReader(inputFilePath))
{
int pageCount = reader.NumberOfPages;
int splitCount = (int)Math.Ceiling((double)pageCount / pagesPerSplit);
for (int i = 0; i < splitCount; i++)
{
int startPage = i * pagesPerSplit + 1;
int endPage = Math.Min(startPage + pagesPerSplit - 1, pageCount);
string outputFilePath = string.Format("Documents\\outs_{0}.pdf", (i + 1));
using (FileStream fs = new FileStream(outputFilePath, FileMode.Create, FileAccess.Write))
using (Document document = new Document())
using (PdfCopy writer = new PdfCopy(document, fs))
{
document.Open();
for (int page = startPage; page <= endPage; page++)
{
PdfImportedPage importedPage = writer.GetImportedPage(reader, page);
writer.AddPage(importedPage);
}
document.Close();
}
}
}
this is the code to split a single pdf into multiple pdf on the basis of number of page in the pdf.