Skip to main content
four80eastfan
Participating Frequently
Sep 18, 2017 11:25 PM UTC
Answered

determine if pdf has layers

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!

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Sep 19, 2017 7:44 AM UTC

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

4 replies

JR Boulay
Community Expert
Community Expert
Sep 19, 2017 11:21 AM UTC

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

Translate
Acrobate du PDF, InDesigner et Photoshopographe
try67
Community Expert
Community Expert
Sep 18, 2017 11:32 PM UTC

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

Translate
four80eastfan
Participating Frequently
Sep 19, 2017 12:01 AM UTC

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?

Translate
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Sep 19, 2017 7:44 AM UTC

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

Translate