/* * 初期表示。 * 拡大、ページ番号、ナビゲーションタブ、タイトルバーなど、ドキュメントの初期表示 * プロパティを定義します。 * * 2ページ目の文書を固定ウィンドウサイズで開き、ズームを300%にして、左上の座標 * (720,100)でページを表示するように定義します。 * * さらに、しおりを表示し、Acrobat のタイトルバーに文書タイトルを表示します。 * * 必要なソフトウェア: PDFlib/PDFlib+PDI/PPS 10 * 必要なデータ: 無し */ package com.pdflib.cookbook.pdflib.general; import com.pdflib.pdflib; import com.pdflib.PDFlibException; public class initial_view { public static void main (String argv[]) { /* 必要に応じてファイルの場所を指定する */ String searchpath = "../input"; String outfile = "initial_view.pdf"; String title = "Initial View"; pdflib p = null; String optlist; int exitcode = 0; try { p = new pdflib(); p.set_option("searchpath={" + searchpath + "}"); /* load_font()の戻り値を確認する */ p.set_option("errorpolicy=return"); /* 2ページ目のドキュメントを表示倍率を300%にして固定ウィンドウサイズで開く。 * 左上の座標(720,100)のページを表示する。 * さらに、Acrobatのタイトルバーに文書タイトルを表示し、 * しおりのナビゲーションパネルを表示します。 */ optlist = "destination={page=2 type=fixed zoom=3 top=720 left=100} " + "viewerpreferences=displaydoctitle openmode=bookmarks "; if (p.begin_document(outfile, optlist) == -1) throw new Exception("Error: " + p.get_errmsg()); p.set_info("Creator", "PDFlib Cookbook"); p.set_info("Title", title); /* 1 ページ目を始める */ p.begin_page_ext(0, 0, "width=a4.width height=a4.height"); /* しおりを作成する */ p.create_bookmark("Page 1", ""); p.fit_textline("This is page 1", 100, 700, "fontname=NotoSerif-Regular fontsize=20"); p.end_page_ext(""); /* 2 ページ目を始める */ p.begin_page_ext(0, 0, "width=a4.width height=a4.height"); /* しおりを作成する */ p.create_bookmark("Page 2", ""); p.fit_textline("Page 2 is displayed with this text", 100, 700, "fontname=NotoSerif-Regular fontsize=18"); p.fit_textline("moved to the top left and a zoom", 100, 660, "fontname=NotoSerif-Regular fontsize=18"); p.fit_textline("of 300% when opening the document", 100, 620, "fontname=NotoSerif-Regular fontsize=18"); p.end_page_ext(""); p.end_document(""); } catch (PDFlibException e) { System.err.println("PDFlib exception occurred:"); System.err.println("[" + e.get_errnum() + "] " + e.get_apiname() + ": " + e.get_errmsg()); exitcode = 1; } catch (Exception e) { System.err.println(e); exitcode = 1; } finally { if (p != null) { p.delete(); } System.exit(exitcode); } } }