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

How to export document as FDF, then import said file back into document?

Explorer ,
Jan 23, 2019 Jan 23, 2019

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.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

666

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

Community Expert , Jan 23, 2019 Jan 23, 2019

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

Votes

Translate

Translate
Community Expert ,
Jan 23, 2019 Jan 23, 2019

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

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 ,
Jan 23, 2019 Jan 23, 2019

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? 

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
Community Expert ,
Jan 23, 2019 Jan 23, 2019

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...

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 ,
Jan 23, 2019 Jan 23, 2019

Copy link to clipboard

Copied

LATEST

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​

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