This is a migrated thread and some comments may be shown as answers.

[Solved] PDF Export Size Issue

1 Answer 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael Cumming
Top achievements
Rank 1
Michael Cumming asked on 23 Jun 2014, 11:25 PM
Hi, We are using the PDF export on a grid with images which works fine apart from the pdf file size which at the moment is over 25MB. We have run the optimizer in Acrobat and it can reduce the file down to less than 1MB with it still looking fine. I think the size issue is due to the images not being optimized I have tried the filter set to Flate with little change. We use a dynamic library to re-size images on the fly but I see that the pdf generation access the original files from the file system which would be quite large especially considering that there are lots of images and we are only showing them at 50px by 50px. Is there a way to intercept the pdf generation at the point where it is accessing the image files from the file system so that we can optimize the image at that point before it inserts it?

Thanks
Michael

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 26 Jun 2014, 12:31 PM
Hello Michael,

A colleague of mine has already answered the support ticket which you have opened, but I will include his answer here as well if somebody else have the same requirement as yours.

"Using large image files will produce large PDF files. I'm afraid there is no optimization built-in. If you have a thumbnail version of the same images you could change the URL of that images just before export. These changes won't be persisted so you won't have to return them back to the original paths. Your code might look like this:

insert a global flag just after the opening tag of the partial page glass:
Copy Code
bool isExport = false;

on export button click event or on ItemCommand event in case where the built-in buttons are used:
Copy Code
isExport = true;

on PreRender or on ItemDataBound (other events are possible also)
Copy Code
//ItemDataBound
if (isExport && e.Item is GridDataItem)
{
     ...find the image and change its url
}
 
//PreRender
if (isExport)
{
   foreach(GridDataItem item in RadGrid1.MasterTableView.Items)
   {
       ...find the image and change its url
   }
}
"

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Michael Cumming
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or