Am 27.04.2015 um 20:08 schrieb John Hewson:
On 27 Apr 2015, at 08:52, Tilman Hausherr <thaush...@t-online.de> wrote:

          PDImageXObject pdImage;
            if (imagePath.toLowerCase().endsWith(".jpg"))
            {
                pdImage = JPEGFactory.createFromStream(doc, new 
FileInputStream(imagePath));
            }
            else if (imagePath.toLowerCase().endsWith(".tif") ||
                     imagePath.toLowerCase().endsWith(".tiff"))
            {
                pdImage = CCITTFactory.createFromFile(doc, new File(imagePath));
            }
            else if (imagePath.toLowerCase().endsWith(".gif") ||
                     imagePath.toLowerCase().endsWith(".bmp") ||
                     imagePath.toLowerCase().endsWith(".png"))
            {
                BufferedImage bim = ImageIO.read(new File(imagePath));
                pdImage = LosslessFactory.createFromImage(doc, bim);
            }
            else
            {
                throw new IOException("Image type not supported: " + imagePath);
            }
Tilman, maybe we could encapsulate this code in a static factory method, e.g. 
PDImageXObject.load(File)?

Yes, that's a good idea... the only thing that irritates me is that if we replace the above code with load(), the example will no longer show how to create an XImage from a BufferedImage.

Tilman


— John


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org

Reply via email to