2

現在、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);
4

1 に答える 1

0

URL はエスケープする必要があり、openDoc メソッドは次のようになります。

var myURL = encodeURI("http://www.example.com");

app.openDoc({cPath: myURL, cFS: "CHTTP" });

CPATH: "開くドキュメントへのデバイスに依存しないパス。oDoc が指定されている場合、パスはそれに対する相対パスにすることができます。ターゲット ドキュメントは、既定のファイル システムでアクセスできる必要があります。"

CHTTP: "ソース ファイル システム名を指定する文字列。次の 2 つの値がサポートされています。デフォルトのファイル システムを表す (デフォルトの空の文字列)、および "CHTTP"。このパラメーターは、Web サーバーがサポートしている場合にのみ関連します。WebDAV .」

http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Acrobat9_HTMLHelp&file=JS_API_AcroJS.88.131.html#1995988

于 2012-09-21T20:14:44.520 に答える