Adobe Acrobat XI无法将特定PDF转换为Plain Text的问题求助
PDF转Plain Text失败问题排查与解决需求
基础问题
有一份特定版式的PDF,既无法通过Adobe Acrobat XI标准版手动转换/保存为Plain Text格式,使用批量转换脚本处理后也只会生成空白文本文件。
详细问题
批量转换该PDF为文本时,Acrobat XI会弹出提示窗口,点击确定后生成的文本文件依然为空。
批量转换脚本
Sub LoopThroughFiles() Dim StrFile As String Dim pdfPath As String StrFile = Dir("C:\temp\PDFs\") fileRoot = "C:\temp\PDFs\" If Right(fileRoot, 1) <> "\" Then fileRoot = fileRoot & "\" 'ensure terminating \ Do While Len(StrFile) > 0 Debug.Print StrFile pdfPath = fileRoot & StrFile Debug.Print pdfPath success = ConvertPdf2(pdfPath, fileRoot & StrFile & ".txt") StrFile = Dir On Error Resume Next Loop End Sub 'returns true if conversion was successful (based on whether `Open` succeeded or not) Function ConvertPdf2(pdfPath As String, textPath As String) As Boolean Dim AcroXApp As Acrobat.AcroApp Dim AcroXAVDoc As Acrobat.AcroAVDoc Dim AcroXPDDoc As Acrobat.AcroPDDoc Dim jsObj As Object, success As Boolean Set AcroXApp = CreateObject("AcroExch.App") Set AcroXAVDoc = CreateObject("AcroExch.AVDoc") success = AcroXAVDoc.Open(pdfPath, "Acrobat") '<<< returns false if fails If success Then Application.Wait (Now + TimeValue("0:00:2")) 'Helps PC have some time to go through data, can cause PC to freeze without Set AcroXPDDoc = AcroXAVDoc.GetPDDoc Set jsObj = AcroXPDDoc.GetJSObject jsObj.SaveAs textPath, "com.adobe.acrobat.plain-text" AcroXAVDoc.Close False End If AcroXApp.Hide AcroXApp.Exit ConvertPdf2 = success 'report success/failure End Function
错误发生在jsObj.SaveAs textPath, "com.adobe.acrobat.plain-text"语句处。若将格式参数改为"com.adobe.acrobat.accesstext",则能生成文本文件,但不符合需求:
- Plain Text(符合需求):句子保持横向连续,无不必要的换行
- Access Text(不符合需求):句子被强制插入回车分隔,排版碎片化
请问是否可以禁用转换时的弹窗,让Plain Text转换正常执行?或者有其他可行的解决办法?
内容的提问来源于stack exchange,提问作者Nick
相关产品推荐
相关产品推荐

