0

I just wish to retrieve the path of PDF document opened in Acrobat DC Pro, and save paths to my database in c#,

I able to get active pdf document in c# but unable to retrieve path of the document,

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();

Now in jsObj I get System.__ComObject, if I am using Vb.net, then I get path of document simply as,

Dim docPath As string
docPath = jsObj.path

but, it is not allowed in C#, what should I do?

H. Pauwelyn
  • 13,575
  • 26
  • 81
  • 144
Aniket Bhansali
  • 630
  • 12
  • 33

1 Answers1

0

Here another solution to get the path of the current active Doc. It uses Acrobat Form api to get the path via js. Attached a vbs example. Good luck, Reinhard

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
ReFran
  • 897
  • 8
  • 14