Skip to main content
Participant
February 27, 2025
Answered

CopyFile Seems to Not Work in Adobe Acrobat Protected Mode

  • February 27, 2025
  • 1 reply
  • 309 views

Hi everyone,

I’m facing an issue while trying to copy an entire document in Adobe Acrobat Protected Mode. The same code works perfectly fine in Non-Protected Mode, but it fails in Protected Mode.

I have already:
Given the right permissions to my working directory.
Whitelisted my entire C drive.

Still, the CopyFile operation doesn't seem to work. I am not sure what I am missing, and I hope someone can point me in the right direction. Here is the relevant code:

 

AVDoc avDoc = AVAppGetActiveDoc();
PDDoc doc = AVDocGetPDDoc(avDoc);
PDDocSave(doc, PDSaveIncremental, NULL, ASGetDefaultFileSys(), NULL, NULL); // Save first

ASFile f = PDDocGetFile(doc);
ASFileSys fs = ASFileGetFileSys(f);
ASPathName pn = ASFileAcquirePathName(f);
char* fn = ASFileSysDisplayStringFromPath(fs, pn);
char bfn[MAX_PATH + 1], nfn[MAX_PATH + 1];

StringCopy(bfn, sizeof(bfn), fn);
PathRemoveExtension(bfn);
StringCat(bfn, sizeof(bfn), " - Copy");
StringCopy(nfn, sizeof(nfn), bfn);
StringCat(nfn, sizeof(nfn), ".pdf");

for (int i = 2; i < 100; i++) {
    if (!PathFileExists(nfn))
        break;
    StringPrintf(nfn, sizeof(nfn), "%s%d.pdf", bfn, i);
}

if (!CopyFile(fn, nfn, TRUE)) {
    MessageBox(NULL, "Error copying file", "Error", MB_OK | MB_ICONERROR);
    throw 0;
}

 

Correct answer Thom Parker

Protected mode restricts access to the local file system, so the Windows API functions won't work, unless you create a broker. 

But the solution is simple. Save the PDF to the new location using the Acrobat SDK functions. Then you avoid the restriction.

 

 

1 reply

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
February 27, 2025

Protected mode restricts access to the local file system, so the Windows API functions won't work, unless you create a broker. 

But the solution is simple. Save the PDF to the new location using the Acrobat SDK functions. Then you avoid the restriction.

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often