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

Flatten pages using Javascript

New Here ,
May 22, 2018 May 22, 2018

Copy link to clipboard

Copied

I am using a Javascript to fills and save forms from data in a text file (Import.txt). I have managed to save the docs and give them file names using form data. I also save them as pdf/a. But I would also like them flattened. Where and how do I use the this.flattenpages-function?

Here is my script

var fileName = "/Users/admin/Desktop/Create/import.txt";

var outputDir = "/Users/admin/Desktop/Create/";

var err = 0;

var idx = 0;

while (err == 0) {

  err = this.importTextData(fileName, idx); // imports the next record

  if (err == -1)

  app.alert("Error: Cannot Open File");

  else if (err == -2)

  app.alert("Error: Cannot Load Data");

    else if (err == 1)

        app.alert("Warning: Missing Data");

    else if (err == 2)

        app.alert("Warning: User Cancelled Row Select");

    else if (err == 3)

        app.alert("Warning: User Cancelled File Select");

  else if (err == 0) {

        this.flattenpages(); // where does this go?

  this.saveAs(outputDir +”Document_”+ this.getField("Orgnr2").value + ".pdf","com.callas.preflight.pdfa"); // saves the file

  idx++;

  }

}

TOPICS
Acrobat SDK and JavaScript

Views

3.0K

Likes

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
LEGEND ,
May 22, 2018 May 22, 2018

Copy link to clipboard

Copied

LATEST

The Acrobat JavaScript Reference for flattenPages has a working example of the code for an entire PDF.

Likes

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