提取所有文本
Contents
[
Hide
]如何提取所有文本
问题: 如何提取所有文本。
提示: 为此,您可以使用 GetStrings 方法,它允许您获取整个文本。
注意: 您可以从底层绘图中提取所有文本。 下面是提取所有文本的示例。 附上控制台输出结果(ExtractTextResult.bmp)和源文件(ExtractText.dwg)。
示例:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string fileName = "ExtractText"; | |
string file = string.Format("{0}.dwg", fileName); | |
using (FileStream inStream = new FileStream(file, FileMode.Open)) | |
using (CadImage image = (CadImage)Image.Load(inStream)) | |
{ | |
foreach (string s in image.GetStrings()) | |
{ | |
Console.WriteLine(s); | |
} | |
} |