-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
41 lines (37 loc) · 1.3 KB
/
Copy pathProgram.cs
File metadata and controls
41 lines (37 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using Ghostscript.NET;
using Ghostscript.NET.Processor;
using System.Diagnostics;
namespace GhostExtract
{
internal class Program
{
static void Main(string[] args)
{
// https://github.com/ArtifexSoftware/Ghostscript.NET/issues/107
string outputText = null;
string strFullnameOutput = Path.Combine(Environment.CurrentDirectory, "input.pdf");
// Ensure the Ghostscript DLL is accessible (gsdll64.dll or gsdll32.dll)
GhostscriptVersionInfo gsv = GhostscriptVersionInfo.GetLastInstalledVersion();
List<string> switches = new List<string>();
switches.Add("-empty");
switches.Add("-dQUIET");
switches.Add("-dNOSAFER");
switches.Add("-dBATCH");
switches.Add("-dNOPAUSE");
switches.Add("-sDEVICE=txtwrite");
switches.Add($"-sOutputFile={outputText}");
switches.Add(strFullnameOutput);
try
{
using (GhostscriptProcessor processor = new GhostscriptProcessor(gsv))
{
processor.StartProcessing(switches.ToArray(), null);
}
}
catch (Exception ex)
{
Debug.Write(ex.Message);
}
}
}
}