将pdf文件转换为C#中的文本
问题描述:
我需要将.pdf文件转换为.txt文件(或.doc,但我更喜欢.txt).
I need to convert a .pdf file to a .txt file (or .doc, but I prefer .txt).
如何在C#中执行此操作?
How can I do this in C#?
答
Ghostscript 可以做你所需要的.以下是用于将pdf文件中的文本提取到txt文件中的命令(您可以从命令行运行它以测试它是否适合您):
Ghostscript could do what you need. Below is a command for extracting text from a pdf file into a txt file (you can run it from a command line to test if it works for you):
gswin32c.exe -q -dNODISPLAY -dSAFER -dDELAYBIND -dWRITESYSTEMDICT -dSIMPLE -c save -f ps2ascii.ps "test.pdf" -c quit >"test.txt"
在此处检查:代码项目:使用Ghostscript API将PDF转换为图像如何在C#中使用ghostscript的详细信息
Check here: codeproject: Convert PDF to Image Using Ghostscript API for details on how to use ghostscript with C#