微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我收到一个错误:CS0116 namspace无法直接包含第3行上的成员,例如字段或方法

如何解决我收到一个错误:CS0116 namspace无法直接包含第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
安装

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。