package com.hundsun.gildata.irp.core.action;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import com.hundsun.gildata.irp.common.util.ItextUtils;
import com.itextpdf.text.Document;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.pdf.PdfWriter;
public class MakePdfTest {
// final int headFontSize = 18;
// final int sectionFontSize = 12;
final int margin = 10;
att = filePath + fileName;
if (!file.exists()) {
file.mkdirs();
}
PdfWriter pdf = null;
try {
document
= new Document(PageSize.
A4, margin, margin, margin, margin
);
pdf = PdfWriter.getInstance(document, fos);
document.open();
String summary
= " this is a pdf made bycode\n 另起一行".
replaceAll("\n",
"<br/>").
replaceAll(" ",
" ");
document.add(ItextUtils.processViewpoint(summary));
att = filePath + fileName;
return;
} finally {
if (document != null) {
document.close();
}
if (pdf != null) {
pdf.close();
}
if (fos != null) {
fos.close();
}
}
}
public static void main
(String[] args
) {
MakePdfTest testMake = new MakePdfTest();
try {
testMake.makdPdf();
System.
out.
println(testMake.
att);
e.printStackTrace();
}
}
}
//java/1341