トラスト・ソフトウェア・システム
トラスト・ソフトウェア・システム

PDF アプリケーション サンプル

PDFファイルを開き、それを構文解析するサンプルアプリケーションを公開します。 ここで示すアプリケーションは、PDF構文を説明するためのものですので、すべてのPDFファイルを構文解析できるものではありません。
このサンプルは、PDF Toolsとは無関係です。PDF構文を説明するための簡単なサンプルアプリケーションの一部です。
前へ <<<

2. Trailerの解析

Trailerは、キーと値のペアが0個以上格納されたディクショナリです。このTrailerを以下のメソッドで解析します。
int ParseTrailer(int offs)
{
    BYTE    *pdf = data.pBlobData;

    //"<<"まで読み飛ばし
    trailerInfo.offs = offs;
    if(ParseObject(&trailerInfo.offs, NULL, &trailerInfo.len))return -1;

    //
    //  構文解析
    //
    string  key;
    int     len;

    for(offs=trailerInfo.offs; offs<(trailerInfo.offs+trailerInfo.len); offs++){
        //キーまで読み飛ばし
        while(true){
            if(offs>=(trailerInfo.offs+trailerInfo.len)) goto end_proc;
            else if(strchr(WHITE_SPACE DELIMITER, (int)pdf[offs])) offs++;
            else break;
        }

        //キー
        for(key=""; !strchr(WHITE_SPACE, (int)pdf[offs]); offs++) key += (char)pdf[offs];

        //値
        while(strchr(WHITE_SPACE, (int)pdf[offs])) offs++;        //white-spaceを読み飛ばし
        int     type;
        if(ParseObject(&offs, &type, &len)) return -5;
        trailer[key] = SPdfData(type, offs, len);
        offs += len;
    }
end_proc:

    return 0;
}
ParseObject( )は、すべてのオブジェクトを解析できるメソッドです。ディクショナリもオブジェクトですが、そこに含まれるコンポーネント(キーや値)もオブジェクトなのでParseObject( )で解析します。
Trailerは解析されて、以下に格納されます。
map<string,SPdfData>    trailer;
SPdfDataは、Trailerの各要素を格納する構造体です。
typedef struct SPdfData_t {
    int     type;        //オブジェクトの種類
    int     offs;        //オブジェクトのオフセット値
    int     len;         //オブジェクトの長さ

    SPdfData_t(){ type=offs=len=0; }
    SPdfData_t(const SPdfData_t &s){ *this=s; }
    SPdfData_t(int t, int o, int l){ type=t; offs=o; len=l; }
} SPdfData, *pSPdfData;
>>> 次へ

サンプル アプリケーションについて

PDFデータを解析できるサンプルアプリケーションを公開しています。PDFParse17_1_0.zip(Winfows版)をダウンロードして、お手元のPDFデータを解析してください。 このアプリケーションのソースコードは、PDF Tools SDKをご購入されたお客様のご希望により開示しています。詳細はお問い合わせください(メール)。


(記載の会社名および製品名は、各社の登録商標および商標です。)
PDF Tools 製品 概要
PDF Security
PDF Validator
PDF to PDF/A Converter
PDF to Image Converter
PDF Imager-LP
Image to PDF Converter
PDF Printer
PDF Prep Tool Suite
PDF Optimizer
PDF Command Line Suite
PDF Extract