在PS中导入EPS - Adob​​e Postscript工具

时间:2015-12-07 22:51:24

标签: java adobe postscript

我正在尝试在EPS中创建一个页面的一部分,然后使用Adobe Postscript工具将该部分EPS导入到我在特定位置的PS文档中:https://xmlgraphics.apache.org/commons/postscript.html

到目前为止,我已经为postscript文件提供了一个基本代,我想为它添加EPS。这是我想要做的伪版本。

    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);
    }

如果你知道如何实现这个目标,我将不胜感激。感谢。

0 个答案:

没有答案