determine if pdf has layers

New Here ,
Sep 18, 2017

Copy link to clipboard

Copied

I'm trying to determine if a pdf has layers (I'm very new to Javascript and this API). Below is the function that I've written for this:

var check_flat = function()

{

    for(var page = 0; page < this.numPages; page++){

        var ocgArray = this.getOCGs(page);

        if(ocgArray != null){

            console.println(page + " has layers");

        } else{

            console.println("no layers on this page");

        }

    }

};

When I try this on a pdf that I'm certain has layers, I only get 'no layers on this page'. Your help is very much appreciated!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

You are mistaken. They are form fields or comments (annotations).

TOPICS
Acrobat SDK and JavaScript

Views

602

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

determine if pdf has layers

New Here ,
Sep 18, 2017

Copy link to clipboard

Copied

I'm trying to determine if a pdf has layers (I'm very new to Javascript and this API). Below is the function that I've written for this:

var check_flat = function()

{

    for(var page = 0; page < this.numPages; page++){

        var ocgArray = this.getOCGs(page);

        if(ocgArray != null){

            console.println(page + " has layers");

        } else{

            console.println("no layers on this page");

        }

    }

};

When I try this on a pdf that I'm certain has layers, I only get 'no layers on this page'. Your help is very much appreciated!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

You are mistaken. They are form fields or comments (annotations).

TOPICS
Acrobat SDK and JavaScript

Views

603

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
Sep 18, 2017 0
Most Valuable Participant ,
Sep 18, 2017

Copy link to clipboard

Copied

The code looks fine. Are you sure the file actually has layers?

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
Reply
Loading...
Sep 18, 2017 1
New Here ,
Sep 18, 2017

Copy link to clipboard

Copied

Thanks for the reply. I've tried with text buttons, comments, and e-signatures. Am I correct in thinking that these are in their own layers or am I mistaken?

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
Reply
Loading...
Sep 18, 2017 0
Most Valuable Participant ,
Sep 19, 2017

Copy link to clipboard

Copied

You are mistaken. They are form fields or comments (annotations).

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
Reply
Loading...
Sep 19, 2017 1
Adobe Community Professional ,
Sep 19, 2017

Copy link to clipboard

Copied

Unlike in an InDesign document, in an Acrobat PDF form fields are not attached to a layer, they are floating above layers.

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
Reply
Loading...
Sep 19, 2017 1