Hi,

Am 06.09.2011 22:05, schrieb Bryan K Cantwell:
I am trying to allow for as many image types as possible to be allowed in my
form for addition to a pdf.
Right now I can do jpg and tif, but really also need png and bmp, and any other
you may know.

Here is the code I have so far that works:
PDXObjectImage yimage = null;
if (logo.toLowerCase().endsWith(".jpg")) {
yimage = new PDJpeg(doc, new FileInputStream(logo));
} else if (logo.toLowerCase().endsWith(".tif") ||
logo.toLowerCase().endsWith(".tiff")) {
yimage = new PDCcitt(doc, new RandomAccessFile(new File(logo), "r"));
} else {
throw new IOException("Image type not supported:" + logo);
}

Any help adding at least bmp and png to this 'if else'?
You should create a BufferedImage of your image using ImageIO and use that BufferedImage to create a PDJpeg using the alternative constructor.

Thanks,
Bryancan


BR
Andreas Lehmkühler

Reply via email to