Jump to content
We've recently updated our Privacy Statement, available here ×

Images and PDF size.


Recommended Posts

By: micheleapicella - micheleapicella

Images and PDF size.

2005-04-04 08:12

I have a report with an image (loaded from a database field) in the Page Header section.

I create the PDF of this report.

The size of this pdf has a linear grow, so i deduced that the image is phisically repeated in every page.

I.e., if the image is 100k, if the report have 10 pages, the pdf size is 1000k.

There is some way to avoid this growth?

Thank you.

 

 

 

By: macoute - macoute

RE: Images and PDF size.

2005-04-19 03:34

I'm not sure to understand your problem ;-)

You have 10 pages with an image on each page, the result is correct 100Ko * 10pages = 1Mo,

To my mind, you have no possibility to tell to the pdf that the same image is on every pages.

And that image is only once in the pdf file.

A pdf file is a result file.

 

 

By: macoute - macoute

RE: Images and PDF size.

2005-04-19 03:36

Perhaps in the pdf format, but in JasperReports no possiblity have have reference.

 

 

By: Pepe P rez - pepeperez

RE: Images and PDF size.

2005-04-19 04:07

 Ah!, in the .jasper file.

 

I am no expert in the PDF format but it seems it is possible. From:

 

http://www.amyuni.com/en/products/pdf_converter/features.html

 

Documents containing images can be compressed using a variety of image compression techniques such as JPEG, CCITT Fax, grayscale, downsampling, *removal of duplicate images*,  

 

Thanks,

 

Pepe.

 

 

 

By: micheleapicella - micheleapicella

RE: Images and PDF size.

2005-04-22 06:16

>Perhaps in the pdf format, but in JasperReports no >possiblity have have reference.

 

I also generate PDFs with FOP and i don't have this problem, so... it's possible

In the "real world" the size of generated PDF is a crucial issue.

 

 

 

By: Pepe P rez - pepeperez

RE: Images and PDF size.

2005-04-19 03:23

Any answer to this?.

 

Thank you.

 

 

 

By: Petr Mich lek - pmichalek

RE: Images and PDF size.

2005-07-30 07:38

Hi, try this patch. It caches java.awt.images and reduces pdf size!

 

Petr Michalek

 

Index: JRFillImage.java

===================================================================

RCS file: /cvsroot/jasperreports/jasperreports/src/net/sf/jasperreports/engine/fill/JRFillImage.java,v

retrieving revision 1.20

diff -u -r1.20 JRFillImage.java

--- JRFillImage.java 20 Jul 2005 16:12:52 -0000 1.20

+++ JRFillImage.java 30 Jul 2005 14:33:21 -0000

@@ -357,8 +357,25 @@

 

if (Image.class.getName().equals(expressionClass.getName()))

{

- Image img = (Image)source;

- newRenderer = JRImageRenderer.getInstance(img, getOnErrorType());

+ if (this.isUsingCache())

+ {

+ if ( this.filler.loadedImages.containsKey(source) )

+ {

+ newRenderer = ((JRPrintImage)this.filler.loadedImages.get(source)).getRenderer();

+ }

+ else

+ {

+ newRenderer = JRImageRenderer.getInstance((Image)source, getOnErrorType());

+ JRPrintImage img = new JRTemplatePrintImage(this.getJRTemplateImage());

+ img.setRenderer(newRenderer);

+ this.filler.loadedImages.put(source, img);

+ }

+ }

+ else

+ {

+ Image img = (Image)source;

+ newRenderer = JRImageRenderer.getInstance(img, getOnErrorType());

+ }

}

else if (InputStream.class.getName().equals(expressionClass.getName()))

{

 

 

 

By: keodark - keodark

RE: Images and PDF size.

2005-08-18 13:53

Petr -

 

I just tried this patch (only I applied it manually as I'm not using CVS), it compiles without error... however, when I run jasper on my report, the pdf is still enormous (5 mb with same image once per page, 330 k without image)...

 

Does your solution work if the image is actually a ImageIcon in a parameter, being cast to a java.awt.Image when used as the source for a report's image object?

 

Is there anything I can change in your code to figure out why it's not working in my case?

 

Thanks!

-Nathan

 

 

By: keodark - keodark

RE: Images and PDF size.

2005-08-18 15:35

Nevermind. I figured it out.. this patch does work quite well, thanks!

 

(I wasn't putting the jasper jar in the right place after building.. doh)

 

 

By: Christiaan - christiaan_se

RE: Images and PDF size.

2006-07-11 07:55

Hi there,

I am experiencing similar problems. I have an image in the footer. Some of our reports can become very large (several thousands of pages). When exporting it to pdf the file becomes several hundreds of mb's instead of several mb's without the image in the footer. Can the mentioned fix fix be applied to the JR library?

 

kind regards,

Christiaan

 

 

By: Teodor Danciu - teodord

RE: Images and PDF size.

2006-07-11 08:02

 

Hi,

 

Have you guys set isUsingCache="true" for your

image elements?

If so, the engine would reuse the same image

reference and resulting files would be minimal.

No need for additional patches.

 

Thank you,

Teodor

 

 

 

By: Christiaan - christiaan_se

RE: Images and PDF size.

2006-07-12 01:56

The isUsingCache="true" option indeed solves this problem! I can now print a pdf document of 5700 pages (18mb) with no OutOfMemory exception instead of 2600 pages (200 mb) resulting in OutOfMemory.

 

Thanks for the reply,

Christiaan

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...