简体   繁体   English

将使用applet和图形绘制的图导出为pdf

[英]Export a diagram drawn using applet and graphics as pdf

My requirement is to draw a graph using a co-ordinate system which I am currently doing using java applets and AWT graphics package. 我的要求是使用当前使用Java小程序和AWT图形包进行的坐标系绘制图形。 I need to export the diagram drawn as a pdf file? 我需要将绘制的图导出为pdf文件吗? Is there anyway to do it using the graphics package itself or is there any other way out. 无论如何,还是可以使用图形包本身来做,还是有其他方法可以解决。 I am using the following code to create the diagram 我正在使用以下代码创建图表

public class Draw extends Applet{

        public void paint(Graphics g){
               g.drawRect(10,10,50,100);
               g.drawRect(100,100,50,50);
        }
}

Can the output of this code be saved as a pdf? 此代码的输出可以另存为pdf吗? Additionally can the scale for Graphics2D be set to mm instead of pixels? 另外,是否可以将Graphics2D的比例尺设置为mm而不是像素? I am not sure if manual conversion is good enough, because extreme precision would be necessary. 我不确定手动转换是否足够好,因为将需要极高的精度。 Thanks in advance. 提前致谢。

您应该能够使用iText com.itextpdf.awt.PdfGraphics2D,本示例中“ iText in Action”的第14章中所述。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM