PDF Driver API活用例
サンプルコード一覧
『PDF Driver API V8.0』に付属するサンプルコードをご紹介します。
入出力と設定ファイルを指定する
入出力ファイルパスと設定ファイル名を指定するサンプルです。
入力ファイルには、Microsoft Word / Excel / PowerPoint、ジャストシステム 一太郎の各形式ファイルを指定してください。
設定ファイルは、PDF Driver APIのインストールフォルダ内の「Settings」フォルダ、あるいは C:\Users\ユーザー名\AppData\Roaming\AntennaHouse\PDF_Driver\8.0\CustomSettings に格納されています。
構文
sampleapi.exe infile outfile settingfile
- infile
- 入力ファイルパス
- outfile
- 出力ファイルパス
- settingfile
- 設定ファイル名
実行イメージ
sampleapi.exe C:\in\test.docx C:\out\out.pdf watermark.ps4
PDF Driver API V8.0 C# サンプル
変換開始:c:\in\test.docx -> c:\out\out.pdf
終了
※ watermark.ps4:あらかじめ、印刷設定ダイアログで「watermark」という名前で「透かし」を設定し保存した設定ファイル
設定を編集する
既存の設定を編集するサンプルです。
入力ファイルには、Microsoft Word / Excel / PowerPoint、ジャストシステム 一太郎の各形式ファイルを指定してください。
構文
sampleapi01.exe infile outfile settingfile save-settingfilepath
- infile
- 入力ファイルパス
- outfile
- 出力ファイルパス
- settingfile
- 既存の設定ファイル名
- save-settingfilepath
- 保存する設定ファイルパス
実行イメージ
sampleapi01.exe C:\in\test.docx C:\out\out.pdf standard.ps4 C:\Settings\edited.ps4
PDF Driver API V8.0 C# サンプル
成功
終了
アドイン変換する
アドインを使用してファイルを変換するサンプルです。
入力ファイルには、Microsoft Word / Excel / PowerPointの各形式ファイルを指定してください。
構文
sampleapi02.exe infile outfile
- infile
- 入力ファイルパス
- outfile
- 出力ファイルパス
実行イメージ
sampleapi02.exe C:\in\test.docx C:\out\out.pdf
PDF Driver API V8.0 C# サンプル
変換開始:c:\in\test.docx -> c:\out\out.pdf
終了
EditSettingSample(出力先指定と設定編集を行う(C++))
PDF Driver 8.0の出力先を指定し、設定を編集するサンプルです。
サンプルでは、指定されたファイルを関連付けられたアプリケーションのprint機能で印刷を行い、同じ場所にPDFを出力します。
構文
EditSettingTest.exe infile
- infile
- 入力ファイルパス
実行イメージ
EditSettingTest.exe C:\in\test.docx
call proc
開始
プリンタ選択: Antenna House PDF Driver 8.0
SelectPrinterに成功
デフォルトプリンタを変更:
(旧) Microsoft Print to PDF
(新) Antenna House PDF Driver 8.0
出力先指定: c:\in\test.docx.pdf
印刷設定
透かし付き(極秘).printSetting3
印刷
1秒待機中...
2秒待機中...
3秒待機中...
4秒待機中...
5秒待機中...
印刷終了
終了: 0
OK
DrvSetNetSample(出力先指定を行う(C#))
PDF Driver 8.0の出力先を指定するC#サンプルです。
c:\sav\sample.pdf にPDFを出力します。
コマンドラインの例
以下は、PDF Driver APIのコマンドラインの例です。
入出力ファイルパスと設定ファイルを指定する
実行イメージ
PdfDrvCmd80.exe -d C:\in\test.docx -o C:\out\out.pdf -i watermark.ps4
エラー表示の例
実行イメージ
PdfDrvCmd80.exe -d C:\in\notexist.docx -o C:\out\out.pdf
convertFile It failed.
errno=150
>echo %errorlevel%
150
- エラーコード
150は、指定されたファイルが見つからないことを示します。 - コマンドラインのエラーコードは、
ERRORLEVELで取得可能です。

