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

GZipStream problem

Scheduled Pinned Locked Moved C#
helpquestion
6 Posts 3 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.
  • Z Offline
    Z Offline
    zeeShan anSari
    wrote on last edited by
    #1

    hi all, for compress the pdf file i use below code:

    byte[] bufferWrite;

            FileStream fsSource;
    
            FileStream fsDest;
            GZipStream gzCompressed;
            fsSource = new FileStream(@"C:\\Invoice.pdf", FileMode.Open, FileAccess.Read, FileShare.Read);
    
            bufferWrite = new byte\[fsSource.Length\];
    
            fsSource.Read(bufferWrite, 0, bufferWrite.Length);
    
            fsDest = new FileStream(@"C:\\Invoice.zip", FileMode.OpenOrCreate, FileAccess.Write);
    
            gzCompressed = new GZipStream(fsDest, CompressionMode.Compress, true);
    
            gzCompressed.Write(bufferWrite, 0, bufferWrite.Length);
    
            fsSource.Close();
            gzCompressed.Close();
            fsDest.Close();
    

    pdf file compress successfully but without extension(.pdf) .......where is problem?

    L 1 Reply Last reply
    0
    • Z zeeShan anSari

      hi all, for compress the pdf file i use below code:

      byte[] bufferWrite;

              FileStream fsSource;
      
              FileStream fsDest;
              GZipStream gzCompressed;
              fsSource = new FileStream(@"C:\\Invoice.pdf", FileMode.Open, FileAccess.Read, FileShare.Read);
      
              bufferWrite = new byte\[fsSource.Length\];
      
              fsSource.Read(bufferWrite, 0, bufferWrite.Length);
      
              fsDest = new FileStream(@"C:\\Invoice.zip", FileMode.OpenOrCreate, FileAccess.Write);
      
              gzCompressed = new GZipStream(fsDest, CompressionMode.Compress, true);
      
              gzCompressed.Write(bufferWrite, 0, bufferWrite.Length);
      
              fsSource.Close();
              gzCompressed.Close();
              fsDest.Close();
      

      pdf file compress successfully but without extension(.pdf) .......where is problem?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      zeeShan anSari wrote:

      pdf file compress successfully but without extension(.pdf) .......where is problem?

      You named it .zip, just stop naming it .zip ? On the other hand, renaming a gzip file to .pdf doesn't (to my knowledge) suddenly make it a pdf file, it just makes your computer think it is.

      Z L 2 Replies Last reply
      0
      • L Lost User

        zeeShan anSari wrote:

        pdf file compress successfully but without extension(.pdf) .......where is problem?

        You named it .zip, just stop naming it .zip ? On the other hand, renaming a gzip file to .pdf doesn't (to my knowledge) suddenly make it a pdf file, it just makes your computer think it is.

        Z Offline
        Z Offline
        zeeShan anSari
        wrote on last edited by
        #3

        Thanks.........u r right :cool:

        1 Reply Last reply
        0
        • L Lost User

          zeeShan anSari wrote:

          pdf file compress successfully but without extension(.pdf) .......where is problem?

          You named it .zip, just stop naming it .zip ? On the other hand, renaming a gzip file to .pdf doesn't (to my knowledge) suddenly make it a pdf file, it just makes your computer think it is.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          harold aptroot wrote:

          (to my knowledge)

          Are you not sure about it ?

          L 1 Reply Last reply
          0
          • L Lost User

            harold aptroot wrote:

            (to my knowledge)

            Are you not sure about it ?

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            No, are you? Some PDF readers may (in theory at least) decide to detect it and decompress the file before loading I wouldn't claim anything with full certainty without testing, and I'm not about to test every known PDF reader with gzipped pdf's

            S 1 Reply Last reply
            0
            • L Lost User

              No, are you? Some PDF readers may (in theory at least) decide to detect it and decompress the file before loading I wouldn't claim anything with full certainty without testing, and I'm not about to test every known PDF reader with gzipped pdf's

              S Offline
              S Offline
              Saksida Bojan
              wrote on last edited by
              #6

              Today I have read CutePDF features, and it seems PDF supports commpresion. But it does not uses any zip, rar or any other container based compresion

              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