Getting error when using c# code in OpenRPA

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))
        for (int page = startPage; page <= endPage; page++)
            PdfImportedPage importedPage = writer.GetImportedPage(reader, page);

this is the code to split a single pdf into multiple pdf on the basis of number of page in the pdf.

Hou cannot use import inside a function. Invoke code wraps the code in a function

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.