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

CopyFile Seems to Not Work in Adobe Acrobat Protected Mode

New Here ,
Feb 26, 2025 Feb 26, 2025

Copy link to clipboard

Copied

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;
}

 

TOPICS
Create PDFs , Edit and convert PDFs , How to , PDF

Views

53
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
1 ACCEPTED SOLUTION
Community Expert ,
Feb 26, 2025 Feb 26, 2025

Copy link to clipboard

Copied

LATEST

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

Votes

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
Community Expert ,
Feb 26, 2025 Feb 26, 2025

Copy link to clipboard

Copied

LATEST

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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