アットウィキロゴ

pdf

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package pdf;

/**
*
* @author ce00582
*/
import java.io.*;

import com.lowagie.text.*;
import com.lowagie.text.pdf.*;

public class pro {

  public static void main(String[] args){
    FileOutputStream out = null;
    BufferedOutputStream bout = null;
    PdfWriter writer = null;
    Document doc = null;
    try {
      out = new FileOutputStream("test.pdf");
      bout = new BufferedOutputStream(out);
      doc = new Document(new Rectangle(0,0,500,500));
      writer = PdfWriter.getInstance(doc, bout);
      doc.open();
      Font kaku_24 = new Font(BaseFont.createFont(
          "HeiseiKakuGo-W5","UniJIS-UCS2-H",
          BaseFont.NOT_EMBEDDED),18);
      kaku_24.setColor(CMYKColor.RED);
      doc.add(new Paragraph("これは、サンプルです。", kaku_24));
      Font mincho_12 = new Font(BaseFont.createFont(
          "HeiseiMin-W3", "UniJIS-UCS2-HW-H",
          BaseFont.NOT_EMBEDDED),12);
      doc.add(new Paragraph("サンプルとして作成したPDFファイルです。", mincho_12));
      doc.add(new Paragraph("果たして、きれいにできたでしょうか。", mincho_12));
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (DocumentException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      doc.close();
      System.out.println("ended...");
    }
  }
}
最終更新:2011年08月17日 22:29