| | |
| | | import com.ruoyi.common.enums.PhotoEnum; |
| | | import com.ruoyi.common.enums.RadioEnum; |
| | | import com.ruoyi.common.enums.VadioEnum; |
| | | import com.smartor.domain.HtmlContentVO; |
| | | import org.apache.poi.hwpf.HWPFDocument; |
| | | import org.apache.poi.hwpf.converter.PicturesManager; |
| | | import org.apache.poi.hwpf.converter.WordToHtmlConverter; |
| | |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.constant.Constants; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @param HtmlContentVO |
| | | * @return |
| | | */ |
| | | @GetMapping("/common/htmlContent") |
| | | public AjaxResult htmlContent(@RequestBody HtmlContentVO htmlContentVO) { |
| | | // 获取文件的原始名称 |
| | | String fileName = htmlContentVO.getFileName(); |
| | | // 将文件保存到指定目录 |
| | | File outputFile = new File(RuoYiConfig.getUploadPath() + "/show/" + fileName.split("\\.", 2)[0] + fileName); |
| | | try (BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile))) { |
| | | writer.write(htmlContentVO.getContent()); |
| | | |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | public static void convertDocToHtml(String docFilePath, String outputHtmlFilePath) throws TransformerException, IOException, ParserConfigurationException { |
| | | |
| | | InputStream inputStream = new FileInputStream(docFilePath); |
| | |
| | | } catch (Exception e) { |
| | | e.getMessage(); |
| | | } |
| | | |
| | | |
| | | TransformerFactory tf = TransformerFactory.newInstance(); |
| | | Transformer transformer = tf.newTransformer(); |
| | | transformer.setOutputProperty(OutputKeys.INDENT, "yes"); |
| | |
| | | StreamResult streamResult = new StreamResult(new File(outputHtmlFilePath)); |
| | | transformer.transform(domSource, streamResult); |
| | | |
| | | System.out.println("Conversion completed successfully."); |
| | | System.out.println("word转html成功"); |
| | | |
| | | } |
| | | |