From 8df1f1536e5cad547c60b833f407792d59221f88 Mon Sep 17 00:00:00 2001 From: Sakura9701 <328572838@qq.com> Date: Sun, 19 Jun 2022 15:47:46 +0800 Subject: [PATCH] =?UTF-8?q?getDoc=E7=BD=91=E4=B8=8A=E4=B8=93=E7=94=A8?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ts_obj/controller/TypesetController.java | 192 +++++++++--------- 1 file changed, 96 insertions(+), 96 deletions(-) diff --git a/src/main/java/com/example/ts_obj/controller/TypesetController.java b/src/main/java/com/example/ts_obj/controller/TypesetController.java index e4d4006..c5cb42f 100644 --- a/src/main/java/com/example/ts_obj/controller/TypesetController.java +++ b/src/main/java/com/example/ts_obj/controller/TypesetController.java @@ -98,7 +98,7 @@ public class TypesetController { ti.setInfo_type(info_type); ti.setMainText(""); ti.setAbstractText(""); -// System.out.println(ti.toString()); +// //System.out.println(ti.toString()); // // Integer res = 1; @@ -222,7 +222,7 @@ public class TypesetController { //获取行对应的单元格 List cells = row.getTableCells(); for (XWPFTableCell cell : cells) { - System.out.println(cell.getText()); + //System.out.println(cell.getText()); } } } @@ -246,7 +246,7 @@ public class TypesetController { // } // } // } -// System.out.println(pictureId +"\t|" + imageName + "\t|" + lastParagraphText); +// //System.out.println(pictureId +"\t|" + imageName + "\t|" + lastParagraphText); // //获取word文本中所有的图片 //// List allPictures = xdoc.getAllPictures(); // //遍历照片 @@ -262,7 +262,7 @@ public class TypesetController { // FileOutputStream fileOutputStream = new FileOutputStream(filePicture); // fileOutputStream.write(data,0,data.length); // fileOutputStream.close(); -// System.out.println("执行结束了"); +// //System.out.println("执行结束了"); //// } // } // } @@ -322,7 +322,7 @@ public class TypesetController { // Boolean bold = false; for (int i=0 ; i < list.size() ; i++){ // for (XWPFParagraph para : list) { - System.out.println("内容为"+list.get(i).getRuns()); + //System.out.println("内容为"+list.get(i).getRuns()); // ArrayList cac_al = new ArrayList();//加粗 // ArrayList cac_it = new ArrayList();//斜体 // String cache = para.getText().trim(); @@ -333,7 +333,7 @@ public class TypesetController { List runs = list.get(i).getRuns(); String replace = String.valueOf(runs).replace(",", "").replace(" ",""); if (replace.contains("Objective. A comprehensive and updated systematic review is needed to evaluate the effectiveness and safety of HuangQiXiXin decoction (HQXXD) for cough variant asthma (CVA). The aim of this systematic review protocol is to comprehensively assess the effectiveness and safety of HQXXD for CVA. Methods. An overall search for studies in main English and Chinese electronic databases from their inception to January 2021 will be performed. Randomized controlled trials (RCTs) regarding HQXXD for CVA will be included. We will use RevMan 5.3 software to perform statistical analysis and meta-analysis. Results. The findings of this systematic review will be disseminated through peer-reviewed publications. Conclusion. The systematic review will provide more evidence regarding the effectiveness and safety of HQXXD for CVA.".replace(",","").replace(" ",""))){ - System.out.println("确实包含"); + //System.out.println("确实包含"); // for (int r=0 ; r < runs.size() ; r++){ // runs.get(r); // @@ -370,7 +370,7 @@ public class TypesetController { cach = r.getText(0); } -// System.out.println(cach); +// //System.out.println(cach); // if(r.isItalic()&&r.getText(0)!=null){ // cach = ""+r.getText(0)+""; @@ -394,7 +394,7 @@ public class TypesetController { FileOutputStream os = new FileOutputStream("C:\\Users\\yl\\Desktop\\pictures\\1.doc"); xdoc.write(os); - System.out.println("输出完毕"); + //System.out.println("输出完毕"); //获取word文本中的所有表格 // Iterator tablesIterator = xdoc.getTablesIterator(); @@ -454,11 +454,11 @@ public class TypesetController { String main = ti.getMainText(); List l = JSON.parseArray(main, String.class); for (String s : l) { - System.out.println(s); + //System.out.println(s); } -// System.out.println(main); +// //System.out.println(main); // List l = (List) JSON.parseObject(main); -// System.out.println(l); +// //System.out.println(l); } catch (Exception e) { logger.error(e.getMessage()); } @@ -577,7 +577,7 @@ public class TypesetController { Paragraph paragraph = cell.getParagraphs().get(n); prList.add(paragraph.getText()); // bw.write(paragraph.getText() + "\t");//获取文本内容 - System.out.println("表格数据"+paragraph.getText()); + //System.out.println("表格数据"+paragraph.getText()); //遍历段落中的所有子对象 @@ -597,7 +597,7 @@ public class TypesetController { arrayList.add(prList); // bw.write("\r\n");//写入内容到txt文件 } - System.out.println("List=====================>"+arrayList); + //System.out.println("List=====================>"+arrayList); } } bw.flush(); @@ -624,7 +624,7 @@ public class TypesetController { } } - System.out.println("list===============>"+list); + //System.out.println("list===============>"+list); map.put("table", list); Configure config = Configure.builder().bind("content", new ParagraphRenderPolicy()). @@ -845,8 +845,8 @@ public class TypesetController { Paragraph paragraph = cell.getParagraphs().get(n); myText += paragraph.getText(); // bw.write(paragraph.getText() + "\t");//获取文本内容 - System.out.println("表格数据"+paragraph.getText()); - System.out.println("prlist=========="+prList); + //System.out.println("表格数据"+paragraph.getText()); + //System.out.println("prlist=========="+prList); // //遍历段落中的所有子对象 // for (int x = 0; x < paragraph.getChildObjects().getCount(); x++) @@ -866,12 +866,12 @@ public class TypesetController { arrayList.add(prList); // bw.write("\r\n");//写入内容到txt文件 } -// System.out.println("List=====================>"+arrayList); +// //System.out.println("List=====================>"+arrayList); tablesList.add(arrayList); } } -// System.out.println("tablesList============>"+tablesList); +// //System.out.println("tablesList============>"+tablesList); // bw.flush(); // bw.close(); // fw.close(); @@ -880,7 +880,7 @@ public class TypesetController { if (tablesList.size() > 1){ for (List ls:tablesList ) { -// System.out.println("ls================"+ls); +// //System.out.println("ls================"+ls); List list = new ArrayList<>(); LinkedHashMap params = new LinkedHashMap<>(); for (int i = 0; i < ls.size(); i++){ @@ -912,7 +912,7 @@ public class TypesetController { } num++; map.put("table"+num, list); - System.out.println("测试=====================》"+map.get("table"+num)); + //System.out.println("测试=====================》"+map.get("table"+num)); } }else { // @@ -935,7 +935,7 @@ public class TypesetController { } } - System.out.println("list9===============>"+list); + //System.out.println("list9===============>"+list); map.put("table1", list); } @@ -963,44 +963,44 @@ public class TypesetController { } map.put("main", mainArr); - JSONArray ja = (JSONArray) JSON.parse(typesetInfo.getRefers()); - ArrayList referArr = new ArrayList(); - int keyn = 0; - for (Object tif : ja){ - keyn++; - String tttt = keyn+" "+String.valueOf(tif).replace("", "").replace("", "").replace("", "").replace("", "").trim().toUpperCase(); - Map cache = new HashMap(); - Style chch = new Style(); - chch.setFontFamily("Charis SIL"); - chch.setFontSize(7.5); - cache.put("ref",new TextRenderData(tttt, chch)); - referArr.add(cache); - } - - map.put("refers",referArr); - - -// //测试 -// // JSONArray ja = (JSONArray) JSON.parse(typesetInfo.getRefers()); -// -// List refsl = new ArrayList(); -// for (Object tif : ja) { -// String tttt = String.valueOf(tif).replace("", "").replace("", "").replace("", "").replace("", "").trim().toUpperCase(); -//// if (tttt.equals("REFERENCE") || tttt.equals("REFERENCES")) { -//// continue; -//// } -// ParagraphRenderData chc_pd = new ParagraphRenderData(); -// +// ArrayList referArr = new ArrayList(); +// int keyn = 0; +// for (Object tif : ja){ +// keyn++; +// String tttt = keyn+" "+String.valueOf(tif).replace("", "").replace("", "").replace("", "").replace("", "").trim().toUpperCase(); +// Map cache = new HashMap(); // Style chch = new Style(); // chch.setFontFamily("Charis SIL"); // chch.setFontSize(7.5); -// String tgh_title = String.valueOf(tif).replace("", "").replace("", "").replace("", "").replace("", ""); -// chc_pd.addText(new TextRenderData(tgh_title, chch)); -// refsl.add(chc_pd); +// cache.put("ref",new TextRenderData(tttt, chch)); +// referArr.add(cache); // } // -// map.put("refs", new NumberingRenderData(NumberingFormat.DECIMAL, refsl)); +// map.put("refers",referArr); + + + //测试 + + JSONArray ja = (JSONArray) JSON.parse(typesetInfo.getRefers()); + + List refsl = new ArrayList(); + for (Object tif : ja) { + String tttt = String.valueOf(tif).replace("", "").replace("", "").replace("", "").replace("", "").trim().toUpperCase(); +// if (tttt.equals("REFERENCE") || tttt.equals("REFERENCES")) { +// continue; +// } + ParagraphRenderData chc_pd = new ParagraphRenderData(); + + Style chch = new Style(); + chch.setFontFamily("Charis SIL"); + chch.setFontSize(7.5); + String tgh_title = String.valueOf(tif).replace("", "").replace("", "").replace("", "").replace("", ""); + chc_pd.addText(new TextRenderData(tgh_title, chch)); + refsl.add(chc_pd); + } + + map.put("refs", new NumberingRenderData(NumberingFormat.DECIMAL, refsl)); String myTemplate = ""; //确定使用的模板 @@ -1169,7 +1169,7 @@ public class TypesetController { } } picMap.put(imageName,lastParagraphText); -// System.out.println(pictureId +"\t|" + imageName + "\t|" + lastParagraphText); +// //System.out.println(pictureId +"\t|" + imageName + "\t|" + lastParagraphText); //获取word文本中所有的图片 // List allPictures = xdoc.getAllPictures(); //遍历照片 @@ -1185,13 +1185,13 @@ public class TypesetController { FileOutputStream fileOutputStream = new FileOutputStream(filePicture); fileOutputStream.write(data,0,data.length); fileOutputStream.close(); -// System.out.println("执行结束了"); +// //System.out.println("执行结束了"); // } } } } -// System.out.println("picNameList===========>"+picNameList); -// System.out.println("picMap===========>"+picMap); +// //System.out.println("picNameList===========>"+picNameList); +// //System.out.println("picMap===========>"+picMap); //2.获取按模板新生成的文档添加图片 File newFile = new File(this.NEW_BASE_DIR + newFileName); FileInputStream newFis = new FileInputStream(newFile); @@ -1203,20 +1203,20 @@ public class TypesetController { Document doc = new Document(); doc.loadFromFile(this.NEW_BASE_DIR + newFileName); Section sec = doc.getSections().get(0); -// System.out.println("sec=================>"+sec); +// //System.out.println("sec=================>"+sec); String text = doc.getText(); -// System.out.println("text=================>"+text); +// //System.out.println("text=================>"+text); Paragraph para = sec.getParagraphs().get(0); -// System.out.println("para=================>"+para); +// //System.out.println("para=================>"+para); for(int i = 0; i < doc.getSections().getCount(); i++) { Section section = doc.getSections().get(i); for (int j = 0; j < section.getParagraphs().getCount(); j++) { Paragraph paragraph = section.getParagraphs().get(j); -// System.out.println(j+"新方式内容"+paragraph.getText()); +// //System.out.println(j+"新方式内容"+paragraph.getText()); for (String pic: picNameList) { String replace = String.valueOf(paragraph.getText()).replace(",", "").replace(" ", ""); if (replace.contains(picMap.get(pic).replace(",", "").replace(" ", ""))) { -// System.out.println("包含"); +// //System.out.println("包含"); String imgPath = IMG_DIR + randomFix +pic.replace("image", ""); File picture=new File(imgPath); @@ -1226,13 +1226,13 @@ public class TypesetController { //判断图片中是否包含 文字 // String valCode = new OCRUtil().recognizeText(new File(imgPath)); -// System.out.println("valCode==============>"+valCode); +// //System.out.println("valCode==============>"+valCode); // //正则表达式 // Pattern p = Pattern.compile("[\u4e00-\u9fa5]"); // Matcher m = p.matcher(valCode); -// System.out.println(m.find()); +// //System.out.println(m.find()); // if (m.find()){ -// System.out.println("查找到了文字"); +// //System.out.println("查找到了文字"); // //1.包含中文 单栏 // DocPicture docPicture = paragraph.appendPicture(imgPath); // docPicture.setWidth(500f); @@ -1270,11 +1270,11 @@ public class TypesetController { // Section section = doc.getSections().get(0); TableCollection tables = secs.get(i).getTables(); - System.out.println(tables); + //System.out.println(tables); //获取section中第一个表格 // Table table = sec.getTables().get(0); int count = tables.getCount(); - System.out.println("===================>"+count); + //System.out.println("===================>"+count); for (int j = 0; j < tables.getCount(); j++) { //给表格应用样式 tables.get(j).applyStyle(DefaultTableStyle.Table_Classic_1); @@ -1329,12 +1329,12 @@ public class TypesetController { String uuid = UUID.randomUUID().toString().trim().replaceAll("-", ""); // for (int i=0 ; i < paragraphs.size() ; i++){ -// System.out.println("内容为"+paragraphs.get(i).getRuns()); +// //System.out.println("内容为"+paragraphs.get(i).getRuns()); // List runs = paragraphs.get(i).getRuns(); // String replace = String.valueOf(runs).replace(",", "").replace(" ",""); // for (String pic: picNameList){ // if (replace.contains(picMap.get(pic).replace(",","").replace(" ",""))){ -// System.out.println("包含执行了"); +// //System.out.println("包含执行了"); // //获取光标 // XmlCursor xmlCursor = paragraphs.get(i+1).getCTP().newCursor(); // XWPFParagraph xwpfParagraph = newXdoc.insertNewParagraph(xmlCursor); @@ -1352,7 +1352,7 @@ public class TypesetController { // FileOutputStream os = new FileOutputStream(IMG_DIR+"New.doc"); // newXdoc.write(os); doc.saveToFile(IMG_DIR + randomFix + uuid+".docx"); - System.out.println("输出完毕"); + //System.out.println("输出完毕"); // os.close(); fis.close(); newFis.close(); @@ -1469,7 +1469,7 @@ public class TypesetController { } } picMap.put(imageName,lastParagraphText); -// System.out.println(pictureId +"\t|" + imageName + "\t|" + lastParagraphText); +// //System.out.println(pictureId +"\t|" + imageName + "\t|" + lastParagraphText); //获取word文本中所有的图片 // List allPictures = xdoc.getAllPictures(); //遍历照片 @@ -1485,13 +1485,13 @@ public class TypesetController { FileOutputStream fileOutputStream = new FileOutputStream(filePicture); fileOutputStream.write(data,0,data.length); fileOutputStream.close(); - System.out.println("执行结束了"); + //System.out.println("执行结束了"); // } } } } -// System.out.println("picNameList===========>"+picNameList); -// System.out.println("picMap===========>"+picMap); +// //System.out.println("picNameList===========>"+picNameList); +// //System.out.println("picMap===========>"+picMap); //2.获取按模板新生成的文档添加图片 @@ -1499,36 +1499,36 @@ public class TypesetController { Document doc = new Document(); doc.loadFromFile(newFileName); Section sec = doc.getSections().get(0); -// System.out.println("sec=================>"+sec); +// //System.out.println("sec=================>"+sec); String text = doc.getText(); -// System.out.println("text=================>"+text); +// //System.out.println("text=================>"+text); Paragraph para = sec.getParagraphs().get(0); -// System.out.println("para=================>"+para); +// //System.out.println("para=================>"+para); for(int i = 0; i < doc.getSections().getCount(); i++) { Section section = doc.getSections().get(i); for (int j = 0; j < section.getParagraphs().getCount(); j++) { Paragraph paragraph = section.getParagraphs().get(j); -// System.out.println(j+"新方式内容"+paragraph.getText()); +// //System.out.println(j+"新方式内容"+paragraph.getText()); for (String pic: picNameList) { String replace = String.valueOf(paragraph.getText()).replace(",", "").replace(" ", ""); if (replace.contains(picMap.get(pic).replace(",", "").replace(" ", ""))) { -// System.out.println("包含"); +// //System.out.println("包含"); String imgPath = IMG_DIR + randomFix +pic.replace("image", ""); File picture=new File(imgPath); BufferedImage sourceImg= ImageIO.read(new FileInputStream(picture)); int width = sourceImg.getWidth(); sourceImg.getHeight(); - System.out.println("图片长度"+width); + //System.out.println("图片长度"+width); //判断图片中是否包含 文字 // String valCode = new OCRUtil().recognizeText(new File(imgPath)); -// System.out.println("valCode==============>"+valCode); +// //System.out.println("valCode==============>"+valCode); // //正则表达式 // Pattern p = Pattern.compile("[\u4e00-\u9fa5]"); // Matcher m = p.matcher(valCode); -// System.out.println(m.find()); +// //System.out.println(m.find()); // if (m.find()){ -// System.out.println("查找到了文字"); +// //System.out.println("查找到了文字"); // //1.包含中文 单栏 // DocPicture docPicture = paragraph.appendPicture(imgPath); // docPicture.setWidth(500f); @@ -1555,9 +1555,9 @@ public class TypesetController { String wrappingstyle = docPicture.getTextWrappingStyle().toString();//图片文字环绕方式 String wrappingtype = docPicture.getTextWrappingType().toString();//环绕文字类型 - System.out.println("坐标位置为: X =" + x + " Y=" + y - + "\n 图片宽:"+ width1 + " 图片高:" + height - + "\n 图片的文字环绕方式:" + wrappingstyle + " 环绕文字类型:" + wrappingtype); + //System.out.println("坐标位置为: X =" + x + " Y=" + y +// + "\n 图片宽:"+ width1 + " 图片高:" + height +// + "\n 图片的文字环绕方式:" + wrappingstyle + " 环绕文字类型:" + wrappingtype); }else { //图片为大图 单栏 DocPicture docPicture = paragraph.appendPicture(imgPath); @@ -1578,9 +1578,9 @@ public class TypesetController { String wrappingstyle = docPicture.getTextWrappingStyle().toString();//图片文字环绕方式 String wrappingtype = docPicture.getTextWrappingType().toString();//环绕文字类型 - System.out.println("坐标位置为: X =" + x + " Y=" + y - + "\n 图片宽:"+ width1 + " 图片高:" + height - + "\n 图片的文字环绕方式:" + wrappingstyle + " 环绕文字类型:" + wrappingtype); + //System.out.println("坐标位置为: X =" + x + " Y=" + y +// + "\n 图片宽:"+ width1 + " 图片高:" + height +// + "\n 图片的文字环绕方式:" + wrappingstyle + " 环绕文字类型:" + wrappingtype); } // } @@ -1596,11 +1596,11 @@ public class TypesetController { // Section section = doc.getSections().get(0); TableCollection tables = secs.get(i).getTables(); - System.out.println(tables); + //System.out.println(tables); //获取section中第一个表格 // Table table = sec.getTables().get(0); int count = tables.getCount(); - System.out.println("===================>"+count); + //System.out.println("===================>"+count); for (int j = 0; j < tables.getCount(); j++) { //给表格应用样式 tables.get(j).applyStyle(DefaultTableStyle.Table_Classic_1); @@ -1655,12 +1655,12 @@ public class TypesetController { String uuid = UUID.randomUUID().toString().trim().replaceAll("-", ""); // for (int i=0 ; i < paragraphs.size() ; i++){ -// System.out.println("内容为"+paragraphs.get(i).getRuns()); +// //System.out.println("内容为"+paragraphs.get(i).getRuns()); // List runs = paragraphs.get(i).getRuns(); // String replace = String.valueOf(runs).replace(",", "").replace(" ",""); // for (String pic: picNameList){ // if (replace.contains(picMap.get(pic).replace(",","").replace(" ",""))){ -// System.out.println("包含执行了"); +// //System.out.println("包含执行了"); // //获取光标 // XmlCursor xmlCursor = paragraphs.get(i+1).getCTP().newCursor(); // XWPFParagraph xwpfParagraph = newXdoc.insertNewParagraph(xmlCursor); @@ -1678,7 +1678,7 @@ public class TypesetController { // FileOutputStream os = new FileOutputStream(IMG_DIR+"New.doc"); // newXdoc.write(os); doc.saveToFile(IMG_DIR + randomFix + uuid+".docx"); - System.out.println("输出完毕"); + //System.out.println("输出完毕"); // os.close(); inputStream.close(); @@ -1700,7 +1700,7 @@ public class TypesetController { //// //找到角标文字 //// while(m.find()) { // if (s.contains("")){ -//// System.out.println("角标"+m.group()); +//// //System.out.println("角标"+m.group()); //// String group = m.group(); // break; // @@ -1749,7 +1749,7 @@ public class TypesetController { ////// Pattern p = Pattern.compile("/(?<=q).*?(?=q)/"); ////// Matcher m = p.matcher(runText); ////// while(m.find()) { -////// System.out.println("角标"+m.group(1)); +////// //System.out.println("角标"+m.group(1)); ////// } //// ////