Tesseract在Intellij中无法读取PDF,因为’gsdll64’库无法加载。

huangapple go评论95阅读模式
英文:

Tesseract in Intellij cannot read pdf because 'gsdll64' library is unable to load

问题

我正试图使用Tesseract OCR阅读器读取PDF文件。对于图像文件,它表现得相当好。

以下是我所做的:

  1. 创建一个Maven项目。
  2. 将tess4j版本4.4.1添加为依赖项。
  3. 将Java版本更改为13
  4. 添加了以下代码:
import net.sourceforge.tess4j.Tesseract;
import java.io.File;

public class OcrReader {

    public static void main(String[] args) throws Exception{
        String inputFilePath = "C:\\Users\\non\\Desktop\.pdf";

        Tesseract tesseract = new Tesseract();
        tesseract.setDatapath("C:\\Users\\non\\Desktop\\tessdata\\");
        //tesseract.setLanguage("dan");
        String string = tesseract.doOCR(new File(inputFilePath));
        System.out.println(string);
    }
}

然后我得到了以下错误:

10:40:46.208 [main] ERROR net.sourceforge.tess4j.util.PdfGsUtilities - 无法加载库 'gsdll64':
找不到指定的模块。

找不到指定的模块。

找不到指定的模块。

在资源路径中找不到本机库 (win32-x86-64/gsdll64.dll) (C:\Users\non\IdeaProjects\OcrSample\target\classes;C:\Users\non\.m2\repository\net\sourceforge\tess4j\tess4j.4.1\tess4j-4.4.1.jar;C:\Users\non\.m2\repository\net\java\dev\jna\jna.4.0\jna-5.4.0.jar;以及其他的路径...)
    
10:40:46.849 [main] DEBUG org.apache.fontbox.ttf.PostScriptTable - 未为字体Cambria提供PostScript名称信息

我应该如何解决这个问题?

英文:

I am attempting to read a pdf with the Tesseract OCR reader. It works for image files quite well though.

Here is what I have done:

  1. Create a Maven Project.

  2. Added tess4j version 4.4.1 as a dependency.

  3. Changed java version to 13.

  4. Added the following code:

     import net.sourceforge.tess4j.Tesseract;
    
     import java.io.File;
    
     public class OcrReader {
    
     public static void main(String[] args) throws Exception{
         String inputFilePath = "C:\\Users\\non\\Desktop\.pdf";
    
         Tesseract tesseract = new Tesseract();
         tesseract.setDatapath("C:\\Users\\non\\Desktop\\tessdata\\");
       //tesseract.setLanguage("dan");
         String string = tesseract.doOCR(new File(inputFilePath));
         System.out.println(string);
     }
     }
    

I get the following error afterwards:

10:40:46.208 [main] ERROR net.sourceforge.tess4j.util.PdfGsUtilities - Unable to load library 'gsdll64':
The specified module could not be found.

The specified module could not be found.

The specified module could not be found.

Native library (win32-x86-64/gsdll64.dll) not found in resource path (C:\Users\non\IdeaProjects\OcrSample\target\classes;C:\Users\non\.m2\repository\net\sourceforge\tess4j\tess4j.4.1\tess4j-4.4.1.jar;C:\Users\non\.m2\repository\net\java\dev\jna\jna.4.0\jna-5.4.0.jar;C:\Users\non\.m2\repository\com\github\jai-imageio\jai-imageio-core.4.0\jai-imageio-core-1.4.0.jar;C:\Users\non\.m2\repository\org\ghost4j\ghost4j.0.1\ghost4j-1.0.1.jar;C:\Users\non\.m2\repository\log4j\log4j.2.17\log4j-1.2.17.jar;C:\Users\non\.m2\repository\commons-beanutils\commons-beanutils.9.2\commons-beanutils-1.9.2.jar;C:\Users\non\.m2\repository\commons-collections\commons-collections.2.1\commons-collections-3.2.1.jar;C:\Users\non\.m2\repository\org\apache\xmlgraphics\xmlgraphics-commons.4\xmlgraphics-commons-1.4.jar;C:\Users\non\.m2\repository\com\lowagie\itext.1.7\itext-2.1.7.jar;C:\Users\non\.m2\repository\org\apache\pdfbox\pdfbox.0.17\pdfbox-2.0.17.jar;C:\Users\non\.m2\repository\org\apache\pdfbox\fontbox.0.17\fontbox-2.0.17.jar;C:\Users\non\.m2\repository\commons-logging\commons-logging.2\commons-logging-1.2.jar;C:\Users\non\.m2\repository\org\apache\pdfbox\pdfbox-tools.0.17\pdfbox-tools-2.0.17.jar;C:\Users\non\.m2\repository\org\apache\pdfbox\pdfbox-debugger.0.17\pdfbox-debugger-2.0.17.jar;C:\Users\non\.m2\repository\org\apache\pdfbox\jbig2-imageio.0.2\jbig2-imageio-3.0.2.jar;C:\Users\non\.m2\repository\commons-io\commons-io.6\commons-io-2.6.jar;C:\Users\non\.m2\repository\net\sourceforge\lept4j\lept4j.12.3\lept4j-1.12.3.jar;C:\Users\non\.m2\repository\org\jboss\jboss-vfs.2.14.Final\jboss-vfs-3.2.14.Final.jar;C:\Users\non\.m2\repository\org\jboss\logging\jboss-logging.1.4.GA\jboss-logging-3.1.4.GA.jar;C:\Users\non\.m2\repository\ch\qos\logback\logback-classic.2.3\logback-classic-1.2.3.jar;C:\Users\non\.m2\repository\ch\qos\logback\logback-core.2.3\logback-core-1.2.3.jar;C:\Users\non\.m2\repository\org\slf4j\slf4j-api.7.25\slf4j-api-1.7.25.jar;C:\Users\non\.m2\repository\org\slf4j\jul-to-slf4j.7.28\jul-to-slf4j-1.7.28.jar;C:\Users\non\.m2\repository\org\slf4j\jcl-over-slf4j.7.28\jcl-over-slf4j-1.7.28.jar;C:\Users\non\.m2\repository\org\slf4j\log4j-over-slf4j.7.28\log4j-over-slf4j-1.7.28.jar)

10:40:46.849 [main] DEBUG org.apache.fontbox.ttf.PostScriptTable - No PostScript name information is provided for the font Cambria

How do I go about solving this?

答案1

得分: 1

你是否正确安装了Ghostscript?

应该包含一个名为gsdll32.dll的文件。

如果没有,可以从以下链接 https://www.ghostscript.com/download/gsdnld.html 下载适用于Win64的Ghostscript安装程序并运行它。

安装完成后,应该在目录%your_install_dir%\gs\gs9.05\bin\中找到一个名为gsdll64.dll的文件。

希望这能解决你的问题。

英文:

Do you install Ghostscript correctly?

It should include a file gsdll32.dll.

If not, download the Ghostscript installer for Win64 from this link https://www.ghostscript.com/download/gsdnld.html and run it.

After the installation, there should be a file gsdll64.dll in the directory

%your_install_dir%\gs\gs9.05\bin\

I hope this will solve your issue.

huangapple
  • 本文由 发表于 2020年5月5日 16:47:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/61609212.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定