PDFlib
KAUFEN
PDFlib

interchange/pdfa

Retrieve PDF/A status and output intents.

Download Java Code     Show Output     Show Input PDF

package com.pdflib.cookbook.pcos.interchange;


import com.pdflib.pCOS;

import com.pdflib.pCOSException;

import com.pdflib.cookbook.pcos.pcos_cookbook_example;


/**

 * Retrieve PDF/A status and output intents.

 * <p>

 * Required software: pCOS interface 3 (pCOS 2.x, PDFlib 7.x, TET 2.2,

 * PLOP 3.x)<br>

 * Required data: PDF document

 *

 * @version $Id: pdfa.java,v 1.4 2007/09/19 08:45:31 stm Exp $

 */

public class pdfa 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(pCOS p, String filename) throws pCOSException, Exception {

        /* Open the PDF document */

        int doc = p.open_document(filename, "");

        if (doc == -1)

            throw new Exception("Error: " + p.get_errmsg());

       

        System.out.println("File name: " + p.get_string(doc, "filename"));

       

        String pdfa_status = p.get_string(doc, "pdfa");


        if (pdfa_status.equals("none")) {

            System.out.println("PDF/A version: (none)");

        }

        else {

            System.out.println("PDF/A version: '" + pdfa_status + "'");


            int output_intent_count = (int) p.get_number(doc, "length:/Root/OutputIntents");

           

            for (int oi = 0; oi < output_intent_count; oi += 1) {

                System.out.println("Output intent " + (oi + 1));

               

                String objtype = p.get_string(doc,

                    "type:/Root/OutputIntents[" + oi + "]/OutputConditionIdentifier");

       

                if (objtype.equals("string")) {

                    System.out.println("   identifier: '"

                        + p.get_string(doc,

                            "/Root/OutputIntents[" + oi + "]/OutputConditionIdentifier")

                        + "'");

       

                    objtype = p.get_string(doc,

                        "type:/Root/OutputIntents[" + oi + "]/Info");

       

                    if (objtype.equals("string")) {

                        System.out.println("  output info: '"

                                + p.get_string(doc,

                                    "/Root/OutputIntents[" + oi + "]/Info")

                                + "'");

                    }

                }

            }

        }

       

        p.close_document(doc);

    }

   

    public pdfa(String[] argv, String readable_name,

        String search_path, String full_rcs_file_name, String revision) {

        super(argv, readable_name, search_path, full_rcs_file_name, revision);

    }


    public static void main(String argv[]) {

        pdfa example = new pdfa(argv,

            "PDF/A status", SEARCH_PATH,

            "$RCSfile: pdfa.java,v $", "$Revision: 1.4 $");

        example.execute();

    }

}