How to use 'using' statements in invoke code

i want to use this code in invoke code

using iTextSharp.text.pdf;
using System.IO;

// Get the array of input PDF file names from the input argument
string[] pdfFiles = inputFiles;

// Set the name of the output PDF file
string outputFileName = outputFiles;

// Create a new PdfCopy object to write the merged PDF document
FileStream outputStream = new FileStream(outputFileName, FileMode.Create);
PdfCopy copy = new PdfCopy(outputStream);

foreach (string inputFile in pdfFiles)
{
    // Create a PdfReader object for the current input file and add its pages to the PdfCopy object
    PdfReader reader = new PdfReader(inputFile);
    copy.AddDocument(reader);

    // Close the PdfReader object for the current input file
    reader.Close();
}

// Close the PdfCopy object and the output stream
copy.Close();
outputStream.Close();

Can you tell which language is this Script on?

it is in C#

Hi,

Can you try to define it at Imports tab?

However, sometimes it doesn’t work well. If you face issue, can you try to add namespace to each class etc without using statement.

Regards,

i have already added both System.IO and itexsharp.text.pdf in the imports pannel but still didnt worked

can you explain what you mean by that , with some example

Hi,

I mean as the following.

// Get the array of input PDF file names from the input argument
string[] pdfFiles = inputFiles;

// Set the name of the output PDF file
string outputFileName = outputFiles;

// Create a new PdfCopy object to write the merged PDF document
System.IO.FileStream outputStream = new System.IO.FileStream(outputFileName, FileMode.Create);
iTextSharp.text.pdf.PdfCopy copy = new  iTextSharp.text.pdf.PdfCopy(outputStream);

foreach (string inputFile in pdfFiles)
{
// Create a PdfReader object for the current input file and add its pages to the PdfCopy object
iTextSharp.text.pdf.PdfReader reader = new iTextSharp.text.pdf.PdfReader(inputFile);
copy.AddDocument(reader);

// Close the PdfReader object for the current input file
reader.Close();
}

// Close the PdfCopy object and the output stream
copy.Close();
outputStream.Close();

BTW, is this code correct?

Regards,

its just a trial code for understanding invoke code pros and cons and capablities , just trying diffrent scenarios to be coverd in invoke code activity, and the issue was resolved by adding the itextsharp pakage from pakage explorer/manage pakage