Copy link to clipboard
Copied
Good evening, I am trying to create a program which will export the PDF document as a FDF file, add pages, then import the FDF file back into itself.
Here is my code, as a javascript action in adobe:
var Pgx = ("G:\Team Drives\GENETICS\LOGISTICS\REC FORMS\REC FORM SHORTCUT\1-LS PGX REC FORM.pdf");
var Cgx = ("G:\Team Drives\GENETICS\LOGISTICS\REC FORMS\REC FORM SHORTCUT\2-MHS CGX REC FORM.pdf");
var File = (this.documentFileName.replace(/.pdf/,""));
this.exportAsFDF({cPath: File(".fdf")});
this.insertPages({cPath: Pgx});
this.insertPages({cPath: Cgx});
this.importAnFDF({cPath: File(".fdf")});
I have tried looking up for what I could find on the forums, and internet, but it seems that my program does not want to add pages, OR export/import FDf files. Any help would be appreciated! I apologize for my lack of coding skill with Java/Javascript.
There are multiple errors in this code... Try this instead:
var fdfFilePath = this.path.replace(".pdf",".fdf"));
var pgxFilePath = "/G/Team Drives/GENETICS/LOGISTICS/REC FORMS/REC FORM SHORTCUT/1-LS PGX REC FORM.pdf";
var cgxFilePath = "/G/Team Drives/GENETICS/LOGISTICS/REC FORMS/REC FORM SHORTCUT/2-MHS CGX REC FORM.pdf";
this.exportAsFDF({cPath: fdfFilePath});
this.insertPages({cPath: pgxFilePath});
this.insertPages({cPath: cgxFilePath});
this.importAnFDF({cPath: fdfFilePath});
Copy link to clipboard
Copied
There are multiple errors in this code... Try this instead:
var fdfFilePath = this.path.replace(".pdf",".fdf"));
var pgxFilePath = "/G/Team Drives/GENETICS/LOGISTICS/REC FORMS/REC FORM SHORTCUT/1-LS PGX REC FORM.pdf";
var cgxFilePath = "/G/Team Drives/GENETICS/LOGISTICS/REC FORMS/REC FORM SHORTCUT/2-MHS CGX REC FORM.pdf";
this.exportAsFDF({cPath: fdfFilePath});
this.insertPages({cPath: pgxFilePath});
this.insertPages({cPath: cgxFilePath});
this.importAnFDF({cPath: fdfFilePath});
Copy link to clipboard
Copied
Amazing, it works like a charm, I noticed the backwards slashes after a created my post... though I do have a question, however:
Is there a way to have the pages being imported, to be imported after the last page?
Copy link to clipboard
Copied
Yes. Change these lines:
this.insertPages({cPath: pgxFilePath});
this.insertPages({cPath: cgxFilePath});
To:
this.insertPages({cPath: pgxFilePath, nPage: this.numPages-1});
this.insertPages({cPath: cgxFilePath, nPage: this.numPages-1});
All of this is documented in the Acrobat JavaScript API Reference, which you should really use if you want to write scripts for Acrobat...
Copy link to clipboard
Copied
Amazing again! Also, I absolutely agree, I have been trying to use the Java API reference more often, it seems my syntax accuracy is the end of me for now. I'll work on that aspect of my code for the future. I really do appreciate your work, and amazing help. try67​