Skip to content

Commit

Permalink
Validation and optimisations
Browse files Browse the repository at this point in the history
  • Loading branch information
Graham Downs committed Apr 2, 2013
1 parent 57e73bd commit 89a1d55
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
20 changes: 16 additions & 4 deletions SplitPdf/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,26 @@ static void Main(string[] args)
return;
}

Console.WriteLine(string.Format("Generating output file {0}", outputFile));
List<string> files = new List<string>();
foreach (string arg in args)
{
if (arg.ToUpper() != "-M" && arg.ToUpper() != outputFile.ToUpper())
files.Add(arg);
}
ConcatenatePdfs(files, outputFile);

bool allFilesFound = true;
files.ForEach(s =>
{
if (!File.Exists(s))
{
Console.WriteLine(string.Format("File not found: {0}", s));
allFilesFound = false;
return;
}
});

if (allFilesFound)
ConcatenatePdfs(files, outputFile);
}
else
{
Expand All @@ -57,7 +69,7 @@ static void Main(string[] args)
private static void ConcatenatePdfs(List<string> files, string outputFile)
{
PdfDocument outputDocument = new PdfDocument();
foreach (string file in files)
files.ForEach(file =>
{
Console.WriteLine(string.Format("Processing {0}", file));
PdfDocument inputDocument = PdfReader.Open(file, PdfDocumentOpenMode.Import);
Expand All @@ -67,7 +79,7 @@ private static void ConcatenatePdfs(List<string> files, string outputFile)
PdfPage page = inputDocument.Pages[idx];
outputDocument.AddPage(page);
}
}
});
Console.WriteLine(string.Format("Creating output file {0}", outputFile));
outputDocument.Save(outputFile);
}
Expand Down
4 changes: 2 additions & 2 deletions SplitPdf/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.3.0")]
[assembly: AssemblyFileVersion("2.1.3.0")]
[assembly: AssemblyVersion("2.1.4.1")]
[assembly: AssemblyFileVersion("2.1.4.1")]

0 comments on commit 89a1d55

Please sign in to comment.