当前位置: 首页>>代码示例>>Java>>正文


Java Ghostscript类代码示例

本文整理汇总了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;
}
 
开发者ID:eseifert,项目名称:vectorgraphics2d,代码行数:36,代码来源:TestCase.java

示例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;
}
 
开发者ID:eseifert,项目名称:vectorgraphics2d,代码行数:38,代码来源:TestCase.java


注:本文中的org.ghost4j.Ghostscript类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。