GhostscriptExample GS
发布时间:2024年01月06日
1.导出图片
package cn.net.haotuo.pojo;
import java.io.*;
public class GhostscriptExample {
public static void main(String[] args) {
String gsPath = "C:/Program Files/gs/gs9.54.0/bin/gswin64c.exe";
String inputFilePath = "C:\\Users\\Administrator\\Desktop\\1050g白卡双面哑膜(5张)《507x457》《4种》.pdf";
String outputFilePath = "C:\\Users\\Administrator\\Desktop\\1050g白卡双面哑膜(5张)《507x457》《4种》.png";
String command = gsPath + " -dNOPAUSE -dBATCH -sDEVICE=png16m -r300 -sOutputFile=" + outputFilePath + " -f" + inputFilePath;
run(command);
}
public static void run(String command){
System.out.println(command);
try {
Process process = Runtime.getRuntime().exec(command);
int exitCode = process.waitFor();
if (exitCode == 0) {
System.out.println("Conversion successful!");
} else {
System.out.println("Conversion failed with error code: " + exitCode);
InputStream errorStream = process.getErrorStream();
BufferedReader errorReader = new BufferedReader(new InputStreamReader(errorStream));
String line;
while ((line = errorReader.readLine()) != null) {
System.out.println(line);
}
}
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
}
文章来源:https://blog.csdn.net/jialan75/article/details/135431127
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:chenni525@qq.com进行投诉反馈,一经查实,立即删除!