ダウンロードitext-1.3
して、のlibフォルダーに配置しましjdk 1.6.0
た。また、lib フォルダーをシステム変数の CLASSPATH として追加しました。
しかし、プログラムを実行するとエラーが発生します:
パッケージ com.itextpdf.text が存在しません。
他のすべてのパッケージについても同様です。私が犯した間違いは何ですか?
import java.io.FileOutputStream;
import java.io.IOException;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
/**
* First iText example: Hello World.
*/
public class HelloWorld {
/** Path to the resulting PDF file. */
public static final String RESULT
= "E:/hello.pdf";
/**
* Creates a PDF file: hello.pdf
* @param args no arguments needed
*/
public static void main(String[] args)
throws DocumentException, IOException {
new HelloWorld().createPdf(RESULT);
}
/**
* Creates a PDF document.
* @param filename the path to the new PDF document
* @throws DocumentException
* @throws IOException
*/
public void createPdf(String filename)
throws DocumentException, IOException {
// step 1
Document document = new Document();
// step 2
PdfWriter.getInstance(document, new FileOutputStream(filename));
// step 3
document.open();
// step 4
document.add(new Paragraph("Hello World!"));
// step 5
document.close();
}
}