pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: buffered image to pdf in pdfbox2.0
Date Mon, 27 Apr 2015 21:03:19 GMT
Am 27.04.2015 um 20:08 schrieb John Hewson:
>> On 27 Apr 2015, at 08:52, Tilman Hausherr <THausherr@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-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message