PDFlib pCOS サンプル集(クックブック)
pCOS インターフェースで、PDF 文書に含まれるすべてのアーティクルの一覧を作成するサンプルプログラムです。
必要な製品:pCOS インターフェース(PDI、PPS、TET、PLOP、PLOP DS、TET PDF IFilter に内蔵されています。)
/*
* Create a list of all articles contained in a PDF document
*
* Required software: pCOS interface 8 (PDFlib+PDI/PPS 9, TET 4.1, PLOP 5.0)
* Required data: PDF document
*/
package com.pdflib.cookbook.pcos.interactive;
import com.pdflib.IpCOS;
import com.pdflib.cookbook.pcos.pcos_cookbook_example;
public class articles 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"));
/* Get the number of articles in the document */
int articlecount = (int) p.pcos_get_number(doc, "length:articles");
System.out.print(articlecount + " articles");
if (articlecount > 0) {
System.out.print(":");
}
System.out.println();
/* For all articles print all its beads */
for (int i = 0; i < articlecount; ++i) {
System.out.println("Title: '"
+ p.pcos_get_string(doc, "articles[" + i + "]/I/Title") + "'");
int beadcount = (int) p.pcos_get_number(doc, "length:articles[" + i
+ "]/beads");
for (int k = 0; k < beadcount; ++k) {
System.out.println(" page "
+ (int) p.pcos_get_number(doc, "articles[" + i + "]/beads["
+ k + "]/destpage"));
}
}
}
public articles(String[] argv, String readable_name, String search_path) {
super(argv, readable_name, search_path);
}
public static void main(String argv[]) {
articles example = new articles(argv, "Articles", SEARCH_PATH);
example.execute();
}
}
(Nov 10, 2010 - Oct 19, 2022)