当前位置:   article > 正文

OFD转图片_java_ofd2img ofd2img = new ofd2img();

ofd2img ofd2img = new ofd2img();

直接上代码:

需要jar 包

1、converter-1.0-SNAPSHOT.jar

2、core-1.0-SNAPSHOT.jar

3、signature-1.0-SNAPSHOT.jar

  1. package com.sino.utils.ofd2img;
  2. import java.awt.image.BufferedImage;
  3. import java.io.File;
  4. import java.io.FileOutputStream;
  5. import java.io.IOException;
  6. import javax.imageio.ImageIO;
  7. import org.dom4j.DocumentException;
  8. import com.ofdbox.convertor.img.Ofd2Img;
  9. import com.ofdbox.core.OFDReader;
  10. import com.ofdbox.core.model.OFD;
  11. /**
  12. * 测试用例
  13. */
  14. public class OFDUtilTest {
  15. public static void main(String[] args) throws IOException, DocumentException {
  16. String imgpath = "C:\\ofd票\\011002000511_05690633.ofd";
  17. String ofd2imgPath = "C:\\ofd票\\011002000511_05690633.jpg";
  18. ofd2Img(imgpath, ofd2imgPath);
  19. }
  20. public static String ofd2Img(String path, String ofd2imgPath) {
  21. OFDReader reader = new OFDReader();
  22. reader.getConfig().setValid(false);
  23. try {
  24. OFD ofd1 = reader.read(new File(path));
  25. Ofd2Img ofd2Img = new Ofd2Img();
  26. ofd2Img.getConfig().setDrawBoundary(false);
  27. BufferedImage image1 = ofd2Img.toImage(ofd1.getDocuments().get(0).getPages().get(0), 15);
  28. ImageIO.write(image1, "png", new FileOutputStream(new File(ofd2imgPath)));
  29. } catch (IOException e) {
  30. e.printStackTrace();
  31. System.out.println("ofd -> img 失败");
  32. }
  33. return ofd2imgPath;
  34. }
  35. }

下载jar包地址:ofd2img.zip_pythonofd转pdf-互联网文档类资源-CSDN下载

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/781804
推荐阅读
相关标签
  

闽ICP备14008679号