栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

OFD转图片

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

OFD转图片

直接上代码:

需要jar 包

1、converter-1.0-SNAPSHOT.jar

2、core-1.0-SNAPSHOT.jar

3、signature-1.0-SNAPSHOT.jar

package com.sino.utils.ofd2img;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import javax.imageio.ImageIO;

import org.dom4j.documentException;

import com.ofdbox.convertor.img.Ofd2Img;
import com.ofdbox.core.OFDReader;
import com.ofdbox.core.model.OFD;


public class OFDUtilTest {

	public static void main(String[] args) throws IOException, documentException {
		String imgpath = "C:\ofd票\011002000511_05690633.ofd";
		String ofd2imgPath = "C:\ofd票\011002000511_05690633.jpg";
		ofd2Img(imgpath, ofd2imgPath);

	}

	public static String ofd2Img(String path, String ofd2imgPath) {
		OFDReader reader = new OFDReader();
		reader.getConfig().setValid(false);
		try {
			OFD ofd1 = reader.read(new File(path));
			Ofd2Img ofd2Img = new Ofd2Img();
			ofd2Img.getConfig().setDrawBoundary(false);

			BufferedImage image1 = ofd2Img.toImage(ofd1.getdocuments().get(0).getPages().get(0), 15);
			ImageIO.write(image1, "png", new FileOutputStream(new File(ofd2imgPath)));
		} catch (IOException e) {
			e.printStackTrace();
			System.out.println("ofd -> img 失败");
		}

		return ofd2imgPath;
	}
}

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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/582803.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号