I am using this to merge 2 pad files:
public static void MergePages(string outputPdfPath, string[] lstFiles)
{
lstFiles = new string[2] { @"Downloads\Certificates\119.FDV-3686.pdf",
@"Downloads\Certificates\119.FDV-3686.pdf" };
outputPdfPath = @"Downloads\Certificates\";
PdfReader reader = null;
Document sourceDocument = null;
PdfCopy pdfCopyProvider = null;
PdfImportedPage importedPage;
sourceDocument = new Document();
pdfCopyProvider = new PdfCopy(sourceDocument,
new System.IO.FileStream(outputPdfPath, System.IO.FileMode.Create));
sourceDocument.Open();
try
{
for (int f = 0; f < lstFiles.Length - 1; f++)
{
int pages = 1;
reader = new PdfReader(lstFiles[f]);
//Add pages of current file
for (int i = 1; i <= pages; i++)
{
importedPage = pdfCopyProvider.GetImportedPage(reader, i);
pdfCopyProvider.AddPage(importedPage);
}
reader.Close();
}
sourceDocument.Close();
}
catch (Exception ex)
{
throw ex;
}
}
The 2 files exists in my project directory but it throws error:
Could not find a part of the path 'C:\Program Files (x86)\IIS Express\~\Downloads\Certificates\119.FDV-3686.pdf'.
I don't understand why it goes to C
drive since files are in the same project.