insert an image in a pdf file
807607Oct 9 2006 — edited Oct 10 2006Hi.
I made a servlet dat makes an image for a database diagram and
now I want to import this picture (image/gif) into a pdf document
so that it's possible to print the result
Can someone help me because I already searched in the class
Graphics2D ( I used this class also for my servlet result) but I
have to rewrite my whole code to use this in the pdf. So, I search
a way to import the micture I made into a pdf document
I just give the code in the servlet where I make the
image so you know how I'm working. The servlet workes perfect
and it shows me a beautiful image on te screen.
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException,
IOException {
intVariables();
response.setContentType("image/jpeg");
OutputStream out =
response.getOutputStream();
// get the session
HttpSession session = request.getSession();
// Create image
Image image = new BufferedImage
(imageWidth, imageHeight,
BufferedImage.TYPE_INT_ARGB);
// Get Graphics context of the image
Graphics g = image.getGraphics();
Graphics2D g2 = (Graphics2D) g;
drawTable(g2, session); // Draw a table on
graphics
// Encode the image and send to the output
stream
new GifEncoder(image, out, true).encode();
session.setAttribute("diagram",image);
out.close(); // Close stream
}
I hope someone can help me