Compress pdf/csv files to zip files
-
I am using System.IO.Compression to create zip file of PDF or CSV files. I used CompressionLevel.Optimal to maximize the compression ratio. However, the percent of compression is 10-12%. Was wondering if there is another efficient way to do it? Framework: 4.5
-
I am using System.IO.Compression to create zip file of PDF or CSV files. I used CompressionLevel.Optimal to maximize the compression ratio. However, the percent of compression is 10-12%. Was wondering if there is another efficient way to do it? Framework: 4.5
Generally speaking, PDF files are already compressed, and don't compress much further - 4% is about what I expect. CSV files on the other hand are text and I'd expect them to reduce by 75% or more unless they are extremely small (when the overhead on ZIP files starts to outweigh the compression). So I'd start by using a commercial package such as WinZIP to compress your files for testing and compare those results with the ratios you are getting with your app. Getting the same kind of compression for two file formats that are so different internally is suspicious to my mind.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
Generally speaking, PDF files are already compressed, and don't compress much further - 4% is about what I expect. CSV files on the other hand are text and I'd expect them to reduce by 75% or more unless they are extremely small (when the overhead on ZIP files starts to outweigh the compression). So I'd start by using a commercial package such as WinZIP to compress your files for testing and compare those results with the ratios you are getting with your app. Getting the same kind of compression for two file formats that are so different internally is suspicious to my mind.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
Sit on my computer? :laugh:
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
Using 7zip is going to require a C# wrapper, like SevenZipSharp: [^]. However, since .NET now provides GZip, I use that, and it's quite powerful.
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
-
Using 7zip is going to require a C# wrapper, like SevenZipSharp: [^]. However, since .NET now provides GZip, I use that, and it's quite powerful.
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
If you're using it from code, yes. But OG's suggestion was to use WinZip to manually compress the files, to see how much compression could reasonably be expected. I was just pointing out that you don't need to pay for a tool to do that. :)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer