• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ASFileAcquirePathName returns UNIX-style pathname on Windows

Explorer ,
Jun 26, 2023 Jun 26, 2023

Copy link to clipboard

Copied

I am trying to get the pathname of the active document in Acrobat using the following:

 

ACCB1 std::string ACCB2 GetActiveDocumentFilename() {
 
AVDoc activeDocument = AVAppGetActiveDoc();
if (!activeDocument) {
return "";
}
PDDoc document = AVDocGetPDDoc(activeDocument);
if (!document) {
return "";
}
ASFile file = PDDocGetFile(document);
if (!file) {
return "";
}
ASPathName filePath = ASFileAcquirePathName(file);
if (!filePath) {
return "";
}
 
return ASFileSysDIPathFromPath(NULL, filePath, NULL);
}

 

However, the pathname I get is (for example) /D/Documents/Testing/Test.pdf

 

Is there a way to get a Windows-formatted path/filename?

 

Cheers

Pete

TOPICS
Windows

Views

341

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Jun 26, 2023 Jun 26, 2023

I used ASFileSysDisplayStringFromPath

Votes

Translate

Translate
Explorer ,
Jun 26, 2023 Jun 26, 2023

Copy link to clipboard

Copied

I used ASFileSysDisplayStringFromPath

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 26, 2023 Jun 26, 2023

Copy link to clipboard

Copied

That is only superficially Unix style. What it actually is, is a DIPath (Device Independent Path) which is what is stored inside a PDF for links etc, and what Acrobat always uses internally. But...this code is fundamentally wrong because it treats an ASPathName as a string. Yes, sometimes it is, and sometimes it is binary data which would crash your plug-in. You need to treat an ASPathName as an opaque pointer, and pass it to an API (with the ASFileSys) for conversion. I think you may already have solved that, but it's important to mention it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 26, 2023 Jun 26, 2023

Copy link to clipboard

Copied

LATEST

Thanks for the info, yes I dug a bit further into the documentation and found that method.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines