我只想检索在Acrobat DC Pro中打开的PDF文档的路径,并在c#中保存到我的数据库的路径,
我能够在c#中获取活动的pdf文档,但无法检索文档的路径,
Type PDFType = Type.GetTypeFromProgID("AcroExch.App");
CAcroApp AcroAppObj = Activator.CreateInstance(PDFType) as CAcroApp;
CAcroAVDoc AvDocObj = AcroAppObj.GetActiveDoc() as CAcroAVDoc;
CAcroPDDoc PdDocObj = AvDocObj.GetPDDoc() as CAcroPDDoc;
object jsObj = pdDocObj.GetJSObject();
现在在 jsObj 我得到System .__ ComObject,如果我使用的是Vb.net,那么我只需将文档的路径作为,
Dim docPath As string
docPath = jsObj.path
但是,C#中不允许这样做,我该怎么办?
答案 0 :(得分:0)
这是获取当前活动Doc路径的另一种解决方案。它使用Acrobat Form api通过js获取路径。附上一个vbs的例子。祝你好运,莱因哈德
Path = "D:\Test.pdf"
Set App = CreateObject("Acroexch.app")
app.show
Set AVDoc = CreateObject("AcroExch.AVDoc")
Set AForm = CreateObject("AFormAut.App") 'from AFormAPI
If AVDoc.Open(Path,"") Then
'// write some js code on a vbs variable
js = "var f = this.path;" &vblf _
& "app.alert(f);"
'//execute the js code
AForm.Fields.ExecuteThisJavaScript js
end if
Set AForm = Nothing
Set AVDoc = Nothing
Set APP = Nothing