/*
Antenna House PDF Tool API V8.0
C++ Interface sample program
概要:文書情報の取得(バージョン・文書情報・PDFの開き方・セキュリティ情報)
Copyright 2013-2026 Antenna House, Inc.
*/
#include < PdfTk.h >
#include < stdio.h >
using namespace PdfTk;
int showAction(PtlAction& action);
int showDest(PtlDest& dest);
int main(int argc, char* argv[])
{
if (argc < 2) {
printf("usage: GetDocInfo_2.exe in-pdf-file\n");
return 1;
}
try
{
PtlParamInput input(argv[1]);
PtlPDFDocument doc;
// PDFファイルをロードします。
doc.load(input);
//PDFの文書プロパティ
PtlDocProperty& docproperty = doc.getDocProperty();
printf("PDF Version\n");
switch (docproperty.getVersion())
{
case PtlDocProperty::PDF_VERSION::PDFV1_0: // PDF-1.0
printf(" major : 1\n");
printf(" minor : 0\n");
break;
case PtlDocProperty::PDF_VERSION::PDFV1_1: // PDF-1.1
printf(" major : 1\n");
printf(" minor : 1\n");
break;
case PtlDocProperty::PDF_VERSION::PDFV1_2: // PDF-1.2
printf(" major : 1\n");
printf(" minor : 2\n");
break;
case PtlDocProperty::PDF_VERSION::PDFV1_3: // PDF-1.3
printf(" major : 1\n");
printf(" minor : 3\n");
break;
case PtlDocProperty::PDF_VERSION::PDFV1_4: // PDF-1.4
printf(" major : 1\n");
printf(" minor : 4\n");
break;
case PtlDocProperty::PDF_VERSION::PDFV1_5: // PDF-1.5
printf(" major : 1\n");
printf(" minor : 5\n");
break;
case PtlDocProperty::PDF_VERSION::PDFV1_6: // PDF-1.6
printf(" major : 1\n");
printf(" minor : 6\n");
break;
case PtlDocProperty::PDF_VERSION::PDFV1_7: // PDF-1.7
printf(" major : 1\n");
printf(" minor : 7\n");
break;
case PtlDocProperty::PDF_VERSION::PDFV2_0: // PDF-2.0
printf(" major : 2\n");
printf(" minor : 0\n");
break;
case PtlDocProperty::PDF_VERSION::PDFV_UNSUPPORTED: // 未サポートのバージョン
printf(" 未サポートのバージョン\n");
break;
}
//PDFの文書情報
printf("\n");
PtlDocInfo& docinf = docproperty.getDocInfo();
printf("Document Information\n");
//タイトル取得
PtlParamString title = docinf.getTitle();
printf(" Title : %s\n", title.c_str());
//サブジェクト取得
PtlParamString subject = docinf.getSubject();
printf(" Subject : %s\n", subject.c_str());
//著者取得
PtlParamString author = docinf.getAuthor();
printf(" Author : %s\n", author.c_str());
//キーワード取得
PtlParamString keywords = docinf.getKeywords();
printf(" Keywords : %s\n", keywords.c_str());
//クリエータ取得
PtlParamString creator = docinf.getCreator();
printf(" Creator : %s\n", creator.c_str());
//プロデューサ取得
PtlParamString producer = docinf.getProducer();
printf(" Producer : %s\n", producer.c_str());
//作成日付を取得
PtlDate creationDate = docinf.getCreationDate();
printf(" CreationDate : %d/%d/%d %d:%d:%d\n"
, creationDate.getYear()
, creationDate.getMonth()
, creationDate.getDay()
, creationDate.getHour()
, creationDate.getMin()
, creationDate.getSec());
//更新日付を取得
PtlDate modDate = docinf.getModDate();
printf(" ModifyDate : %d/%d/%d %d:%d:%d\n"
, modDate.getYear()
, modDate.getMonth()
, modDate.getDay()
, modDate.getHour()
, modDate.getMin()
, modDate.getSec());
// ページ数
printf(" Max Page : %d\n", doc.getPageCount());
// 開き方情報を取得
printf("\n\n");
printf("View Information\n");
PtlOpenMode& openmode = docproperty.getOpenMode();
//読み上げオプション取得
switch (docproperty.getDirection()) {
case PtlDocProperty::DIRECTION_L2R:
printf(" Direction : Left to Right\n");
break;
case PtlDocProperty::DIRECTION_R2L:
printf(" Direction : Right to Left )\n");
break;
}
// ページレイアウトを取得
switch (openmode.getPageLayout())
{
case PtlOpenMode::PAGE_LAYOUT_SINGLE_PAGE: // 単一ページ
printf(" PageLayout : SinglePage\n");
break;
case PtlOpenMode::PAGE_LAYOUT_ONE_COLUMN: // 連続ページ
printf(" PageLayout : OneColumn\n");
break;
case PtlOpenMode::PAGE_LAYOUT_TWO_COLUMN_LEFT: // 奇数ページを左側にして連続見開きページ
printf(" PageLayout : TwoColumnLeft\n");
break;
case PtlOpenMode::PAGE_LAYOUT_TWO_COLUMN_RIGHT: // 奇数ページを右側にして連続見開きページ
printf(" PageLayout : TwoColumnRight\n");
break;
case PtlOpenMode::PAGE_LAYOUT_TWO_PAGE_LEFT: // 奇数ページを左側にして見開きページ
printf(" PageLayout : TwoPageLeft\n");
break;
case PtlOpenMode::PAGE_LAYOUT_TWO_PAGE_RIGHT: // 奇数ページを右側にして見開きページ
printf(" PageLayout : TwoPageRight\n");
break;
}
// PageMode : Use Outlines
switch (openmode.getPageMode())
{
case PtlOpenMode::PAGE_MODE_USE_NONE: // ページのみ表示
printf(" PageMode : Use None\n");
break;
case PtlOpenMode::PAGE_MODE_USE_OUTLINES: // アウトラインパネルとページ
printf(" PageMode : Use Outlines\n");
break;
case PtlOpenMode::PAGE_MODE_USE_THUMBS: // サムネイルパネルとページ
printf(" PageMode : Use Thumbs\n");
break;
case PtlOpenMode::PAGE_MODE_USE_OC: // レイヤーパネルとページ
printf(" PageMode : Use OC\n");
break;
case PtlOpenMode::PAGE_MODE_USE_ATTACHMENTS: // 添付ファイルパネルとページ
printf(" PageMode : Use Atttachments\n");
break;
}
// ウィンドウオプションを取得
bool fitwindow
= (openmode.getWindowOption() & PtlOpenMode::WINDOWS_OPTION_FIT_WINDOW)
== PtlOpenMode::WINDOWS_OPTION_FIT_WINDOW;
bool centerwindow
= (openmode.getWindowOption() & PtlOpenMode::WINDOWS_OPTION_CENTER_WINDOW)
== PtlOpenMode::WINDOWS_OPTION_CENTER_WINDOW;
bool fullscreen
= (openmode.getWindowOption() & PtlOpenMode::WINDOWS_OPTION_FULL_SCREEN)
== PtlOpenMode::WINDOWS_OPTION_FULL_SCREEN;
if (fitwindow) {
printf(" FitWindow : true\n");
}
else{
printf(" FitWindow : false\n");
}
if (centerwindow){
printf(" CenterWindow : true\n");
}
else{
printf(" CenterWindow : false\n");
}
if (fullscreen) {
printf(" Full Screen : true\n");
}
else {
printf(" Full Screen : false\n");
}
// ウィンドウのタイトルバーに文書タイトルを表示するかどうかを取得
if (openmode.getDisplayDocTitle())
{
printf(" Display Doc Title : true\n");
}
else
{
printf(" Display Doc Title : false\n");
}
// ユーザーインターフェイスオプションを取得
int uiopt = openmode.getUIOption();
bool hidemenu
= (openmode.getUIOption() & PtlOpenMode::UI_OPTION_HIDE_MENUBAR)
== PtlOpenMode::UI_OPTION_HIDE_MENUBAR;
bool hidetool
= (openmode.getUIOption() & PtlOpenMode::UI_OPTION_HIDE_TOOLBAR)
== PtlOpenMode::UI_OPTION_HIDE_TOOLBAR;
bool hidewinui
= (openmode.getUIOption() & PtlOpenMode::UI_OPTION_HIDE_WINDOWUI)
== PtlOpenMode::UI_OPTION_HIDE_WINDOWUI;
if (hidemenu) {
printf(" Hide Menubar : true\n");
}
else {
printf(" Hide Menubar : false\n");
}
if (hidetool) {
printf(" Hide Toolbar : true\n");
}
else {
printf(" Hide Toolbar : false\n");
}
if (hidewinui) {
printf(" Hide Window UI : true\n");
}
else {
printf(" Hide Window UI : false\n");
}
// オープンアクションを取得
showAction(openmode.getOpenAction());
// カスタムプロパティを取得
printf("\n\n");
printf("Custom Property\n");
PtlCustomProperties& customProperties = docproperty.getCustomProperties();
int numCustomProperties = customProperties.getCount();
for (int i = 0; i < numCustomProperties; ++i) {
PtlCustomProperty prop = customProperties.get(i);
printf(" Name : %s\n", prop.getName().c_str());
printf(" Value : %s\n", prop.getValue().c_str());
}
printf("\n\n");
printf("Security Information\n");
bool isEncrypted = doc.isEncrypted();
if (!isEncrypted) {
printf(" Not Encrypted.\n");
return 0;
}
const PtlEncrypt& encrypt = doc.getEncrypt();
int filterType = encrypt.getFilterType();
if (filterType != PtlEncrypt::FILTER_STANDARD) {
return 0;
}
const PtlEncryptStandard& encryptStandard = (const PtlEncryptStandard&)encrypt;
printf(" Security Handler : Standard Security\n");
int keyLength = encrypt.getKeyLength();
printf(" Key Length : %d\n", keyLength);
int method = encryptStandard.getMethod();
if (method == PtlEncryptStandard::METHOD_RC4) {
printf(" Method = RC4\n");
}
else
if (method == PtlEncryptStandard::METHOD_RC4) {
printf(" Method = AES\n");
}
const PtlEncryptPermission& perms = encryptStandard.getPermission();
switch (perms.getType()) {
case PtlEncryptPermission::PERM_TYPE1:
{
printf(" Permission Type1\n");
const PtlEncryptPermissionType1& perms1 = reinterpret_cast(perms);
bool print = perms1.getPrint();
if (print) {
printf(" Print : allowed.\n");
}
else {
printf(" Print : not allowed.\n");
}
int modify = perms1.getModify();
switch (modify) {
case PtlEncryptPermissionType1::PERM_MODIFY_NOT_ALLOWED:
printf(" Modify : not allowed.\n");
break;
case PtlEncryptPermissionType1::PERM_MODIFY_ANNOTANDFORM:
printf(" Modify : Commenting, filling in form fields, and signing existing signature fields.\n");
break;
case PtlEncryptPermissionType1::PERM_MODIFY_ASSEMBLEANDFORM:
printf(" Modify : Page layout, filling in form fields, and signing existing signature fields.\n");
break;
case PtlEncryptPermissionType1::PERM_MODIFY_MODYFYDOC:
printf(" Modify : Any except extracting pages.\n");
break;
}
bool copy = perms1.getCopy();
if (copy) {
printf(" Copy : Enable copying of text, images, and other content and access for the visually impaired.\n");
}
else {
printf(" Copy : Disable copying of text, images, and other content and access for the visually impaired.\n");
}
}
break;
case PtlEncryptPermission::PERM_TYPE2:
{
printf(" Permission Type2\n");
const PtlEncryptPermissionType2& perms2 = reinterpret_cast(perms);
int print = perms2.getPrint();
switch (print) {
case PtlEncryptPermissionType2::PERM_PRINT_NOT_ALLOWED:
printf(" Print : not allowed.\n");
break;
case PtlEncryptPermissionType2::PERM_PRINT_LOW:
printf(" Print : Low resolution.\n");
break;
case PtlEncryptPermissionType2::PERM_PRINT_HIGH:
printf(" Print : High resolution.\n");
break;
}
int modify = perms2.getModify();
switch (modify) {
case PtlEncryptPermissionType2::PERM_MODIFY_NOT_ALLOWED:
printf(" Modify : not allowed.\n");
break;
case PtlEncryptPermissionType2::PERM_MODIFY_ASSEMBLEDOC:
printf(" Modify : Inserting, deleting, and rotating pages.\n");
break;
case PtlEncryptPermissionType2::PERM_MODIFY_FILLFORM:
printf(" Modify : Filling in form fields, and signing existing signature fields.\n");
break;
case PtlEncryptPermissionType2::PERM_MODIFY_ANNOTANDFORM:
printf(" Modify : Commenting, filling in form fields, and signing existing signature fields.\n");
break;
case PtlEncryptPermissionType2::PERM_MODIFY_MODYFYDOC:
printf(" Modify : Any except extracting pages.\n");
break;
}
bool copy = perms2.getCopy();
if (copy) {
printf(" Copy : Enable copying of text, images, and other content.\n");
}
else {
printf(" Copy : Disable copying of text, images, and other content.\n");
}
bool acc = perms2.getAccessibility();
if (acc) {
printf(" Accessibility : Enable text access for screen render devices for the visually impaired.\n");
}
else {
printf(" Accessibility : Disable text access for screen render devices for the visually impaired.\n");
}
}
break;
}
printf("\n\n");
printf("Standard Information\n");
if (doc.isSignatured()) {
printf(" Signature : true\n");
}
else {
printf(" Signature : false\n");
}
if (doc.isPDFA()) {
printf(" PDF/A : true\n");
}
else {
printf(" PDF/A : false\n");
}
if (doc.isPDFX()) {
printf(" PDF/X : true\n");
}
else {
printf(" PDF/X : false\n");
}
printf("\n");
printf("完了!\n");
}
catch (const PtlException &e)
{
fprintf(stderr, "Error code : %d\n %s\n", e.getErrorCode(), e.getErrorMessage().c_str());
}
return 0;
}
int showAction(PtlAction& action)
{
try {
switch (action.getType()) {
case PtlAction::TYPE_NONE:
printf(" Action : none\n");
break;
case PtlAction::TYPE_UNKNOWN:
printf(" Action : unknown\n");
break;
case PtlAction::TYPE_GOTO:
{
printf(" Action : GoTo\n");
PtlActionGoTo& actGoTo = (PtlActionGoTo&)action;
PtlDest& dest = actGoTo.getDest();
int ret = showDest(dest);
if (ret != 0) {
return ret;
}
}
break;
case PtlAction::TYPE_GOTO_R:
{
printf(" Action : GoToR\n");
PtlActionGoToR& actGoToR = (PtlActionGoToR&)action;
PtlDest& dest = actGoToR.getDest();
int ret = showDest(dest);
if (ret != 0) {
return ret;
}
}
break;
case PtlAction::TYPE_LAUNCH:
{
printf(" Action : Launch\n");
PtlActionLaunch& actLaunch = (PtlActionLaunch&)action;
printf(" file name : %s\n", actLaunch.getFileName().c_str());
bool flag = actLaunch.getNewWindowFlag();
if (flag) {
printf(" new window : true\n");
}
else {
printf(" new window : false\n");
}
}
break;
case PtlAction::TYPE_URI:
{
printf(" Action : URI\n");
PtlActionURI& actURI = (PtlActionURI&)action;
printf(" uri : %s\n", actURI.getURI().c_str());
}
break;
}
}
catch (PtlException e) {
printf(" Error Message: %s\n", e.getErrorMessage().c_str());
printf("\n");
return e.getErrorCode();
}
catch (...) {
printf("Unknown error has occured.\n");
printf("\n");
return -2;
}
return 0;
}
int showDest(PtlDest& dest)
{
try {
int destType = dest.getType();
int pageNumber = dest.getPageNumber();
switch (destType) {
case PtlDest::TYPE_NONE:
printf(" Dest : none\n");
break;
case PtlDest::TYPE_XYZ:
{
printf(" Dest page : %d\n", pageNumber);
printf(" Dest type : XYZ\n");
float left = 0.0f;
if (!dest.isLeftNull())
left = dest.getLeft();
printf(" left : %f\n", left);
float top = 0.0f;
if (!dest.isTopNull())
top = dest.getTop();
printf(" top : %f\n", top);
float zoom = 0.0f;
if (!dest.isZoomNull())
zoom = dest.getZoom();
printf(" zoom : %f\n", zoom);
}
break;
case PtlDest::TYPE_FIT:
printf(" Dest page : %d\n", pageNumber);
printf(" Dest type : Fit\n");
break;
case PtlDest::TYPE_FIT_H:
{
printf(" Dest page : %d\n", pageNumber);
printf(" Dest type : FitH\n");
float top = 0.0f;
if (!dest.isTopNull())
top = dest.getTop();
printf(" top : %f\n", top);
}
break;
case PtlDest::TYPE_FIT_V:
{
printf(" Dest page : %d\n", pageNumber);
printf(" Dest type : FitV\n");
float left = 0.0f;
if (!dest.isLeftNull())
left = dest.getLeft();
printf(" left : %f\n", left);
}
break;
case PtlDest::TYPE_FIT_R:
{
printf(" Dest page : %d\n", pageNumber);
printf(" Dest type : FitR\n");
float left = 0.0f;
if (!dest.isLeftNull())
left = dest.getLeft();
printf(" left : %f\n", left);
float bottom = 0.0f;
if (!dest.isBottomNull())
bottom = dest.getBottom();
printf(" bottom : %f\n", bottom);
float right = 0.0f;
if (!dest.isRightNull())
right = dest.getRight();
printf(" right : %f\n", right);
float top = 0.0f;
if (!dest.isTopNull())
top = dest.getTop();
printf(" top : %f\n", top);
float zoom = 0.0f;
if (!dest.isZoomNull())
zoom = dest.getZoom();
printf(" zoom : %f\n", zoom);
}
break;
case PtlDest::TYPE_FIT_B:
printf(" Dest page : %d\n", pageNumber);
printf(" Dest type : FitB\n");
break;
case PtlDest::TYPE_FIT_BH:
printf(" Dest page : %d\n", pageNumber);
printf(" Dest type : FitBH\n");
{
float top = 0.0f;
if (!dest.isTopNull())
top = dest.getTop();
printf(" top : %f\n", top);
}
break;
case PtlDest::TYPE_FIT_BV:
{
printf(" Dest page : %d\n", pageNumber);
printf(" Dest type : FitBV\n");
float left = 0.0f;
if (!dest.isLeftNull())
left = dest.getLeft();
printf(" left : % f\n", left);
}
break;
}
}
catch (PtlException e) {
printf(" Error Message: %s\n", e.getErrorMessage().c_str());
printf("\n");
return e.getErrorCode();
}
catch (...) {
printf("Unknown error has occured.\n");
printf("\n");
return -2;
}
return 0;
}
PDF Tool APIサンプルコード:文書の情報取得(バージョン・文書情報・PDFの開き方・セキュリティ情報)
入力PDFの文書情報やセキュリティ状態など、文書の情報を取得します。
概要
サンプルコードの概要
文書の情報を取得します。
コマンドラインでパラメータの指定が無い場合はすべての情報を出力します。
APIでも同じ項目を出力するサンプルを作成しました。
出力する項目は
PDFバージョン
/文書情報
/ページ数
/開き方情報
/カスタムプロパティ
/セキュリティ情報
/電子署名
/PDF/A, PDF/Xの有無
です。
- PtlDocProperty :PDFの文書プロパティを表現したクラスです
- PtlPDFDocument.getDocProperty() :文書プロパティを取得
- PtlDocInfo :PDFの文書情報を表現したクラスです
- PtlDocProperty.getDocInfo() :文書情報を取得
- PtlOpenMode :PDFの開き方を表現したクラス
- PtlDocProperty.getOpenMode() :開き方を取得
- PtlCustomProperties :カスタムプロパティのコンテナを表現するクラス
- PtlDocProperty.getCustomProperties() :カスタムプロパティを取得
- PtlEncrypt :PDFのセキュリティハンドラおよび暗号化情報を表現したクラス
- PtlPDFDocument.getEncrypt() :暗号化情報を取得
- PtlEncryptStandard :PDFの標準セキュリティハンドラの暗号化情報を表現したクラス
- PtlEncryptPermission :ユーザアクセス許可フラグを表現したクラス
- PtlEncryptStandard.getPermission() :ユーザアクセス許可フラグを取得
- PtlEncryptPermissionType1& perms1 :標準セキュリティハンドラのリビジョン番号が2での権限を表現したクラス
- PtlEncryptPermissionType2& perms2 :標準セキュリティハンドラのリビジョン番号が3以降での権限を表現したクラス
- PtlAction :PDFのアクションを表現したクラスです
- PtlOpenMode.getOpenAction() :オープンアクションを取得
- PtlActionGoTo :PDFのGoToアクションを表現したクラス
- PtlActionGoToR :PDFのGoToRアクションを表現したクラス
- PtlActionLaunch :PDFのLaunchアクションを表現したクラス
- PtlActionURI :PDFのURIアクションを表現したクラス
- PtlDest :PDFの宛先を表現したクラス
サンプルコード
/*
Antenna House PDF Tool API V8.0
Java Interface sample program
概要:文書情報の取得(バージョン・文書情報・PDFの開き方・セキュリティ情報)
Copyright 2015-2026 Antenna House, Inc.
*/
package Sample;
import jp.co.antenna.ptl.*;
public class GetDocInfo_2 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
if (args.length < 1)
{
System.out.println("usage: java GetDocInfo_2 in-pdf-file");
return;
}
try (PtlParamInput inputFile = new PtlParamInput(args[0]);
PtlPDFDocument doc = new PtlPDFDocument())
{
// PDFファイルをロード
doc.load(inputFile);
//PDFの文書プロパティ
try (PtlDocProperty docproperty = doc.getDocProperty();) //PDFの文書プロパティ
{
System.out.println("PDF Version");
switch (docproperty.getVersion())
{
case PDFV1_0: // PDF-1.0
System.out.println(" major : 1");
System.out.println(" minor : 0");
break;
case PDFV1_1: // PDF-1.1
System.out.println(" major : 1");
System.out.println(" minor : 1");
break;
case PDFV1_2: // PDF-1.2
System.out.println(" major : 1");
System.out.println(" minor : 2");
break;
case PDFV1_3: // PDF-1.3
System.out.println(" major : 1");
System.out.println(" minor : 3");
break;
case PDFV1_4: // PDF-1.4
System.out.println(" major : 1");
System.out.println(" minor : 4");
break;
case PDFV1_5: // PDF-1.5
System.out.println(" major : 1");
System.out.println(" minor : 5");
break;
case PDFV1_6: // PDF-1.6
System.out.println(" major : 1");
System.out.println(" minor : 6");
break;
case PDFV1_7: // PDF-1.7
System.out.println(" major : 1");
System.out.println(" minor : 7");
break;
case PDFV2_0: // PDF-2.0
System.out.println(" major : 2");
System.out.println(" minor : 0");
break;
case PDFV_UNSUPPORTED: // 未サポートのバージョン
System.out.println(" 未サポートのバージョン");
break;
}
System.out.print("\n");
System.out.println("Document Information");
try (PtlDocInfo docinf = docproperty.getDocInfo()) { //PDFの文書情報
// タイトル取得
System.out.println(" Title : " + docinf.getTitle());
// サブジェクト取得
System.out.println(" Subject : " + docinf.getSubject());
// 著者取得
System.out.println(" Author : " + docinf.getAuthor());
// キーワード取得
System.out.println(" Keywords : " + docinf.getKeywords());
// クリエータ取得
System.out.println(" Creator : " + docinf.getCreator());
// プロデューサ取得
System.out.println(" Producer : " + docinf.getProducer());
// 作成日付を取得
try (PtlDate dateCreate = docinf.getCreationDate())
{
System.out.println(" CreationDate : "
+ dateCreate.getYear()
+ "/" + dateCreate.getMonth()
+ "/" + dateCreate.getDay()
+ " " + dateCreate.getHour()
+ ":" + dateCreate.getMin()
+ ":" + dateCreate.getSec());
}
// 更新日付を取得
try (PtlDate dateMod = docinf.getModDate())
{
System.out.println(" ModifyDate : "
+ dateMod.getYear()
+ "/" + dateMod.getMonth()
+ "/" + dateMod.getDay()
+ " " + dateMod.getHour()
+ ":" + dateMod.getMin()
+ ":" + dateMod.getSec());
}
// ページ数
System.out.println(" Max Page : " + doc.getPageCount());
}
// 開き方情報を取得
System.out.println("\n");
System.out.println("View Information");
try(PtlOpenMode openmode = docproperty.getOpenMode();)
{
//読み上げオプション取得
switch (docproperty.getDirection()) {
case DIRECTION_L2R:
System.out.println(" Direction : Left to Right");
break;
case DIRECTION_R2L:
System.out.println(" Direction : Right to Left )");
break;
}
// ページレイアウトを取得
switch (openmode.getPageLayout())
{
case PAGE_LAYOUT_SINGLE_PAGE: // 単一ページ
System.out.println(" PageLayout : SinglePage");
break;
case PAGE_LAYOUT_ONE_COLUMN: // 連続ページ
System.out.println(" PageLayout : OneColumn");
break;
case PAGE_LAYOUT_TWO_COLUMN_LEFT: // 奇数ページを左側にして連続見開きページ
System.out.println(" PageLayout : TwoColumnLeft");
break;
case PAGE_LAYOUT_TWO_COLUMN_RIGHT: // 奇数ページを右側にして連続見開きページ
System.out.println(" PageLayout : TwoColumnRight");
break;
case PAGE_LAYOUT_TWO_PAGE_LEFT: // 奇数ページを左側にして見開きページ
System.out.println(" PageLayout : TwoPageLeft");
break;
case PAGE_LAYOUT_TWO_PAGE_RIGHT: // 奇数ページを右側にして見開きページ
System.out.println(" PageLayout : TwoPageRight");
break;
}
// PageMode : Use Outlines
switch (openmode.getPageMode())
{
case PAGE_MODE_USE_NONE: // ページのみ表示
System.out.println(" PageMode : Use None");
break;
case PAGE_MODE_USE_OUTLINES: // アウトラインパネルとページ
System.out.println(" PageMode : Use Outlines");
break;
case PAGE_MODE_USE_THUMBS: // サムネイルパネルとページ
System.out.println(" PageMode : Use Thumbs");
break;
case PAGE_MODE_USE_OC: // レイヤーパネルとページ
System.out.println(" PageMode : Use OC");
break;
case PAGE_MODE_USE_ATTACHMENTS: // 添付ファイルパネルとページ
System.out.println(" PageMode : Use Atttachments");
break;
}
// ウィンドウオプションを取得
boolean fitwindow
= (openmode.getWindowOption() & PtlOpenMode.WINDOWS_OPTION_FIT_WINDOW)
== PtlOpenMode.WINDOWS_OPTION_FIT_WINDOW;
boolean centerwindow
= (openmode.getWindowOption() & PtlOpenMode.WINDOWS_OPTION_CENTER_WINDOW)
== PtlOpenMode.WINDOWS_OPTION_CENTER_WINDOW;
boolean fullscreen
= (openmode.getWindowOption() & PtlOpenMode.WINDOWS_OPTION_FULL_SCREEN)
== PtlOpenMode.WINDOWS_OPTION_FULL_SCREEN;
if (fitwindow) {
System.out.println(" FitWindow : true");
}
else{
System.out.println(" FitWindow : false");
}
if (centerwindow){
System.out.println(" CenterWindow : true");
}
else{
System.out.println(" CenterWindow : false");
}
if (fullscreen) {
System.out.println(" Full Screen : true");
}
else {
System.out.println(" Full Screen : false");
}
// ウィンドウのタイトルバーに文書タイトルを表示するかどうかを取得
if (openmode.getDisplayDocTitle())
{
System.out.println(" Display Doc Title : true");
}
else
{
System.out.println(" Display Doc Title : false");
}
// ユーザーインターフェイスオプションを取得
// int uiopt = openmode.getUIOption();
boolean hidemenu
= (openmode.getUIOption() & PtlOpenMode.UI_OPTION_HIDE_MENUBAR)
== PtlOpenMode.UI_OPTION_HIDE_MENUBAR;
boolean hidetool
= (openmode.getUIOption() & PtlOpenMode.UI_OPTION_HIDE_TOOLBAR)
== PtlOpenMode.UI_OPTION_HIDE_TOOLBAR;
boolean hidewinui
= (openmode.getUIOption() & PtlOpenMode.UI_OPTION_HIDE_WINDOWUI)
== PtlOpenMode.UI_OPTION_HIDE_WINDOWUI;
if (hidemenu) {
System.out.println(" Hide Menubar : true");
}
else {
System.out.println(" Hide Menubar : false");
}
if (hidetool) {
System.out.println(" Hide Toolbar : true");
}
else {
System.out.println(" Hide Toolbar : false");
}
if (hidewinui) {
System.out.println(" Hide Window UI : true");
}
else {
System.out.println(" Hide Window UI : false");
}
// オープンアクションを取得
showAction(openmode.getOpenAction());
// カスタムプロパティを取得
System.out.println("\n");
System.out.println("Custom Property");
PtlCustomProperties customProperties = docproperty.getCustomProperties();
int numCustomProperties = customProperties.getCount();
for (int i = 0; i < numCustomProperties; ++i) {
PtlCustomProperty prop = customProperties.get(i);
System.out.println(" Name : " + prop.getName());
System.out.println(" Value : " + prop.getValue());
}
}
System.out.println("\n");
System.out.println("Security Information");
boolean isEncrypted = doc.isEncrypted();
if (!isEncrypted) {
System.out.println(" Not Encrypted.");
return;
}
PtlEncrypt encrypt = doc.getEncrypt();
PtlEncrypt.FILTER_TYPE filterType = encrypt.getFilterType();
if (filterType != PtlEncrypt.FILTER_TYPE.FILTER_STANDARD) {
return;
}
PtlEncryptStandard encryptStandard = (PtlEncryptStandard)encrypt;
System.out.println(" Security Handler : Standard Security");
int keyLength = encrypt.getKeyLength();
System.out.println(" Key Length : " + keyLength);
PtlEncryptStandard.STANDARD_METHOD_TYPE method = encryptStandard.getMethod();
if (method == PtlEncryptStandard.STANDARD_METHOD_TYPE.METHOD_RC4) {
System.out.println(" Method = RC4");
}
else
if (method == PtlEncryptStandard.STANDARD_METHOD_TYPE.METHOD_RC4) {
System.out.println(" Method = AES");
}
switch (encryptStandard.getPermission().getType()) {
case PERM_TYPE1:
{
System.out.println(" Permission Type1");
PtlEncryptPermissionType1 perms1 = (PtlEncryptPermissionType1)encryptStandard.getPermission();
boolean print = perms1.getPrint();
if (print) {
System.out.println(" Print : allowed.");
}
else {
System.out.println(" Print : not allowed.");
}
PtlEncryptPermissionType1.PERMISSION_MODIFY modify = perms1.getModify();
switch (modify) {
case PERM_MODIFY_NOT_ALLOWED:
System.out.println(" Modify : not allowed.");
break;
case PERM_MODIFY_ANNOTANDFORM:
System.out.println(" Modify : Commenting, filling in form fields, and signing existing signature fields.");
break;
case PERM_MODIFY_ASSEMBLEANDFORM:
System.out.println(" Modify : Page layout, filling in form fields, and signing existing signature fields.");
break;
case PERM_MODIFY_MODYFYDOC:
System.out.println(" Modify : Any except extracting pages.");
break;
}
boolean copy = perms1.getCopy();
if (copy) {
System.out.println(" Copy : Enable copying of text, images, and other content and access for the visually impaired.");
}
else {
System.out.println(" Copy : Disable copying of text, images, and other content and access for the visually impaired.");
}
}
break;
case PERM_TYPE2:
{
System.out.println(" Permission Type2");
PtlEncryptPermissionType2 perms2 = (PtlEncryptPermissionType2)encryptStandard.getPermission();
PtlEncryptPermissionType2.PERMISSION_PRINT print = perms2.getPrint();
switch (print) {
case PERM_PRINT_NOT_ALLOWED:
System.out.println(" Print : not allowed.");
break;
case PERM_PRINT_LOW:
System.out.println(" Print : Low resolution.");
break;
case PERM_PRINT_HIGH:
System.out.println(" Print : High resolution.");
break;
}
PtlEncryptPermissionType2.PERMISSION_MODIFY modify = perms2.getModify();
switch (modify) {
case PERM_MODIFY_NOT_ALLOWED:
System.out.println(" Modify : not allowed.");
break;
case PERM_MODIFY_ASSEMBLEDOC:
System.out.println(" Modify : Inserting, deleting, and rotating pages.");
break;
case PERM_MODIFY_FILLFORM:
System.out.println(" Modify : Filling in form fields, and signing existing signature fields.");
break;
case PERM_MODIFY_ANNOTANDFORM:
System.out.println(" Modify : Commenting, filling in form fields, and signing existing signature fields.");
break;
case PERM_MODIFY_MODYFYDOC:
System.out.println(" Modify : Any except extracting pages.");
break;
}
boolean copy = perms2.getCopy();
if (copy) {
System.out.println(" Copy : Enable copying of text, images, and other content.");
}
else {
System.out.println(" Copy : Disable copying of text, images, and other content.");
}
boolean acc = perms2.getAccessibility();
if (acc) {
System.out.println(" Accessibility : Enable text access for screen render devices for the visually impaired.");
}
else {
System.out.println(" Accessibility : Disable text access for screen render devices for the visually impaired.");
}
}
break;
}
System.out.println("\n");
System.out.println("Standard Information");
if (doc.isSignatured()) {
System.out.println(" Signature : true");
}
else {
System.out.println(" Signature : false");
}
if (doc.isPDFA()) {
System.out.println(" PDF/A : true");
}
else {
System.out.println(" PDF/A : false");
}
if (doc.isPDFX()) {
System.out.println(" PDF/X : true");
}
else {
System.out.println(" PDF/X : false");
}
}
}
catch(PtlException pex) {
System.out.println("PtlException : ErrorCode = " + pex.getErrorCode() + "\n " + pex.getErrorMessage());
}
catch(Exception ex) {
System.out.println(ex.getMessage());
ex.printStackTrace();
}
catch (Error ex) {
System.out.println(ex.getMessage());
ex.printStackTrace();
}
finally {
System.out.print("\n");
System.out.println("-- 完了 --");
}
}
private static int showAction(PtlAction action) {
try {
switch (action.getType()) {
case TYPE_NONE:
System.out.println(" Action : none");
break;
case TYPE_UNKNOWN:
System.out.println(" Action : unknown");
break;
case TYPE_GOTO:
{
System.out.println(" Action : GoTo");
PtlActionGoTo actGoTo = (PtlActionGoTo)action;
PtlDest dest = actGoTo.getDest();
int ret = showDest(dest);
if (ret != 0) {
return ret;
}
}
break;
case TYPE_GOTO_R:
{
System.out.println(" Action : GoToR");
PtlActionGoToR actGoToR = (PtlActionGoToR)action;
PtlDest dest = actGoToR.getDest();
int ret = showDest(dest);
if (ret != 0) {
return ret;
}
}
break;
case TYPE_LAUNCH:
{
System.out.println(" Action : Launch");
PtlActionLaunch actLaunch = (PtlActionLaunch)action;
System.out.println(" file name : " + actLaunch.getFileName());
boolean flag = actLaunch.getNewWindowFlag();
if (flag) {
System.out.println(" new window : true");
}
else {
System.out.println(" new window : false");
}
}
break;
case TYPE_URI:
{
System.out.println(" Action : URI");
PtlActionURI actURI = (PtlActionURI)action;
System.out.println(" uri : " + actURI.getURI());
}
break;
case TYPE_JAVASCRIPT:
break;
default:
break;
}
}
catch (PtlException e) {
System.out.println(" Error Message: " + e.getErrorMessage());
System.out.println("\n");
return e.getErrorCode();
}
catch (Exception e) {
System.out.println("Unknown error has occured.");
System.out.println("\n");
return -2;
}
return 0;
}
private static int showDest(PtlDest dest)
{
try {
PtlDest.DEST_TYPE destType = dest.getType();
int pageNumber = dest.getPageNumber();
switch (destType) {
case TYPE_NONE:
System.out.println(" Dest : none");
break;
case TYPE_XYZ:
{
System.out.println(" Dest page : " + pageNumber);
System.out.println(" Dest type : XYZ");
float left = 0.0f;
if (!dest.isLeftNull())
left = dest.getLeft();
System.out.println(" left : " + left);
float top = 0.0f;
if (!dest.isTopNull())
top = dest.getTop();
System.out.println(" top : " + top);
float zoom = 0.0f;
if (!dest.isZoomNull())
zoom = dest.getZoom();
System.out.println(" zoom : " + zoom);
}
break;
case TYPE_FIT:
System.out.println(" Dest page : " + pageNumber);
System.out.println(" Dest type : Fit");
break;
case TYPE_FIT_H:
{
System.out.println(" Dest page : " + pageNumber);
System.out.println(" Dest type : FitH");
float top = 0.0f;
if (!dest.isTopNull())
top = dest.getTop();
System.out.println(" top : " + top);
}
break;
case TYPE_FIT_V:
{
System.out.println(" Dest page : " + pageNumber);
System.out.println(" Dest type : FitV");
float left = 0.0f;
if (!dest.isLeftNull())
left = dest.getLeft();
System.out.println(" left : " + left);
}
break;
case TYPE_FIT_R:
{
System.out.println(" Dest page : " + pageNumber);
System.out.println(" Dest type : FitR");
float left = 0.0f;
if (!dest.isLeftNull())
left = dest.getLeft();
System.out.println(" left : " + left);
float bottom = 0.0f;
if (!dest.isBottomNull())
bottom = dest.getBottom();
System.out.println(" bottom : " + bottom);
float right = 0.0f;
if (!dest.isRightNull())
right = dest.getRight();
System.out.println(" right : " + right);
float top = 0.0f;
if (!dest.isTopNull())
top = dest.getTop();
System.out.println(" top : " + top);
float zoom = 0.0f;
if (!dest.isZoomNull())
zoom = dest.getZoom();
System.out.println(" zoom : " + zoom);
}
break;
case TYPE_FIT_B:
System.out.println(" Dest page : " + pageNumber);
System.out.println(" Dest type : FitB");
break;
case TYPE_FIT_BH:
System.out.println(" Dest page : " + pageNumber);
System.out.println(" Dest type : FitBH");
{
float top = 0.0f;
if (!dest.isTopNull())
top = dest.getTop();
System.out.println(" top : " + top);
}
break;
case TYPE_FIT_BV:
{
System.out.println(" Dest page : " + pageNumber);
System.out.println(" Dest type : Fit");
float left = 0.0f;
if (!dest.isLeftNull())
left = dest.getLeft();
System.out.println(" left : " + left);
}
break;
}
}
catch (PtlException e) {
System.out.println(" Error Message: " + e.getErrorMessage());
System.out.println("\n");
return e.getErrorCode();
}
catch (Exception e) {
System.out.println("Unknown error has occured.");
System.out.println("\n");
return -2;
}
return 0;
}
}
/*
Antenna House PDF Tool API V8.0
.NET Interface sample program
概要:文書情報の取得(バージョン・文書情報・PDFの開き方・セキュリティ情報)
Copyright 2013-2026 Antenna House, Inc.
*/
using PdfTkNet;
namespace GetDocInfo_2
{
class Program
{
static void Main(string[] args)
{
if (args.Length < 1)
{
Console.WriteLine("usage: GetDocInfo_2.exe in-pdf-file");
return;
}
try
{
using (PtlParamInput inputFile = new PtlParamInput(args[0]))
using (PtlPDFDocument doc = new PtlPDFDocument())
{
//PDFファイルをロードします。
doc.load(inputFile);
//PDFの文書プロパティ
using (PtlDocProperty docproperty = doc.getDocProperty())
{
Console.WriteLine("PDF Version");
switch (docproperty.getVersion())
{
case PtlDocProperty.PDF_VERSION.PDFV1_0: // PDF-1.0
Console.WriteLine(" major : 1");
Console.WriteLine(" minor : 0");
break;
case PtlDocProperty.PDF_VERSION.PDFV1_1: // PDF-1.1
Console.WriteLine(" major : 1");
Console.WriteLine(" minor : 1");
break;
case PtlDocProperty.PDF_VERSION.PDFV1_2: // PDF-1.2
Console.WriteLine(" major : 1");
Console.WriteLine(" minor : 2");
break;
case PtlDocProperty.PDF_VERSION.PDFV1_3: // PDF-1.3
Console.WriteLine(" major : 1");
Console.WriteLine(" minor : 3");
break;
case PtlDocProperty.PDF_VERSION.PDFV1_4: // PDF-1.4
Console.WriteLine(" major : 1");
Console.WriteLine(" minor : 4");
break;
case PtlDocProperty.PDF_VERSION.PDFV1_5: // PDF-1.5
Console.WriteLine(" major : 1");
Console.WriteLine(" minor : 5");
break;
case PtlDocProperty.PDF_VERSION.PDFV1_6: // PDF-1.6
Console.WriteLine(" major : 1");
Console.WriteLine(" minor : 6");
break;
case PtlDocProperty.PDF_VERSION.PDFV1_7: // PDF-1.7
Console.WriteLine(" major : 1");
Console.WriteLine(" minor : 7");
break;
case PtlDocProperty.PDF_VERSION.PDFV2_0: // PDF-2.0
Console.WriteLine(" major : 2");
Console.WriteLine(" minor : 0");
break;
case PtlDocProperty.PDF_VERSION.PDFV_UNSUPPORTED: // 未サポートのバージョン
Console.WriteLine(" 未サポートのバージョン");
break;
}
//PDFの文書情報
Console.Write(Environment.NewLine);
Console.WriteLine("Document Information");
using (PtlDocInfo docinf = docproperty.getDocInfo())
{
//タイトル取得
Console.WriteLine(" Title : " + docinf.getTitle());
//サブジェクト取得
Console.WriteLine(" Subject : " + docinf.getSubject());
//著者取得
Console.WriteLine(" Author : " + docinf.getAuthor());
//キーワード取得
Console.WriteLine(" Keywords : " + docinf.getKeywords());
//クリエータ取得
Console.WriteLine(" Creator : " + docinf.getCreator());
//プロデューサ取得
Console.WriteLine(" Producer : " + docinf.getProducer());
//作成日付を取得
using (PtlDate date = docinf.getCreationDate())
{
int year = date.getYear();
int month = date.getMonth();
int day = date.getDay();
int hour = date.getHour();
int min = date.getMin();
int sec = date.getSec();
Console.WriteLine(" CreationDate : {0}/{1}/{2} {3}:{4}:{5}", year, month, day, hour, min, sec);
}
//更新日付を取得
using (PtlDate date = docinf.getModDate())
{
int year = date.getYear();
int month = date.getMonth();
int day = date.getDay();
int hour = date.getHour();
int min = date.getMin();
int sec = date.getSec();
Console.WriteLine(" ModifyDate : {0}/{1}/{2} {3}:{4}:{5}", year, month, day, hour, min, sec);
}
}
// ページ数
Console.WriteLine(" Max Page : {0}", doc.getPageCount());
// 開き方情報を取得
Console.WriteLine(Environment.NewLine);
Console.WriteLine("View Information");
PtlOpenMode openmode = docproperty.getOpenMode();
//読み上げオプション取得
switch (docproperty.getDirection())
{
case PtlDocProperty.DIRECTION.DIRECTION_L2R:
Console.WriteLine(" Direction : Left to Right");
break;
case PtlDocProperty.DIRECTION.DIRECTION_R2L:
Console.WriteLine(" Direction : Right to Left )");
break;
}
// ページレイアウトを取得
switch (openmode.getPageLayout())
{
case PtlOpenMode.PAGE_LAYOUT.PAGE_LAYOUT_SINGLE_PAGE: // 単一ページ
Console.WriteLine(" PageLayout : SinglePage");
break;
case PtlOpenMode.PAGE_LAYOUT.PAGE_LAYOUT_ONE_COLUMN: // 連続ページ
Console.WriteLine(" PageLayout : OneColumn");
break;
case PtlOpenMode.PAGE_LAYOUT.PAGE_LAYOUT_TWO_COLUMN_LEFT: // 奇数ページを左側にして連続見開きページ
Console.WriteLine(" PageLayout : TwoColumnLeft");
break;
case PtlOpenMode.PAGE_LAYOUT.PAGE_LAYOUT_TWO_COLUMN_RIGHT: // 奇数ページを右側にして連続見開きページ
Console.WriteLine(" PageLayout : TwoColumnRight");
break;
case PtlOpenMode.PAGE_LAYOUT.PAGE_LAYOUT_TWO_PAGE_LEFT: // 奇数ページを左側にして見開きページ
Console.WriteLine(" PageLayout : TwoPageLeft");
break;
case PtlOpenMode.PAGE_LAYOUT.PAGE_LAYOUT_TWO_PAGE_RIGHT: // 奇数ページを右側にして見開きページ
Console.WriteLine(" PageLayout : TwoPageRight");
break;
}
// PageMode : Use Outlines
switch (openmode.getPageMode())
{
case PtlOpenMode.PAGE_MODE.PAGE_MODE_USE_NONE: // ページのみ表示
Console.WriteLine(" PageMode : Use None");
break;
case PtlOpenMode.PAGE_MODE.PAGE_MODE_USE_OUTLINES: // アウトラインパネルとページ
Console.WriteLine(" PageMode : Use Outlines");
break;
case PtlOpenMode.PAGE_MODE.PAGE_MODE_USE_THUMBS: // サムネイルパネルとページ
Console.WriteLine(" PageMode : Use Thumbs");
break;
case PtlOpenMode.PAGE_MODE.PAGE_MODE_USE_OC: // レイヤーパネルとページ
Console.WriteLine(" PageMode : Use OC");
break;
case PtlOpenMode.PAGE_MODE.PAGE_MODE_USE_ATTACHMENTS: // 添付ファイルパネルとページ
Console.WriteLine(" PageMode : Use Atttachments");
break;
}
// ウィンドウオプションを取得
bool fitwindow
= (openmode.getWindowOption() & PtlOpenMode.WINDOWS_OPTION.WINDOWS_OPTION_FIT_WINDOW)
== PtlOpenMode.WINDOWS_OPTION.WINDOWS_OPTION_FIT_WINDOW;
bool centerwindow
= (openmode.getWindowOption() & PtlOpenMode.WINDOWS_OPTION.WINDOWS_OPTION_CENTER_WINDOW)
== PtlOpenMode.WINDOWS_OPTION.WINDOWS_OPTION_CENTER_WINDOW;
bool fullscreen
= (openmode.getWindowOption() & PtlOpenMode.WINDOWS_OPTION.WINDOWS_OPTION_FULL_SCREEN)
== PtlOpenMode.WINDOWS_OPTION.WINDOWS_OPTION_FULL_SCREEN;
if (fitwindow)
{
Console.WriteLine(" FitWindow : true");
}
else
{
Console.WriteLine(" FitWindow : false");
}
if (centerwindow)
{
Console.WriteLine(" CenterWindow : true");
}
else
{
Console.WriteLine(" CenterWindow : false");
}
if (fullscreen)
{
Console.WriteLine(" Full Screen : true");
}
else
{
Console.WriteLine(" Full Screen : false");
}
// ウィンドウのタイトルバーに文書タイトルを表示するかどうかを取得
if (openmode.getDisplayDocTitle())
{
Console.WriteLine(" Display Doc Title : true");
}
else
{
Console.WriteLine(" Display Doc Title : false");
}
// ユーザーインターフェイスオプションを取得
int uiopt = (int)openmode.getUIOption();
bool hidemenu
= (openmode.getUIOption() & PtlOpenMode.UI_OPTION.UI_OPTION_HIDE_MENUBAR)
== PtlOpenMode.UI_OPTION.UI_OPTION_HIDE_MENUBAR;
bool hidetool
= (openmode.getUIOption() & PtlOpenMode.UI_OPTION.UI_OPTION_HIDE_TOOLBAR)
== PtlOpenMode.UI_OPTION.UI_OPTION_HIDE_TOOLBAR;
bool hidewinui
= (openmode.getUIOption() & PtlOpenMode.UI_OPTION.UI_OPTION_HIDE_WINDOWUI)
== PtlOpenMode.UI_OPTION.UI_OPTION_HIDE_WINDOWUI;
if (hidemenu)
{
Console.WriteLine(" Hide Menubar : true");
}
else
{
Console.WriteLine(" Hide Menubar : false");
}
if (hidetool)
{
Console.WriteLine(" Hide Toolbar : true");
}
else
{
Console.WriteLine(" Hide Toolbar : false");
}
if (hidewinui)
{
Console.WriteLine(" Hide Window UI : true");
}
else
{
Console.WriteLine(" Hide Window UI : false");
}
// オープンアクションを取得
showAction(openmode.getOpenAction());
// カスタムプロパティを取得
Console.WriteLine(Environment.NewLine);
Console.WriteLine("Custom Property");
PtlCustomProperties customProperties = docproperty.getCustomProperties();
int numCustomProperties = customProperties.getCount();
for (int i = 0; i < numCustomProperties; ++i)
{
PtlCustomProperty prop = customProperties.get(i);
Console.WriteLine(" Name : {0}", prop.getName());
Console.WriteLine(" Value : {0}", prop.getValue());
}
Console.WriteLine("\n");
Console.WriteLine("Security Information");
bool isEncrypted = doc.isEncrypted();
if (!isEncrypted)
{
Console.WriteLine(" Not Encrypted.");
return;
}
PtlEncrypt encrypt = doc.getEncrypt();
int filterType = (int)encrypt.getFilterType();
if (filterType != (int)PtlEncrypt.FILTER_TYPE.FILTER_STANDARD)
{
return;
}
PtlEncryptStandard encryptStandard = (PtlEncryptStandard)encrypt;
Console.WriteLine(" Security Handler : Standard Security");
int keyLength = encrypt.getKeyLength();
Console.WriteLine(" Key Length : {0}", keyLength);
int method = (int)encryptStandard.getMethod();
if (method == (int)PtlEncryptStandard.STANDARD_METHOD_TYPE.METHOD_RC4)
{
Console.WriteLine(" Method = RC4");
}
else
if (method == (int)PtlEncryptStandard.STANDARD_METHOD_TYPE.METHOD_RC4)
{
Console.WriteLine(" Method = AES");
}
PtlEncryptPermission perms = encryptStandard.getPermission();
switch (perms.getType())
{
case PtlEncryptPermission.PERM_TYPE.PERM_TYPE1:
{
Console.WriteLine(" Permission Type1");
PtlEncryptPermissionType1 perms1 = (PtlEncryptPermissionType1)perms;
bool print = perms1.getPrint();
if (print)
{
Console.WriteLine(" Print : allowed.");
}
else
{
Console.WriteLine(" Print : not allowed.");
}
PtlEncryptPermissionType1.PERMISSION_MODIFY modify = perms1.getModify();
switch (modify)
{
case PtlEncryptPermissionType1.PERMISSION_MODIFY.PERM_MODIFY_NOT_ALLOWED:
Console.WriteLine(" Modify : not allowed.");
break;
case PtlEncryptPermissionType1.PERMISSION_MODIFY.PERM_MODIFY_ANNOTANDFORM:
Console.WriteLine(" Modify : Commenting, filling in form fields, and signing existing signature fields.");
break;
case PtlEncryptPermissionType1.PERMISSION_MODIFY.PERM_MODIFY_ASSEMBLEANDFORM:
Console.WriteLine(" Modify : Page layout, filling in form fields, and signing existing signature fields.");
break;
case PtlEncryptPermissionType1.PERMISSION_MODIFY.PERM_MODIFY_MODYFYDOC:
Console.WriteLine(" Modify : Any except extracting pages.");
break;
}
bool copy = perms1.getCopy();
if (copy)
{
Console.WriteLine(" Copy : Enable copying of text, images, and other content and access for the visually impaired.");
}
else
{
Console.WriteLine(" Copy : Disable copying of text, images, and other content and access for the visually impaired.");
}
}
break;
case PtlEncryptPermission.PERM_TYPE.PERM_TYPE2:
{
Console.WriteLine(" Permission Type2");
PtlEncryptPermissionType2 perms2 = (PtlEncryptPermissionType2)perms;
PtlEncryptPermissionType2.PERMISSION_PRINT print = perms2.getPrint();
switch (print)
{
case PtlEncryptPermissionType2.PERMISSION_PRINT.PERM_PRINT_NOT_ALLOWED:
Console.WriteLine(" Print : not allowed.");
break;
case PtlEncryptPermissionType2.PERMISSION_PRINT.PERM_PRINT_LOW:
Console.WriteLine(" Print : Low resolution.");
break;
case PtlEncryptPermissionType2.PERMISSION_PRINT.PERM_PRINT_HIGH:
Console.WriteLine(" Print : High resolution.");
break;
}
PtlEncryptPermissionType2.PERMISSION_MODIFY modify = perms2.getModify();
switch (modify)
{
case PtlEncryptPermissionType2.PERMISSION_MODIFY.PERM_MODIFY_NOT_ALLOWED:
Console.WriteLine(" Modify : not allowed.");
break;
case PtlEncryptPermissionType2.PERMISSION_MODIFY.PERM_MODIFY_ASSEMBLEDOC:
Console.WriteLine(" Modify : Inserting, deleting, and rotating pages.");
break;
case PtlEncryptPermissionType2.PERMISSION_MODIFY.PERM_MODIFY_FILLFORM:
Console.WriteLine(" Modify : Filling in form fields, and signing existing signature fields.");
break;
case PtlEncryptPermissionType2.PERMISSION_MODIFY.PERM_MODIFY_ANNOTANDFORM:
Console.WriteLine(" Modify : Commenting, filling in form fields, and signing existing signature fields.");
break;
case PtlEncryptPermissionType2.PERMISSION_MODIFY.PERM_MODIFY_MODYFYDOC:
Console.WriteLine(" Modify : Any except extracting pages.");
break;
}
bool copy = perms2.getCopy();
if (copy)
{
Console.WriteLine(" Copy : Enable copying of text, images, and other content.");
}
else
{
Console.WriteLine(" Copy : Disable copying of text, images, and other content.");
}
bool acc = perms2.getAccessibility();
if (acc)
{
Console.WriteLine(" Accessibility : Enable text access for screen render devices for the visually impaired.");
}
else
{
Console.WriteLine(" Accessibility : Disable text access for screen render devices for the visually impaired.");
}
}
break;
}
Console.WriteLine(Environment.NewLine);
Console.WriteLine("Standard Information");
if (doc.isSignatured())
{
Console.WriteLine(" Signature : true");
}
else
{
Console.WriteLine(" Signature : false");
}
if (doc.isPDFA())
{
Console.WriteLine(" PDF/A : true");
}
else
{
Console.WriteLine(" PDF/A : false");
}
if (doc.isPDFX())
{
Console.WriteLine(" PDF/X : true");
}
else
{
Console.WriteLine(" PDF/X : false");
}
}
}
}
catch (PtlException pex)
{
Console.WriteLine(pex.getErrorCode() + " : " + pex.getErrorMessageJP());
pex.Dispose();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
Console.WriteLine("\n");
Console.WriteLine("-- 完了 --");
}
}
public static int showAction(PtlAction action)
{
try
{
switch (action.getType())
{
case PtlAction.ACTION_TYPE.TYPE_NONE:
Console.WriteLine(" Action : none");
break;
case PtlAction.ACTION_TYPE.TYPE_UNKNOWN:
Console.WriteLine(" Action : unknown");
break;
case PtlAction.ACTION_TYPE.TYPE_GOTO:
{
Console.WriteLine(" Action : GoTo");
PtlActionGoTo actGoTo = (PtlActionGoTo)action;
PtlDest dest = actGoTo.getDest();
int ret = showDest(dest);
if (ret != 0)
{
return ret;
}
}
break;
case PtlAction.ACTION_TYPE.TYPE_GOTO_R:
{
Console.WriteLine(" Action : GoToR");
PtlActionGoToR actGoToR = (PtlActionGoToR)action;
PtlDest dest = actGoToR.getDest();
int ret = showDest(dest);
if (ret != 0)
{
return ret;
}
}
break;
case PtlAction.ACTION_TYPE.TYPE_LAUNCH:
{
Console.WriteLine(" Action : Launch");
PtlActionLaunch actLaunch = (PtlActionLaunch)action;
Console.WriteLine(" file name : {0}", actLaunch.getFileName());
bool flag = actLaunch.getNewWindowFlag();
if (flag)
{
Console.WriteLine(" new window : true");
}
else
{
Console.WriteLine(" new window : false");
}
}
break;
case PtlAction.ACTION_TYPE.TYPE_URI:
{
Console.WriteLine(" Action : URI");
PtlActionURI actURI = (PtlActionURI)action;
Console.WriteLine(" uri : {0}", actURI.getURI());
}
break;
}
}
catch (PtlException e)
{
Console.WriteLine(" Error Message: {0}", e.getErrorMessage());
Console.WriteLine("\n");
return e.getErrorCode();
}
catch (Exception)
{
Console.WriteLine("Unknown error has occured.");
Console.WriteLine("\n");
return -2;
}
return 0;
}
public static int showDest(PtlDest dest)
{
try
{
PtlDest.DEST_TYPE destType = dest.getType();
int pageNumber = dest.getPageNumber();
switch (destType)
{
case PtlDest.DEST_TYPE.TYPE_NONE:
Console.WriteLine(" Dest : none");
break;
case PtlDest.DEST_TYPE.TYPE_XYZ:
{
Console.WriteLine(" Dest page : {0}", pageNumber);
Console.WriteLine(" Dest type : XYZ");
float left = 0.0f;
if (!dest.isLeftNull())
left = dest.getLeft();
Console.WriteLine(" left : {0}", left);
float top = 0.0f;
if (!dest.isTopNull())
top = dest.getTop();
Console.WriteLine(" top : {0}", top);
float zoom = 0.0f;
if (!dest.isZoomNull())
zoom = dest.getZoom();
Console.WriteLine(" zoom : {0}", zoom);
}
break;
case PtlDest.DEST_TYPE.TYPE_FIT:
Console.WriteLine(" Dest page : {0}", pageNumber);
Console.WriteLine(" Dest type : Fit");
break;
case PtlDest.DEST_TYPE.TYPE_FIT_H:
{
Console.WriteLine(" Dest page : {0}", pageNumber);
Console.WriteLine(" Dest type : FitH");
float top = 0.0f;
if (!dest.isTopNull())
top = dest.getTop();
Console.WriteLine(" top : {0}", top);
}
break;
case PtlDest.DEST_TYPE.TYPE_FIT_V:
{
Console.WriteLine(" Dest page : {0}", pageNumber);
Console.WriteLine(" Dest type : FitV");
float left = 0.0f;
if (!dest.isLeftNull())
left = dest.getLeft();
Console.WriteLine(" left : {0}", left);
}
break;
case PtlDest.DEST_TYPE.TYPE_FIT_R:
{
Console.WriteLine(" Dest page : {0}", pageNumber);
Console.WriteLine(" Dest type : FitR");
float left = 0.0f;
if (!dest.isLeftNull())
left = dest.getLeft();
Console.WriteLine(" left : {0}", left);
float bottom = 0.0f;
if (!dest.isBottomNull())
bottom = dest.getBottom();
Console.WriteLine(" bottom : {0}", bottom);
float right = 0.0f;
if (!dest.isRightNull())
right = dest.getRight();
Console.WriteLine(" right : {0}", right);
float top = 0.0f;
if (!dest.isTopNull())
top = dest.getTop();
Console.WriteLine(" top : {0}", top);
float zoom = 0.0f;
if (!dest.isZoomNull())
zoom = dest.getZoom();
Console.WriteLine(" zoom : {0}", zoom);
}
break;
case PtlDest.DEST_TYPE.TYPE_FIT_B:
Console.WriteLine(" Dest page : {0}", pageNumber);
Console.WriteLine(" Dest type : FitB");
break;
case PtlDest.DEST_TYPE.TYPE_FIT_BH:
{
Console.WriteLine(" Dest page : {0}", pageNumber);
Console.WriteLine(" Dest type : FitBH");
float top = 0.0f;
if (!dest.isTopNull())
top = dest.getTop();
Console.WriteLine(" top : {0}", top);
}
break;
case PtlDest.DEST_TYPE.TYPE_FIT_BV:
{
Console.WriteLine(" Dest page : {0}", pageNumber);
Console.WriteLine(" Dest type : FitBV");
float left = 0.0f;
if (!dest.isLeftNull())
left = dest.getLeft();
Console.WriteLine(" left : {0}", left);
}
break;
}
}
catch (PtlException e)
{
Console.WriteLine(" Error Message: {0}", e.getErrorMessage());
Console.Write("\n");
return e.getErrorCode();
}
catch (Exception)
{
Console.WriteLine("Unknown error has occured.");
Console.Write("\n");
return -2;
}
return 0;
}
}
}
AHPDFToolCmd80.exe -getFileInfo -d C:\in\test1.pdf
実行例
コマンドラインでの実行例
GetDocInfo_2.exe C:\in\test1.pdf
PDF Version
major : 1
minor : 7
Document Information
Title : PDF Tool API V7.0 コマンドライン説明書
Subject :
Author : アンテナハウス株式会社
Keywords :
Creator : AH Formatter V6.6 MR1 for Linux64 : 6.6.2.35616 (2018/10/15 18:42JST)
Producer : Antenna House PDF Output Library 6.6.1317 (Linux64)
CreationDate : 2021/4/23 11:26:49
ModifyDate : 2021/5/25 17:33:30
Max Page : 68
View Information
Direction : Left to Right
PageLayout : SinglePage
PageMode : Use Outlines
FitWindow : false
CenterWindow : false
Full Screen : false
Display Doc Title : false
Hide Menubar : false
Hide Toolbar : false
Hide Window UI : false
Action : none
Custom Property
Security Information
Security Handler : Standard Security
Key Length : 256
Permission Type2
Print : High resolution.
Modify : Commenting, filling in form fields, and signing existing signature fields.
Copy : Enable copying of text, images, and other content.
Accessibility : Enable text access for screen render devices for the visually impaired.
Standard Information
Signature : false
PDF/A : false
PDF/X : false
完了!
java -jar GetDocInfo_2.jar C:\in\test1.pdf
PDF Version
major : 1
minor : 7
Document Information
Title : PDF Tool API V7.0 コマンドライン説明書
Subject :
Author : アンテナハウス株式会社
Keywords :
Creator : AH Formatter V6.6 MR1 for Linux64 : 6.6.2.35616 (2018/10/15 18:42JST)
Producer : Antenna House PDF Output Library 6.6.1317 (Linux64)
CreationDate : 2021/4/23 11:26:49
ModifyDate : 2021/5/25 17:33:30
Max Page : 68
View Information
Direction : Left to Right
PageLayout : SinglePage
PageMode : Use Outlines
FitWindow : false
CenterWindow : false
Full Screen : false
Display Doc Title : false
Hide Menubar : false
Hide Toolbar : false
Hide Window UI : false
Action : none
Custom Property
Security Information
Security Handler : Standard Security
Key Length : 256
Permission Type2
Print : High resolution.
Modify : Commenting, filling in form fields, and signing existing signature fields.
Copy : Enable copying of text, images, and other content.
Accessibility : Enable text access for screen render devices for the visually impaired.
Standard Information
Signature : false
PDF/A : false
PDF/X : false
-- 完了 --
GetDocInfo_2.exe C:\in\test1.pdf PDF Version major : 1 minor : 7 Document Information Title : PDF Tool API V7.0 コマンドライン説明書 Subject : Author : アンテナハウス株式会社 Keywords : Creator : AH Formatter V6.6 MR1 for Linux64 : 6.6.2.35616 (2018/10/15 18:42JST) Producer : Antenna House PDF Output Library 6.6.1317 (Linux64) CreationDate : 2021/4/23 11:26:49 ModifyDate : 2021/5/25 17:33:30 Max Page : 68 View Information Direction : Left to Right PageLayout : SinglePage PageMode : Use Outlines FitWindow : false CenterWindow : false Full Screen : false Display Doc Title : false Hide Menubar : false Hide Toolbar : false Hide Window UI : false Action : none Custom Property Security Information Security Handler : Standard Security Key Length : 256 Permission Type2 Print : High resolution. Modify : Commenting, filling in form fields, and signing existing signature fields. Copy : Enable copying of text, images, and other content. Accessibility : Enable text access for screen render devices for the visually impaired. Standard Information Signature : false PDF/A : false PDF/X : false -- 完了 --
AHPDFToolCmd80.exe -getFileInfo -d C:\in\test1.pdf
PDF Version
major : 1
minor : 7
Document Information
Title : PDF Tool API V7.0 コマンドライン説明書
Subject :
Author : アンテナハウス株式会社
Keywords :
Creator : AH Formatter V6.6 MR1 for Linux64 : 6.6.2.35616 (2018/10/15 18:42JST)
Producer : Antenna House PDF Output Library 6.6.1317 (Linux64)
CreateDate : 2021/4/23 11:26:49
ModifyDate : 2021/5/25 17:33:30
Max Page : 68
View Information
Direction : Left to Right
PageLayout : Single Page
PageMode : Use Outlines
FitWindow : false
CenterWindow : false
Full Screen : false
Display Doc Title : false
Hide Menubar : false
Hide Toolbar : false
Hide Window UI : false
Action : none
Custom Property
Security Information
Security Handler : Standard Security
Key Length : 256
Permission Type2
Print : High resolution.
Modify : Commenting, filling in form fields, and signing existing signature fields.
Copy : Enable copying of text, images, and other content.
Accessibility : Enable text access for screen render devices for the visually impaired.
Standard Information
Signature : false
PDF/A : false
PDF/X : false
use time 0.017000s
出力結果イメージ
APIのサンプルでもコマンドラインで出力するすべての項目が出力されました。
コマンドラインでパラメータの指定が無い場合はすべての情報が出力されます。

