Java 在PS-Tools for Adobe Postscript中导入EPS
我正在尝试在EPS中创建页面的一部分,然后使用Tools for Adobe Postscript将该部分EPS导入到我的PS文档中的特定位置: 到目前为止,我已经为postscript文件生成了一个基本版本,我想向其中添加EPS。这是我想做的一个伪版本Java 在PS-Tools for Adobe Postscript中导入EPS,java,adobe,postscript,Java,Adobe,Postscript,我正在尝试在EPS中创建页面的一部分,然后使用Tools for Adobe Postscript将该部分EPS导入到我的PS文档中的特定位置: 到目前为止,我已经为postscript文件生成了一个基本版本,我想向其中添加EPS。这是我想做的一个伪版本 OutputStream out = new java.io.FileOutputStream(outputFile); out = new java.io.BufferedOutputStream(out); tr
OutputStream out = new java.io.FileOutputStream(outputFile);
out = new java.io.BufferedOutputStream(out);
try {
//Instantiate the PSDocumentGraphics2D instance
PSDocumentGraphics2D g2d = new PSDocumentGraphics2D(false);
g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
EPSDocumentGraphics2D eg2d = new EPSDocumentGraphics2D(false);
eg2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
//Set up the document size
g2d.setupDocument(out, pageWidthPT, pageHeightPT);
eg2d.setupDocument(out, 400, 200); //400pt x 200pt
g2d.setFont(new Font(font, Font.PLAIN, fontSize));
//Paint a bounding box
eg2d.drawRect(0, 0, 400, 200);
//A few rectangles rotated and with different color
Graphics2D copy = (Graphics2D)eg2d.create();
int c = 12;
for (int i = 0; i < c; i++) {
float f = ((i + 1) / (float)c);
Color col = new Color(0.0f, 1 - f, 0.0f);
copy.setColor(col);
copy.fillRect(70, 90, 50, 50);
copy.rotate(-2 * Math.PI / (double)c, 70, 90);
}
copy.dispose();
//Some text
eg2d.rotate(-0.25);
eg2d.setColor(Color.RED);
eg2d.setFont(new Font("sans-serif", Font.PLAIN, 36));
eg2d.drawString("Hello world!", 140, 140);
eg2d.setColor(Color.RED.darker());
//Cleanup
eg2d.finish();
g2d.insertEPS(eg2d, 0,0); // something like this?
g2d.nextPage();
g2d.drawString("Hello World!", 10, 20);
g2d.finish();//Cleanup
} finally {
IOUtils.closeQuietly(out);
}
OutputStream out=newjava.io.FileOutputStream(outputFile);
out=新java.io.BufferedOutputStream(out);
试一试{
//实例化PSDocumentGraphics2D实例
PSDocumentGraphics2D g2d=新PSDocumentGraphics2D(假);
setGraphicContext(新org.apache.xmlgraphics.java2d.GraphicContext());
EPSDocumentGraphics2D eg2d=新的EPSDocumentGraphics2D(假);
setGraphicContext(新org.apache.xmlgraphics.java2d.GraphicContext());
//设置文档大小
g2d.setupDocument(out、pageWidthPT、pageHeightPT);
setupDocument(out,400200);//400pt x 200pt
g2d.setFont(新字体(Font,Font.PLAIN,fontSize));
//绘制边界框
eg2d.drawRect(0,0,400,200);
//几个旋转的矩形,颜色不同
Graphics2D copy=(Graphics2D)eg2d.create();
int c=12;
对于(int i=0;i
如果你知道如何实现这个目标,我会很感激你的启发。谢谢