spire(文件转换) 上传服务器 转换出现乱码

spire官网:https://www.e-iceblue.cn/Introduce/Spire-PDF-NET.html

出现乱码的原因https://blog.csdn.net/hou110yuan/article/details/89531792

部分代码

                   File copyFile = new File(multipartFile.getOriginalFilename());
                   //生成根目录文件
                    FileUtils.copyInputStreamToFile(multipartFile.getInputStream(), copyFile);   
                    String path = System.getProperty("user.dir") + "/" + multipartFile.getOriginalFilename();
                    File pngFile = new File(path);
                    //创建Document对象
                    Document doc = new Document();

                    //加载Word文档
                    doc.loadFromFile(pngFile.getPath());

                    //将指定页保存为BufferedImage
                    BufferedImage image = doc.saveToImages(0, ImageType.Bitmap);

                    //将图片数据保存为PNG格式文档 将图片写入根目录
                    File writePng = new File(System.getProperty("user.dir") + "/" + multipartFile.getOriginalFilename() + ".png");
                    ImageIO.write(image, "PNG", writePng);

                    InputStream inputStream = new FileInputStream(writePng);

                    //上传png (oss)
                    MultipartFile pngMul = new MockMultipartFile(writePng.getName(), writePng.getName(), "utf-8", inputStream);
                    String png = (String) this.toUploadBlogPost(pngMul, 2).getData();

                    //上传word
                    String word = (String) this.toUploadBlogPost(multipartFile, 1).getData();

                   // 会在本地产生临时文件,用完后需要删除
                    if (copyFile.exists()) {
                        copyFile.delete();
                    }
                    if (writePng.exists()) {
                        writePng.delete();
                    }

你可能感兴趣的:(spire(文件转换) 上传服务器 转换出现乱码)