g2d.setGraphicContext(new GraphicContext());
g2d.setCustomTextHandler(new NativeTextHandler(g2d, null));
g2d.setupDocument(out, 200, 100);
g2d.setFont(new Font("Helvetica", Font.PLAIN, 12));
g2d.drawString("Hi there Helvetica", 50, 50);
g2d.finish();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}