We are not really talking about the same thing. You are not getting an
URL and loading that same image using iText directly and through the
java awt toolkit. What you are doing is generating an awt image and
using that image as a reference. Then you save that image to jpeg, with
some unknown compression, and load it again. You choose the worst format
to save charts. If you had saved the image as gif or png the size would
be similar, if compression was applied.

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Rochana Attale
> Sent: Friday, February 11, 2005 4:45 AM
> To: [email protected]
> Subject: [iText-questions] Why are the results of" 
> Image.getInstance(URL uRL)" and "Image.getInstance(Image 
> image, Color color)" different ?
> 
> The simplified code:
> 
> ==============
> 
>  
> 
> public static synchronized ByteArrayOutputStream 
> getRatioListPDF(File file,
> 
>       Object graph) throws
> 
>       DocumentException, FileNotFoundException, IOException
> 
>  
> 
>   {
> 
>     Document doc = new Document(PageSize.A4, 70, 70, 70, 70);
> 
>     ByteArrayOutputStream bos = new ByteArrayOutputStream();
> 
>     PdfWriter docWriter = PdfWriter.getInstance(doc, bos);
> 
>     doc.open();
> 
>  
> 
> //********************* Code that adds images using URLs 
> **********************/
> 
>     // URL url = (URL) graph;
> 
>     // Image img = Image.getInstance(url);
> 
> //************************************************************
> *************************/
> 
>  
> 
> //*********************** Code that adds a java.awt.Image 
> ***********************/ 
> 
>     Image img = Image.getInstance( (java.awt.Image) graphs, null);
> 
> //************************************************************
> *************************/
> 
>  
> 
>     img.scalePercent(75, 75);
> 
>     img.setAlignment(Image.MIDDLE);
> 
>     doc.add(img);
> 
>     doc.close();
> 
>     FileOutputStream fos = new FileOutputStream(file);
> 
>     fos.write(bos.toByteArray());
> 
>     fos.close();
> 
>     return bos;
> 
>   }
> 
>  
> 
>  
> 
> Test results:
> 
> =========
> 
>  
> 
> * Code that adds images using URLs:
> 
>  
> 
>   Time taken: 251 milliseconds
> 
>   Image size: 24KB
> 
>  
> 
> * Code that adds a java.awt.Image :
> 
>  
> 
>   Time taken: 282 milliseconds
> 
>   Image size: 3KB
> 
>  
> 
> PLEASE FIND ATTACHED THE RESULTING PDF DOCUMENTS.
> 
>  
> 
>  
> 
>  
> 
>  
> 
> 


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to