現在、PHP ライブラリ DOMPDF を使用して HTML から PDF を生成するアプリケーションを構築しています。PDF には、コンテンツを更新する機能、またはサイト API から入手できる場合は新しいバージョンをダウンロードする機能が必要です。これを達成するには、Acrobat Javascript を使用する必要があると思いますが、その方法がわかりません。私は、PDF に埋め込まれている次の JavaScript を作成しましたが、何もしません (警告ボックスも表示しません)。<script type="text/javascript">
タグを使用して HTML ヘッドに埋め込まれます。
これに関するヘルプは大歓迎です:)
// The JS that needs to be inserted in to a PDF file to self update
app.alert('checking for updates');
var version = "1";
var book_id = "1234";
var update_url = "http://localhost/koolbookz/"+book_id+"/"+version;
// Open the source documents:
var source1 = app.openDoc(update_url);
// Obtain the OCG order array for each source document:
var mergedOCGArray = new Array();
var source1OCGArray = source1.getOCGOrder();
// Merge the OCG order arrays into the target array:
for (var i=0; i<source1OCGArray.length; i++) mergedOCGArray[i] = source1OCGArray[i];
var offset = source1OCGArray.length;
// Create the target document:
var target = app.newDoc(book_id+".pdf");
// Insert source1.pdf:
target.insertPages({
nPage : -1,
cPath : update_url,
});
// Set the OCG order array in the target document
target.setOCGOrder(mergedOCGArray);
// Save the target document:
target.saveAs(book_id+".pdf");
// Close the target document without notifying the user:
//target.closeDoc(true);