【HSP3】HNBridgeを使用して、iTextSharpでPDFの情報を読み出すテスト

つやぴん氏(@tuyapin)作「HNBridge」を使用して、iTextSharpでPDFの情報を読み出すテスト

つやぴん氏(@tuyapin)作「HNBridge」を使用して、iTextSharpでPDFの情報を読み出すテスト

  • hk1v
  • 2014/8/13 18:33
/**

	つやぴん氏作「HNBridge」を使用して、iTextSharpでPDFの情報を読み出すテスト

	【このプログラムを実行するには!】
	
	※	2014/08/13現在、
	http://tuyapin.net/hsp/hnbridge
	で入手可能なバージョン(1.0.0_45)は、IDictionaryの操作をサポートしていない為、
	https://github.com/tuyapin/HNBridge
	で入手可能なソースコードをVisualStudioでビルドして出力されたHNBridge.dllを使用する必要があります。
	また、HNBridge.asファイルに、
	
	#func global _GetDProperty "GetDProperty" sptr, sptr, var

	#defcfunc GetDProperty str p1, str p2
		hoge = "";
		_GetDProperty p1, p2, hoge
	return hoge;

	を追加する必要があります。
	
	将来のバージョンでは修正されている可能性があります。
	
*/

#include "HNBridge.as"
#module
#defcfunc safeNull str p1
	if p1 == "hdn://NULL" : return ""
return p1
#global

	title "HNBridgeを使用して、iTextSharpでPDFの情報を読み出すテスト"

	LoadAssembly "itextsharp.dll"

	CreateObjectFromClassName "iTextSharp.text.pdf.PdfReader"
	
	dialog "pdf", 16
	if stat == 0 : end
	fname = refstr
	mes "ファイル名: \t\t"+fname
	
	CreateInstanceWithOneArg fname

	mes "PDF変換: \t\t"+safeNull(GetDProperty("Info", "Producer"))
	mes "作成日時: \t\t"+safeNull(GetDProperty("Info", "CreationDate"))
	mes "題名: \t\t\t"+safeNull(GetDProperty("Info", "Subject"))
	mes "アプリケーション: \t"+safeNull(GetDProperty("Info", "Creator"))
	mes "キーワード: \t\t"+safeNull(GetDProperty("Info", "Keywords"))
	mes "編集日時: \t\t"+safeNull(GetDProperty("Info", "ModDate"))
	mes "タイトル: \t\t"+safeNull(GetDProperty("Info", "Title"))
	
	mes "PDFページ数: \t\t"+GetProperty("NumberOfPages")
	mes "PDFバージョン: \t\t1."+GetProperty("PdfVersion")
	
	InvokeMethodWithZeroArgs "Close"
	UnloadAssembly