(以下教導如何讓netbean的Project File匯入jar檔):
Step1:

Step2:

Step3:

Step4:

Step5:

經過上述的步驟,就已經成功將Jar檔加入這個Project了。
接下來開一個Class檔,
將以下程式call進去,再Compile + Run...
/**
* HelloWorld.java
*/
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
// 創建一個Document對象
Document document = new Document();
try {
// 生成名為 HelloWorld.pdf 的文檔
PdfWriter.getInstance(document, new FileOutputStream("HelloWorld.pdf"));
// 添加PDF文檔的一些信息
document.addTitle("Hello World example");
document.addAuthor("Bruno Lowagie");
document.addSubject("This example explains how to add metadata.");
document.addKeywords("iText, Hello World, step 3, metadata");
document.addCreator("My program using iText");
// 打開文檔,將要寫入內容
document.open();
// 插入一個段落
document.add(new Paragraph("Hello World!"));
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
// 關閉打開的文檔
document.close();
}
}
完成第一個pdf的產生。
如果我的不是java application 而係web application, 而要用到一的額外的jar file, 那我可以怎樣做? thank you for your help!
回覆刪除你這裡提到的web application指的是哪一種?
回覆刪除