Jump to content

Retrieve full path of PDF document


Recommended Posts

Hi,

I would like to know if it is possible to retrieve the name and the full path of an adobe PDF document which is actually opened.

_Wingettitle() gives me the full name (test.pdf), but i would like to know what the location (C:\documents\) of the document is.

Adobe 10 doen't display it in the windowtitle, but it is there in te properties tab (file-properties-location)

I searched the forums, but I can only find a way to retrieve the path of the Adobe application(and that is not what I'm looking for)

Any ideas?

Link to comment
Share on other sites

  • Moderators

albertmaathuis,

Do you not have a path to open the PDF file in the first place? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Yes and No,

Of course I have opened the PDF docs in the first place, but i open e.g 10 PDF's from differt locations.

After that I am going to manipulate one ore more PDF's (add other PDF or overlay with watermark and so on)

For saving the document in the right place I would like to know its first name and location, verify if its the right one and then save it with a different name on the same location.

Link to comment
Share on other sites

Maybe _PathSplit?

_PathSplit

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • Moderators

albertmaathuis,

But you have just told us that you do! :huh:

Of course I have opened the PDF docs in the first place, but i open e.g 10 PDF's from differt locations

So save those locations in an array which you can then access later:

For saving the document in the right place I would like to know its first name and location

You pull the location of that first PDF from the array and use _PathSplit to extract the data. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I'm sorry perhaps I didn't explain it clearly.

I open the PDF e.g by double clicing on the document, or I have made the pdf from word or excel by saving it to a PDF printer.

So the PDF's are opened and on the desktop. Then I start my program, and I attach to lets say PDF document number3

The program sets an overlay (e.g. a logo) on PDF document3 and then saves it on the original location (which i do not know) under a differnt name.

If the PDF's wher openend from within autoit, then there would be no problem.

Link to comment
Share on other sites

Use the autoit info tool. I believe that window should be stagnant, so you can get the control's handle by instance (use the controlNN, examples are present).

Help file for: ControlGetHandle, and ControlGetText

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

you have to show us what you are working with (your script: only the part about manipulating the properties window), so we can help.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Here is part of the script I'm working on.

Open a PDF document and a Word document, than run the script (no need to make an executable, just run it in the scite editor)

Running the script will show from the PDF document only the name and from the word document the path name

I realize that the PDF part is different from the word part, but that is the reason for this post.

;Open a PDF document by double click or start adobe reader and open a PDF document

;Running this script will only show the title (=name) of then PDF document

$handle = WinGetHandle("test.pdf", "")

msgbox(0,"handle=",$handle)

$test = WinGetTitle($handle)

msgbox(0,"windowtitle=",$test)

;this is the way it works with Microsoft Word

;Open a word document and run the script

$oWord = ObjGet("","Word.Application")

$oDocs = $oWord.Documents

$wordaanwezig=0

For $o In $oDocs

msgbox(0,"Pathname=",$o.Path)

msgbox(0,"Fullname=",$o.FullName)

Next

Link to comment
Share on other sites

Not sure what your question is...if you can't find the pdf handle, use something like this (loop through the array, and grab the handle you need)

#include <Array.au3>
$aPDF = WinList("[Class:AcrobatSDIWindow]")
_ArrayDisplay($aPDF)
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Tried, but it only gives me the handle of the active PDF document (with the name) and the handle of adobe reader.

Not the filepath, and with the handles I cann't find the path of the active document.

I was hoping there would be something simular as in the word environment:

Something like:

$oPDF = ObjGet("","[Class:AcrobatSDIWindow]")

$oPDFs = $oPDF.Documents

For $o In $oPDFs

msgbox(0,"Pathname=",$o.Path)

msgbox(0,"Fullname=",$o.FullName)

Next

But this gives me an error on "documents" ( Variable must be of type object)

Perhaps the line $oPDF.Documents is not document, but something else...?

Searching the internet I found something which doesn't make me happy.

http://forums.adobe.com/message/1161198#1161198

So I think it is not possible to extract the path in a simple way.

Link to comment
Share on other sites

  • Moderators

albertmaathuis,

Just look at the list of recently opened files in the Registry. This code works for my Acrobat Reader - just substitute the relevant location for your Adobe version: ;)

; Set the location
Local $sReg = "HKEY_CURRENT_USER\Software\Adobe\Acrobat Reader\7.0\AVGeneral\cRecentFiles"
; Extract the recent file keys
For $i = 1 To 100
    Local $sKey = RegEnumKey($sReg, $i)
    If @error <> 0 Then
        ; No more keys
        ExitLoop
    Else
        ; Read the key - it is stored in binary so convert it
        Local $sVal = BinaryToString(RegRead($sReg & "\" & $sKey, "tDIText"))
        MsgBox(4096, $i, $sVal)
    EndIf
Next

That should get you what you need. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

albertmaathuis,

Glad I could help. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...