[英]I am getting a errors: CS0116 A namspace cannot directly contain members such as fields or methods on Line 3
#nullable enable
using System.Text;
using Ghostscript.NET;
using Ghostscript.NET.Processor;
namespace Metro.MbaProcessing.Core
{
internal static class PdfToText
{
private const string HandleTag = "%handle%";
private const string HandleFormat = "X2";
internal static string Process(string filePath, Encoding encoding)
{
GhostscriptVersionInfo gsv = GhostscriptVersionInfo.GetLastInstalledVersion();
using var processor = new GhostscriptProcessor(gsv);
using var pipedOutput = new GhostscriptPipedOutput();
string outputPipeHandle = $"{HandleTag}{int.Parse(pipedOutput.ClientHandle).ToString(HandleFormat)}";
string[] switches =
{
$"-o{outputPipeHandle}",
"-empty",
"-dQUIET",
"-dSAFER",
"-dBATCH",
"-dNOPAUSE",
"-dNOPROMPT",
"-sDEVICE=txtwrite",
//$"-o{outputPipeHandle}",
"-q",
"-f",
filePath
};
processor.StartProcessing(switches, null);
return encoding.GetString(pipedOutput.Data);
}
}
}
You need to load the ghostcript nuget package.您需要加载 ghostcript nuget 包。
Click on tools.点击工具。
Nuget package manager. Nuget 包管理器。
Manage Nuget Packages for solution.管理 Nuget 包以获取解决方案。
Click Browse
Tab单击
Browse
选项卡
Search for GhostScript.NetCore by Stephan Jimane搜索 Stephan Jimane 的 GhostScript.NetCore
Install安装
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.