本文整理汇总了Java中org.ghost4j.Ghostscript类的典型用法代码示例。如果您正苦于以下问题:Java Ghostscript类的具体用法?Java Ghostscript怎么用?Java Ghostscript使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Ghostscript类属于org.ghost4j包,在下文中一共展示了Ghostscript类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRasterizedEPS
import org.ghost4j.Ghostscript; //导入依赖的package包/类
public BufferedImage getRasterizedEPS() {
if (rasterizedEPS != null) {
return rasterizedEPS;
}
try {
File epsInputFile = File.createTempFile(getClass().getName() + ".testEPS", ".eps");
epsInputFile.deleteOnExit();
OutputStream epsInput = new FileOutputStream(epsInputFile);
epsProcessor.getDocument(vectorGraphics.getCommands(), getPageSize()).writeTo(epsInput);
epsInput.close();
File pngOutputFile = File.createTempFile(getClass().getName() + ".testEPS", "png");
pngOutputFile.deleteOnExit();
Ghostscript gs = Ghostscript.getInstance();
gs.initialize(new String[] {
"-dBATCH",
"-dQUIET",
"-dNOPAUSE",
"-dSAFER",
String.format("-g%dx%d", Math.round(getPageSize().getWidth()), Math.round(getPageSize().getHeight())),
"-dGraphicsAlphaBits=4",
"-dAlignToPixels=0",
"-dEPSCrop",
"-dPSFitPage",
"-sDEVICE=pngalpha",
"-sOutputFile=" + pngOutputFile.toString(),
epsInputFile.toString()
});
gs.exit();
rasterizedEPS = ImageIO.read(pngOutputFile);
} catch (IOException | GhostscriptException e) {
e.printStackTrace();
}
return rasterizedEPS;
}
示例2: getRasterizedPDF
import org.ghost4j.Ghostscript; //导入依赖的package包/类
public BufferedImage getRasterizedPDF() {
if (rasterizedPDF != null) {
return rasterizedPDF;
}
try {
File pdfInputFile = File.createTempFile(getClass().getName() + ".testPDF", ".pdf");
pdfInputFile.deleteOnExit();
OutputStream pdfInput = new FileOutputStream(pdfInputFile);
pdfProcessor.getDocument(vectorGraphics.getCommands(), getPageSize()).writeTo(pdfInput);
pdfInput.close();
File pngOutputFile = File.createTempFile(getClass().getName() + ".testPDF", "png");
pngOutputFile.deleteOnExit();
Ghostscript gs = Ghostscript.getInstance();
gs.initialize(new String[] {
"-dBATCH",
"-dQUIET",
"-dNOPAUSE",
"-dSAFER",
String.format("-g%dx%d", Math.round(getPageSize().getWidth()), Math.round(getPageSize().getHeight())),
"-dGraphicsAlphaBits=4",
// TODO: More robust settings for gs? DPI value is estimated.
"-r25",
"-dAlignToPixels=0",
"-dPDFFitPage",
"-sDEVICE=pngalpha",
"-sOutputFile=" + pngOutputFile.toString(),
pdfInputFile.toString()
});
gs.exit();
rasterizedPDF = ImageIO.read(pngOutputFile);
} catch (IOException | GhostscriptException e) {
e.printStackTrace();
}
return rasterizedPDF;
}