I am trying to merge 52+ files and every time I merge 52 or a bit less, the output file has a wrong extension. aka "dirpath\OUTPUT.pd" or even "dirpath\OUTPUTpdf". When I try to merge more than 52 files the output file is corrupt and cannot be opened.
I can send a batch file for reference if needed.
Please help ASAP.
Thank you,
Customer
-------------------------------------------------------------------------
You can use a .txt file to merge lots of PDF files into one PDF file, please by following steps to try,
1. Please run following command line to get all filenames for all of your PDF files,
dir C:\pdf\*.pdf /s/b > C:\files.txt
Note: you can adjust the order for files in C:\files.txt by manual.
2. Please run following command line merge these PDF files into a PDF file,
"C:\Program Files\PDF Split-Merge v3.0\pdfpg.exe" C:\files.txt C:\out.pdf
The command line application is better than GUI version if you wish merge 1000+ PDF files into one PDF file.
The pdfpg.exe application is located in the PDF Split-Merge installation folder.
VeryPDF
-------------------------------------------------------------------------
Instead of using a text file I have directed the entire output to a batch file that contains the command and all the files. This is the only way I can get the full execution through my .NET program. This works perfectly with a hand full of files and only messes up when I have more than 52 files. Please help.
Customer
-------------------------------------------------------------------------
The length of Windows Command Line is limited to 4096 characters (maybe 1024 characters on Windows XP), if the length of your command line too long, you need put these PDF filenames into a .txt file, then you can call pdfpg command line to merge PDF files included in this .txt to PDF file properly.
VeryPDF
-------------------------------------------------------------------------
Thank you for the excellent tip. Would you by chance have an example to execute pdfpg with C# using a text file?
Customer
-------------------------------------------------------------------------
Thanks for your message, please refer to following C# code, we hoping this C# example will useful to you,
using System.Diagnostics;
class Program
{
static void Main()
{
LaunchCommandLineApp();
}
/// <summary>
/// Launch the legacy application with some options set.
/// </summary>
static void LaunchCommandLineApp()
{
// Use ProcessStartInfo class
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "D:\\pdfpg.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = "D:\\files.txt D:\\out.pdf";
try
{
// Start the process with the info we specified.
// Call WaitForExit and then the using statement will close.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch
{
// Log error.
}
}
}
VeryPDF