티스토리 뷰

jOpenDocument는 비어있는 문서를 만드는데 약간 어려움이 있었지만 ODFDOM는 비어있는 문서도 쉽게 생성이 가능하다.
이틀립스 환경에서 진행.




0. odfdom 라이브러리 다운 받기
http://odftoolkit.org/projects/odfdom/pages/Home 여기가서 다운 받기 (jar, binary)

1. 이클립스에 빌드패스 추가하기.

Project > Properties > Java build path > Libraries > Add Jars or Add external Jars > 다운 받은 jar 파일 선택


2. 예제대로 따라하기.
// Create a text document from a standard template (empty documents within the JAR)
OdfTextDocument odt = OdfTextDocument.newTextDocument();

// Append text to the end of the document. 
odt.addText("This is my very first ODF test");

// Save document
odt.save("MyFilename.odt");

끝.

다음에는 이미지를 추가하는 방법을 알아보자. (조금 알아본바로는 OdfDrawImage를 아마 써야할듯 하다. ImageHandler라던가..)
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함