|
|
@@ -10,6 +10,7 @@ import com.goafanti.common.utils.excel.FileUtils;
|
|
|
|
|
|
import com.goafanti.common.utils.pdf.PDFUtils;
|
|
|
import com.lowagie.text.*;
|
|
|
+import com.lowagie.text.Font;
|
|
|
import com.lowagie.text.pdf.BaseFont;
|
|
|
import com.lowagie.text.rtf.RtfWriter2;
|
|
|
import com.sushengren.easyword.EasyWord;
|
|
|
@@ -18,6 +19,7 @@ import org.springframework.http.MediaType;
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.awt.*;
|
|
|
import java.io.*;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
@@ -128,16 +130,43 @@ public class WordUtils {
|
|
|
}
|
|
|
|
|
|
private Font setFont(int size, int style) {
|
|
|
- BaseFont baseFont=null;
|
|
|
- Font font=null;
|
|
|
+ Font font=new Font(Font.NORMAL, size, style, new Color(0, 0, 0));
|
|
|
+ return font;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void test(){
|
|
|
+ // 创建word文档,并设置纸张的大小
|
|
|
+ Document document = new Document(PageSize.A4);
|
|
|
+ // 创建word文档
|
|
|
try {
|
|
|
- baseFont=BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
|
|
|
- font=new Font(baseFont,size,style);
|
|
|
- } catch (DocumentException e) {
|
|
|
+ RtfWriter2.getInstance(document, new FileOutputStream("D:/data/dbDetail.doc"));
|
|
|
+ document.open();// 设置文档标题
|
|
|
+// Paragraph ph = new Paragraph();
|
|
|
+// Font f = new Font();
|
|
|
+// Paragraph p = new Paragraph("数据库表设计文档", new Font(Font.NORMAL, 24, Font.BOLDITALIC, new Color(0, 0, 0)));
|
|
|
+// p.setAlignment(1);
|
|
|
+// document.add(p);
|
|
|
+ Paragraph p=new Paragraph("data.getRdName()",new Font(Font.NORMAL, 24, Font.BOLDITALIC, new Color(0, 0, 0)));
|
|
|
+ p.setAlignment(1);
|
|
|
+ document.add(p);
|
|
|
+ addDocument(document,"项目起止时间: ","data.getRdName()");
|
|
|
+ addDocument(document,"公司名称: ","data.getUserName()");
|
|
|
+ addDocument(document,"项目负责人: ","data.getConsultantName()");
|
|
|
+ addDocument(document,"技术领域: ","data.getTechnicalField()");
|
|
|
+ addDocument(document,"技术来源: ","data.getTechnologySource()");
|
|
|
+ addDocument(document,"研发费用总预计: ","data.getTotalAmount().toEngineeringString()"+" 万元");
|
|
|
+ addDocument(document,"研发目的/立项目的/实施方式",null);
|
|
|
+ addContent(document," data.getRdObjective()");
|
|
|
+ addDocument(document,"核心技术/创新点",null);
|
|
|
+ addContent(document," data.getCoreTechnology()");
|
|
|
+ addDocument(document,"成果",null);
|
|
|
+ addContent(document," data.getAchieveResults()");
|
|
|
+ document.close();
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
e.printStackTrace();
|
|
|
- } catch (IOException e) {
|
|
|
+ } catch (DocumentException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- return font;
|
|
|
}
|
|
|
}
|