public bool MergePDFFiles(List <string> pdfFiles, string outPdfFileName, out string err) { bool result = false; int count = 0; err = ""; try { if (isLibraryLoaded == false) { result = LoadPDFLib(); if (result == false) { return(result); } } if (pdfFiles != null) { foreach (string fileName in pdfFiles) { pdfLib.AddToFileList("PDFList", fileName); } if (string.IsNullOrWhiteSpace(outPdfFileName)) { outPdfFileName = "MergedPdf.pdf"; } count = pdfLib.MergeFileList("PDFList", Path.Combine(Path.GetDirectoryName(pdfFiles[0]), outPdfFileName)); //int FileHandle = pdfLib.DAOpenFileReadOnly(Path.Combine(Path.GetDirectoryName(pdfFiles[0]), outPdfFileName), ""); //if (FileHandle == 0) //{ // err += "Debenu Error Code " + pdfLib.LastErrorCode().ToString(); // //LogManager.Trace("PWPPDFMgr::ExtractPDFPages", TraceCategoryType.Error, "DAOpenFileReadOnly failed - Unable to open file-srcpath", srcpath, "errorcode", errorcode.ToString()); // return result; //} //pdfLib.ClearPageLabels(); //pdfLib.AddPageLabels(0, 2, 1, "Page "); //if (FileHandle != -1) //{ // pdfLib.DACloseFile(FileHandle); //} result = (count == pdfFiles.Count); } } catch (Exception ex) { err += ex.Message + "\n"; err += pdfLib.LastErrorCode(); } return(result); }