39 lines
1.4 KiB
C#
39 lines
1.4 KiB
C#
using System.Diagnostics;
|
|
|
|
namespace PDFWorkflowManager
|
|
{
|
|
public static class PdfService
|
|
{
|
|
public static void MergePdfs(string pdfToolkitPath, string inputPattern, string bannerPage, string outputFile)
|
|
{
|
|
var startInfo = new ProcessStartInfo
|
|
{
|
|
FileName = pdfToolkitPath,
|
|
Arguments = $"\"{inputPattern}\" {bannerPage} cat output \"{outputFile}\"",
|
|
UseShellExecute = false,
|
|
RedirectStandardOutput = true,
|
|
CreateNoWindow = true
|
|
};
|
|
using (var process = Process.Start(startInfo))
|
|
{
|
|
process.WaitForExit();
|
|
}
|
|
}
|
|
|
|
public static void UpdatePdfMetadata(string ghostScriptPath, string tempFile, string metadataFile, string outputFile)
|
|
{
|
|
var startInfo = new ProcessStartInfo
|
|
{
|
|
FileName = ghostScriptPath,
|
|
Arguments = $"-dBATCH -dNOPAUSE -dAutoRotatePages=/None -sDEVICE=pdfwrite -sOutputFile=\"{outputFile}\" \"{tempFile}\" \"{metadataFile}\"",
|
|
UseShellExecute = false,
|
|
RedirectStandardOutput = true,
|
|
CreateNoWindow = true
|
|
};
|
|
using (var process = Process.Start(startInfo))
|
|
{
|
|
process.WaitForExit(120000);
|
|
}
|
|
}
|
|
}
|
|
} |