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

How do I open file explorer and get selected file path with JS editor?

New Here ,
May 03, 2024 May 03, 2024

I've been trying to create a script to select a pdf containing the front sides of pages and another pdf containing the backside of pages, then combine them with the proper order.
This is what I have so far:

var myDoc = app.newDoc();

var frontSidePg = "<Path to front side pages pdf>";
var backSidePg = "<Path to back side pages pdf>";

// Only here for getting page count
var fDoc = app.openDoc({
    cPath: frontSidePg
});

// Insert front and back pages in correct order
for (var i=0; i<fDoc.numPages; i++) {
    // Front Pages
    myDoc.insertPages({
        nPage : myDoc.numPages-1,
        cPath : frontSidePg,
        nStart: i
    });
    // Back Pages
    myDoc.insertPages({
        nPage : myDoc.numPages-1,
        cPath : backSidePg,
        nStart: fDoc.numPages-i-1
    });
}

myDoc.deletePages({nStart:0}); // Delete blank initial page

I have other co-workers who will likely be using this script so I can't expect them to manually change the file paths each time.

I've tried things like:

app.execMenuItem("Open");
var frontSidePg = String(this.path);

 But it breaks when I try to get the second document needed.

I can't seem to find anything else in the API documentation to help me here.

TOPICS
Acrobat SDK and JavaScript , Windows
190
Translate
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 ,
May 04, 2024 May 04, 2024
LATEST

Hi,

Where are located both front and back pages?

If they are on a sever disk the path is the same for all users. If they are in local, instead of creating a new doc, you can open

one of them then add the other one and save the combined file with a new name... (is this understandablle???).

@+

Translate
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