Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

IText

From ZeroWiki
Revision as of 05:31, 7 February 2021 by imported>Unknown
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Java를 이용하여 PDF 파일을 제작을 도와주는 라이브러리. 라이선스는 MPLLGPL.

RefactorMe 페이지이름이 부적절하다고 생각하시는 분은 페이지이름바꾸기해 주세요. 프로젝트(라이브러리) 이름을 그대로 사용했습니다. 

관련링크

예제

  • HelloWorld
package spike;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;


public class HelloWorld {
    public HelloWorld() {
        writeHello();
    }
    
    private void writeHello() {
        Document document = new Document();
        try {
            PdfWriter.getInstance(document, new FileOutputStream("Hello.pdf"));
	        document.open();
	        document.add(new Paragraph("Hello, World"));
	        document.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (DocumentException e) {
            e.printStackTrace();
        }
    }

    public static void main(String args[]) {
        new HelloWorld();
    }
}
  
 결과 파일 : Hello.pdf

도구분류, 프로그래밍분류