Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Compress pdf/csv files to zip files

Compress pdf/csv files to zip files

Scheduled Pinned Locked Moved C#
question
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NJdotnetdev
    wrote on last edited by
    #1

    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

    OriginalGriffO 1 Reply Last reply
    0
    • N NJdotnetdev

      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

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      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...

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      Richard DeemingR 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        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...

        Richard DeemingR Offline
        Richard DeemingR Offline
        Richard Deeming
        wrote on last edited by
        #3

        OriginalGriff wrote:

        a commercial package such as WinZIP

        Is there anything that WinZip can do that 7-Zip[^] can't? :)


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

        OriginalGriffO B 2 Replies Last reply
        0
        • Richard DeemingR Richard Deeming

          OriginalGriff wrote:

          a commercial package such as WinZIP

          Is there anything that WinZip can do that 7-Zip[^] can't? :)


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          Sit on my computer? :laugh:

          Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          1 Reply Last reply
          0
          • Richard DeemingR Richard Deeming

            OriginalGriff wrote:

            a commercial package such as WinZIP

            Is there anything that WinZip can do that 7-Zip[^] can't? :)


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            B Offline
            B Offline
            BillWoodruff
            wrote on last edited by
            #5

            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

            Richard DeemingR 1 Reply Last reply
            0
            • B BillWoodruff

              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

              Richard DeemingR Offline
              Richard DeemingR Offline
              Richard Deeming
              wrote on last edited by
              #6

              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

              "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups