<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

       

      public void testWordToPDF(HttpServletResponse response) throws Exception {
              String FILE_NAME = "E:\\1111.docx";
              InputStream inputStream = new FileInputStream(FILE_NAME);
              InputStream is = DocxToPdf.docToPdf(inputStream);
              InputStream aa = PdfWaterMark.addWaterMark(is, "admin", 10);
              //將XWPFDocument文件變?yōu)镸ultipartFile
              String reportName = "企業(yè)123";
              MultipartFile multipartFile = inputStreamToCommonsMultipartFile(aa, reportName + ".pdf");
          
              String fileName = multipartFile.getOriginalFilename();
              File file = new File("E:\\"+fileName);
              OutputStream out = null;
              try{
                  //獲取文件流,以文件流的方式輸出到新文件
                  out = new FileOutputStream(file);
                  byte[] ss = multipartFile.getBytes();
                  for(int i = 0; i < ss.length; i++){
                      out.write(ss[i]);
                  }
              }catch(IOException e){
                  e.printStackTrace();
              }finally {
                  if (out != null){
                      try {
                          out.close();
                      } catch (IOException e) {
                          e.printStackTrace();
                      }
                  }
              }
          }

       

      /**
           *
           * @param is 輸入流
           * @return
           */
          public static InputStream docToPdf(InputStream is) {
              try {
                  WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(is);
                  Mapper fontMapper = new IdentityPlusMapper();
                  if(PhysicalFonts.get("SimSun") == null){
                      PhysicalFonts.addPhysicalFonts("SimSun", WordUtils.class.getResource("/simsun.ttc"));
                  }
                  fontMapper.put("隸書", PhysicalFonts.get("LiSu"));
                  fontMapper.put("宋體", PhysicalFonts.get("SimSun"));
                  fontMapper.put("微軟雅黑", PhysicalFonts.get("Microsoft Yahei"));
                  fontMapper.put("黑體", PhysicalFonts.get("SimHei"));
                  fontMapper.put("楷體", PhysicalFonts.get("KaiTi"));
                  fontMapper.put("新宋體", PhysicalFonts.get("NSimSun"));
                  fontMapper.put("仿宋", PhysicalFonts.get("FangSong"));
                  fontMapper.put("幼圓", PhysicalFonts.get("YouYuan"));
                  fontMapper.put("方正小標(biāo)宋簡體", PhysicalFonts.get("SimHei"));
                  fontMapper.put("仿宋_GB2312", PhysicalFonts.get("SimHei"));
                  wordMLPackage.setFontMapper(fontMapper);
                  FastByteArrayOutputStream os = new FastByteArrayOutputStream();
                  FOSettings foSettings = Docx4J.createFOSettings();
                  foSettings.setWmlPackage(wordMLPackage);
      
                  Docx4J.toFO(foSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);
                  return os.getInputStream();
              } catch (Exception e) {
                  log.error("word轉(zhuǎn)pdf失敗==", e);
                  throw new RuntimeException("word轉(zhuǎn)pdf失敗");
              }
          }
      /**
           * pdf生成水印
           * @param is    字節(jié)輸入流
           * @param WaterMarkContent  水印文案
           * @param numberOfPage      每頁需要插入的條數(shù)
           * @throws Exception
           */
          public static InputStream addWaterMark(InputStream is, String WaterMarkContent, int numberOfPage)throws Exception {
              PdfReader reader = new PdfReader(is);
              FastByteArrayOutputStream os = new FastByteArrayOutputStream();
      
              PdfStamper stamper = new PdfStamper(reader, os);
              PdfGState gs = new PdfGState();
      
              //設(shè)置字體
              BaseFont font =  BaseFont.createFont("STSong-Light","UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
              // 設(shè)置透明度
              gs.setFillOpacity(0.4f);
      
              int total = reader.getNumberOfPages() + 1;
              PdfContentByte content;
              for (int i = 1; i < total; i++) {
                  content = stamper.getOverContent(i);
                  content.beginText();
                  content.setGState(gs);
                  //水印顏色
                  content.setColorFill(BaseColor.LIGHT_GRAY);
                  //水印字體樣式和大小
                  content.setFontAndSize(font, 35);
                  //插入水印  循環(huán)每頁插入的條數(shù)
                  for (int j = 0; j < numberOfPage; j++) {
                      content.showTextAligned(Element.ALIGN_CENTER, WaterMarkContent, 300, 200 * (j + 1), 30);
                  }
                  content.endText();
              }
              stamper.close();
              return os.getInputStream();
          }

       

      <!--word 轉(zhuǎn) pdf -->
              <dependency>
                  <groupId>org.docx4j</groupId>
                  <artifactId>docx4j</artifactId>
                  <version>${docx4j.version}</version>
              </dependency>
              <dependency>
                  <groupId>org.docx4j</groupId>
                  <artifactId>docx4j-export-fo</artifactId>
                  <version>${export.fo.version}</version>
              </dependency>

       

       

       

      參考鏈接:
      https://blog.csdn.net/qq_26772309/article/details/127018051

      posted on 2023-04-26 17:40  茫無所知  閱讀(555)  評(píng)論(0)    收藏  舉報(bào)
      主站蜘蛛池模板: 国产SM重味一区二区三区| 济阳县| 亚洲成人av在线系列| 无人去码一码二码三码区| 久久亚洲精品情侣| 天堂国产一区二区三区| japanese无码中文字幕| 亚洲天堂一区二区成人在线| 秋霞在线观看片无码免费不卡 | 久久综合色之久久综合色| 一出一进一爽一粗一大视频| 亚洲精品国产老熟女久久| 亚洲中文字幕在线精品一区| 人人妻人人狠人人爽天天综合网| 国产农村激情免费专区| 99久久久国产精品免费无卡顿| 亚洲欧美一区二区成人片| 日本丰满的人妻hd高清在线| 中国女人熟毛茸茸A毛片| 亚洲国产午夜福利精品| a级免费视频| 日韩成人一区二区三区在线观看| 在线观看无码av五月花| 亚洲国产精品久久久天堂麻豆宅男| 狠狠亚洲超碰狼人久久| 亚洲人妻中文字幕一区| 韩国无码av片在线观看| 999精品全免费观看视频| 搡老熟女老女人一区二区| 丁香五月天综合缴情网| 曰韩无码二三区中文字幕| 日本东京热不卡一区二区| 韩国免费a级毛片久久| 成人婷婷网色偷偷亚洲男人的天堂 | 欧美人与动欧交视频| 国产成人无码aa精品一区| 亚洲一级片一区二区三区| 人妻少妇精品视频专区| 色噜噜狠狠成人综合| 东京热一精品无码av| 无套内谢极品少妇视频|