c# - 我收到一个错误:CS0116 A namspace cannot directly contain members,例如第 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);
}
}
}
解决方案
您需要加载 ghostcript nuget 包。
点击工具。
Nuget 包管理器。
管理 Nuget 包以获取解决方案。
单击Browse
选项卡
搜索由 Stephan Jimane
安装的 GhostScript.NetCore
推荐阅读
- python - 我的 Python 代码对新实施的方法有任何安全问题吗?
- gdal - 将 GLC2000 数据转换为 netcdf 文件
- angular - 使用 Angular 上的 Service Worker 缓存来自 API 的数据响应
- javascript - 关于 React.memo 和性能优化的问题
- oracle - 是否可以为数据库优先项目自定义 Oracle.EntityFrameworkCore 中的默认映射?
- reactjs - React useContext + TS 错误:“'{}' 上不存在属性”
- docker - 有没有办法知道从 docker 容器中发布了哪个端口?
- typescript - rxjs bindCallback Subscription on mqtt-client message-event 只触发一次,不触发DataQueryResponsesubscriber.next()
- node.js - Mongoose 模式在更新时跳过验证
- pytorch - Xavier 权重 pytorch 实现之间的区别