Home
ZINEのPDFを書き出したいときに使えるプログラムです. Processing IDEで動作します.
1ページ分はA4サイズ(裁ち落としなし),見開きでは2ページ分でA3サイズ(裁ち落としなし)での書き出しを想定しています. いくつかの配置テンプレートをまとめています.
デフォルトで使用するフォントは以下です. フォントをインストールした上で実行してください.
実行すると,コードとZINE-TEMPLATE/ZineTemplate/data/
に置かれたデータを使い,ZINE-TEMPLATE/ZineTemplate/output/
にPDFを1ページずつ書き出します.
1つ1つのページは,ZineTemplate.pde
内のgeneratePages()
内に処理を書いて生成します.配置テンプレートについては,他のページで説明しています.
public ArrayList<Page> generatePages() {
// 中略
// こんな感じで追加する
pages.add( new CoverSpreadLeft(Section.chap1_sec1_cover) ); // 1章1節見開き表紙左
pages.add( new CoverSpreadRight(Section.chap1_sec1_cover, color(#FFFFFF), null) ); // 1章1節見開き表紙右
pages.add( new DescriptionPage(Section.chap1_sec1, "description/") ); // DescriptionPageの例
// 中略
return pages;
}
PDFを書き出すときは,ZineTemplate.pde
の以下の記述をtrue
にしてください.
デフォルトはtrue
です.
boolean isExportPDF = true; // 全ページをPDFとして出力
書き出す時のページ配置を選べます.
- A3サイズ:2ページを横に並べて書き出す
- A4サイズ:1ページだけ書き出す
2ページを横に並べるときは,ZineTemplate.pde
の以下の記述をtrue
にしてください.
デフォルトはtrue
です.
boolean isTwoSheets = true; // 2ページを横に並べて,見開き1ページとして表示
レイアウトの基準となるグリッドを用意しています.
背景にグリッドを表示する場合は,ZineTemplate.pde
の以下の記述をtrue
にしてください.
デフォルトはfalse
です.
boolean isVisibleGrid = false; // 描画の基準として使用する水色のグリッドを,背景に表示
Author.pde
内の,執筆者の役割を示すクラスRole
内の項目を追加/削除してください.役割を追加する場合はrole5
(あくまで一例)などとして追加します.
role1("役割1"),
role2("役割2"),
role3("役割3"),
role4("役割4");
次にAuthor.pde
内の,著者リストを表すクラスAuthor
内の項目を追加/削除してください.著者を追加する場合はauthor7
(あくまで一例)などとして追加します.
author1("執筆者1", "author1", "執筆者1の所属", new Role[]{ Role.role1, Role.role2, Role.role3 }),
author2("執筆者2", "author2", "執筆者2の所属", new Role[]{ Role.role1, Role.role2, Role.role3 }),
author3("執筆者3", "author3", "執筆者3の所属", new Role[]{ Role.role1, Role.role2, Role.role3 }),
author4("執筆者4", "author4", "執筆者4の所属", new Role[]{ Role.role1, Role.role4 }),
author5("執筆者5", "author5", "執筆者5の所属", new Role[]{ Role.role1, Role.role4 }),
author6("執筆者6", "author6", "執筆者6の所属", new Role[]{ Role.role1, Role.role4 });
ZineTemplate.pde
にあるパスを表す変数を,必要に応じて追加/削除してください.
// Sectionのenum内で使うパス
static String cover_path = "cover/";
static String foreword_path = "foreafter/foreword/";
static String contents_path = "contents_table/";
static String chap1_path = "chapter1/";
static String sec1_path = "section1/";
static String afterword_path = "foreafter/afterword/";
static String colophon_path = "colophon/";
static String backcover_path = "backcover/";
Section.pde
内の,章/節のリストを表すクラスSection
内の項目を追加/削除してください.先ほどのパスを表す変数を使って,パスを設定してください.
cover(cover_path, "表紙", new Author[]{ Author.author1 }),
foreword(foreword_path, "まえがき", new Author[]{ Author.author1 }),
contents(contents_path, "目次", new Author[]{ Author.author1 }),
chap1_cover(chap1_path + cover_path, "1章", new Author[]{ Author.author1, Author.author2, Author.author3, Author.author4, Author.author5, Author.author6 }),
chap1_sec1_cover(chap1_path + sec1_path + cover_path, "1章1節表紙", new Author[]{ Author.author1 }),
chap1_sec1(chap1_path + sec1_path, "1章1節", new Author[]{ Author.author1 }),
afterword(afterword_path, "あとがき", new Author[]{ Author.author1, Author.author2, Author.author3, Author.author4, Author.author5, Author.author6 }),
colophon(colophon_path, "奥付", new Author[]{ Author.author1 }),
backcover(backcover_path, "裏表紙", new Author[]{ Author.author1 }),
empty("", "", new Author[]{});
各配置テンプレートは,classとして作っています(DescriptionPage.pde
のように,各pdeファイルに書いています).
Pageクラス(Page.pde
)を継承して作っています.
命名規則は以下です.
役割 | クラス名 | 命名例 |
---|---|---|
文章を書くページ | DescriptionPage |
DescriptionPage |
画像だけのページ | LargeImagePage |
LargeImagePage2 |
文章と画像が配置されるページ |
[クラス名] + [画像の枚数]
|
DescriptionPage12 |
コードを載せるページ |
[クラス名] + Code
|
DescriptionPage1Code |
各画像のサイズが異なるページ |
[クラス名] + mini + [サイズが異なる画像の枚数]
|
DescriptionPage2mini1 |