Free Support Forum - aspose.com

PDF File Size with Images

I am evaluating Aspose.PDF and have found it easy to use. I am almost at a point to purchase Aspose.PDF, however I am having a problem with images and file sizes.

I am building a report that will be 1000’s of pages (my initial test was 3000 page report but I anticipate some reports will as large as 50,000 pages). Every page contains an image as part of a table - other data in that table may change on every page. My image size is 42K. When I build the report of 3000 pages the file size is over 5MB. When I tried a test of 50,000 pages I had to stop the process because the file size grew to over 1GB. This file size is unacceptable for our process.

Below is a snippet of the code I use to build the table with an image in one of the cells.

Is there a better way to handle images so that the file size does not grow too large? Thank you for your help.


Table table1 = new Table();
table1.ColumnWidths = “300 250 350”;
table1.DefaultCellTextInfo.LineSpacing = 2;
table1.DefaultCellTextInfo.FontName = “Arial”;

Row row1 = table1.Rows.Add();

//cell 1 - image
Cell cell1 = row1.Cells.Add();
Aspose.Pdf.Image image1 = new Aspose.Pdf.Image();
image1.ImageInfo.File = “c:/horizontal.tif”;
image1.ImageInfo.ImageFileType = ImageFileType.Tiff;
image1.ImageInfo.IsBlackWhite = true;
image1.ImageScale = .15f;
cell1.Paragraphs.Add(image1);

…finish building table

Dear gibsoju,

Thank you for considering Aspose.

Each of your image will make the pdf file size increase about 42k. So it’s not easy to reduce the file size. If all your images are the same, the better way is to add the image data to pdf only once. But Aspose.Pdf does not support this. I will consider if this function is easy to implement.

I am also evaluating the product and have an issue with importing .gif images. I generate a report that uses a collection of unique images totalling 15.4 MB. The images are really the primary portion of the content, however, when I add them to the PDF document it is over 197 MB. This is unacceptable for my requirements. I can understand a little bit larger file size, but not 10+ times as much.

One more point. I also need to scale down the image 65% from the original, because the default settings for importing a gif seems to significantly enlarge it.

Hi,

Thank you for considering Aspose.

Some types of GIF image is not supported well and the generated PDF has lerger size than it should be. Can you please send one of the GIF image and let me test it?

As for the scaling problem, you can use the ImageScale property.

Attached is a sample of the image.

I have reproduced this problem. I will try to reduce the size of the pdf file but I can’t finish it in short time. Is it possible for you to convert the image into other type such as JPEG?

No, a JPEG will be much too large. How long will this take to get rolled into a release?

I have not made plan for this issue. It is difficult to reduce the size. I think I can’t finish it in 3 months since there many other urgent task already in my schedule.
Sorry for the inconvenience.

Please refer to Image reuse in page footers? and try the attached dll.

I’ve tried using the 2.4.1.0, 2.4.2.0 (the footer image fix) and 2.5.1.0 (the latest I could find) dll’s, and I still have PDF files which are extremely oversized when they contain gif images.

A one page PDF that contains only the header image with text is around 30kb; but if I add a gif image, the PDF blows out to around 300-400kb. The gif image that I used was less than 10kb in size. I’m a little bewildered as to how the file size blows that far out!

Any ideas?

Thanks,
Christine

Dear Christine,

Thank you for considering Aspose.

Sorry for reply to you so late. This problem should have been solved in the latest hotfix. Please:
1) Make sure you are using the latest hotfix (the correct dll is referenced);
2) Try to use a image with other format, for example JPEG;
3) If it still won’t work, send the image and your code to me and let me check it.