pCOS Cookbook



Determine which navigation tab (panel) is visible upon opening the document.

Download Java Code  Show Output  Show Input (pCOS-path-reference.pdf) 

 * Determine which navigation tab (panel) is visible upon opening the document.
 * Required software: any pCOS interface 
 * Required data: PDF document
package com.pdflib.cookbook.pcos.pages;

import com.pdflib.IpCOS;
import com.pdflib.cookbook.pcos.pcos_cookbook_example;

public class pagemode extends pcos_cookbook_example {
    /* This is where the data files are. Adjust as necessary. */
    private final static String SEARCH_PATH = "../input";

    public void example_code(IpCOS p, int doc) throws Exception {
        System.out.println("File name: " + p.pcos_get_string(doc, "filename"));

        /* Analyze the document's page mode setting if present */
        String objtype = p.pcos_get_string(doc, "type:/Root/PageMode");

        if (objtype.equals("name"))
             String pagemode = p.pcos_get_string(doc, "/Root/PageMode");

             /* "PageOnly" is an undocumented value created by Acrobat */
             if (pagemode.equals("UseNone") || pagemode.equals("PageOnly"))
                System.out.println("no panel visible");

             else if (pagemode.equals("UseOutlines"))
                System.out.println("bookmark panel visible");

             else if (pagemode.equals("UseThumbs"))
                System.out.println("thumbnail panel visible");

             else if (pagemode.equals("FullScreen"))
                System.out.println("full-screen mode");

             else if (pagemode.equals("UseOC"))
                System.out.println("layer panel visible");

             else if (pagemode.equals("UseAttachments"))
                System.out.println("attachment panel visible");

                System.out.println("unknown page mode '" + pagemode + "'");
            /* PageMode not present or unknown type */
            System.out.println("default setting: no panel visible");

    public pagemode(String[] argv, String readable_name, String search_path) {
        super(argv, readable_name, search_path);

    public static void main(String argv[]) {
        pagemode example = new pagemode(argv, "Initial view", SEARCH_PATH);