1 Replies - 3090 Views - Last Post: 02 July 2013 - 06:54 AM Rate Topic: -----

#1 November-06  Icon User is offline

  • D.I.C Regular

Reputation: 53
  • View blog
  • Posts: 482
  • Joined: 04-January 11

Compressing PDF

Posted 02 July 2013 - 03:41 AM

Has anyone used System.IO.Packaging.Package before?

I am generating multiple PDFs which will be placed in a zipped folder and made available to the user for download.

I followed the code from http://www.codeproje.../Zip-Files-Easy to create the zipped folder.

The problem is, the compressed folder is larger in size compared to the total size of all the PDFs contained in the folder. If my PDFs have a total of 70MB, my compressed folder has a size of 111MB.

I read the other developer's comments and they said that the following lines are concerned:

//Read all of the bytes from the file to add to the zip file 
byte[] fileByte = File.ReadAllBytes(filename);
//Compress and write the bytes to the zip file 
pckgPart.GetStream().Write(fileByte, 0, fileByte.Length);

They say this only works for Text files. But PDFs become larger using this.

I would like to ask for your help regarding what to replace these lines with to compress the PDF to a smaller size?

This post has been edited by November-06: 02 July 2013 - 03:42 AM

Is This A Good Question/Topic? 0
  • +

Replies To: Compressing PDF

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon

Reputation: 13965
  • View blog
  • Posts: 55,749
  • Joined: 12-June 08

Re: Compressing PDF

Posted 02 July 2013 - 06:54 AM

I wouldn't figure the packaging namespace is where you would go for compression. I've used the gzip/zip in System.IO.Compression with great success.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1