首页 > 解决方案 > 如何将智能 PDF 表单数据导出为没有图像的 excel 格式?

问题描述

我有大量的 PDF 表单(格式相同),我想导出到可过滤的 Excel 文件。这些表格包含贯穿始终的图像。使用 adobe 标准导出时,得到的 .csv 文件包含大量随机字符作为“图像数据”。由于我有这么多 pdf 表格,我显然不想包括这个。将文件导入excel时,由于图像数据,会生成大量的随机字符列和行

我一直在用 VBA 写一些东西来尝试排除无意义的列,但是我的代码太具体而且太慢了。我想要一种更有效的方法来做到这一点。

Sub OpenCSV()

Application.ScreenUpdating = False

Dim FilePath As String, rownumber As Integer, j As Integer

'Select The File

FilePath = Application.GetOpenFilename("Text Files (*.csv),*.csv", , "Select CSV file")

Open FilePath For Input As #1

rownumber = 0

' Loop continues until End Of File

Do Until EOF(1)

Line Input #1, LineFromFile

'Make an array from the file

LineItems = Split(LineFromFile, ",")

j = 0
    For i = 0 To 314

' This If statement removes the images (only works if report is in exact same format)

If i <> 86 And i <> 87 And i <> 88 And i <> 89 Then

Cells(1, 1).Offset(rownumber, j).Value = LineItems(i)

j = j + 1

End If

Next i

rownumber = rownumber + 1
Loop

Close #1

End Sub

这运行缓慢,如果缺少表单条目等通常会导致错误。我愿意改进此代码,或者如果存在某种软件解决方案则放弃它。

标签: vbacsvpdf

解决方案


使用 VBA,您只能提取表单信息而不是图像。请参阅此处的示例:https ://github.com/pdftables/vba-pdftables-api/blob/master/pdftables.vba


推荐阅读