想从PDF档案中抽当中想要文字
时间:2014-03-18
来源:互联网
想从PDF档案中search个keyword, 然后copy keyword后面若干个字出来. 因档案成千个, 每个档只系要十多行字, 用肉眼睇有排
小弟试个用php pdf phaser, 但只要pdf入面keyword多个一个, 就抽错晒
各位高手请问除左php, 仲有冇api or language 可以处理到抽到pdf既文字? 大家有冇类似经验或遇上同样情况?
我见其实好多文件都用pdf, 文件一多, 如果可以自动抽到当中想要文字系好方便.
小弟试个用php pdf phaser, 但只要pdf入面keyword多个一个, 就抽错晒

各位高手请问除左php, 仲有冇api or language 可以处理到抽到pdf既文字? 大家有冇类似经验或遇上同样情况?
我见其实好多文件都用pdf, 文件一多, 如果可以自动抽到当中想要文字系好方便.
作者: leefrk17 发布时间: 2014-03-18
If you are java programmer, you can try pdfbox library.
http://pdfbox.apache.org/
http://pdfbox.apache.org/
作者: McLoneIII 发布时间: 2014-03-18
引用:原帖由 leefrk17 於 2014-1-19 05:27 AM 发表
想从PDF档案中search个keyword, 然后copy keyword后面若干个字出来. 因档案成千个, 每个档只系要十多行字, 用肉眼睇有排
小弟试个用php pdf phaser, 但只要pdf入面keyword多个一个, 就抽错晒
各位高 ...
http://itextpdf.com/product/itext想从PDF档案中search个keyword, 然后copy keyword后面若干个字出来. 因档案成千个, 每个档只系要十多行字, 用肉眼睇有排
小弟试个用php pdf phaser, 但只要pdf入面keyword多个一个, 就抽错晒

各位高 ...
Download itextsharp.dll, 果度有API 畀你睇点用, 除左.net, Java 都有
Powershell:
复制内容到剪贴板代码:Add-Type -Path .\itextsharp.dll
$pdfs = (gci . -include "*.pdf" -recurse)
foreach($pdf in $pdfs) {
[string[]]$Text = $null
$reader = New-Object iTextSharp.text.pdf.pdfreader -ArgumentList $pdf.FullName
for ($page = 1; $page -le $reader.NumberOfPages; $page++) {
$strategy = new-object 'iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy'
$pageText = [iTextSharp.text.pdf.parser.PdfTextExtractor]::GetTextFromPage($reader, $page, $strategy);
$Text += $pageText.split("`n")
}
$reader.Close();
$Text | select-string "hello world"
}
当你抄左去 current directory, 响 current directory 下面揾哂*.pdf, search "hello world" $pdfs = (gci . -include "*.pdf" -recurse)
foreach($pdf in $pdfs) {
[string[]]$Text = $null
$reader = New-Object iTextSharp.text.pdf.pdfreader -ArgumentList $pdf.FullName
for ($page = 1; $page -le $reader.NumberOfPages; $page++) {
$strategy = new-object 'iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy'
$pageText = [iTextSharp.text.pdf.parser.PdfTextExtractor]::GetTextFromPage($reader, $page, $strategy);
$Text += $pageText.split("`n")
}
$reader.Close();
$Text | select-string "hello world"
}
作者: lohengrin 发布时间: 2014-03-18
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28