Compress file in zlib format using c# .NET | inflate deflate files | Aspose Zip Gzip Archive | PowerBuilder

Can the Aspose.Zip product compress a file in zlib format? We have older applications that use zlib to deflate files. Aspose.Zip.GzipArchive can decompress these files. However, the zlib library can not inflate files that have been compressed by Aspose.Zip.GzipArchive.

@jeffgeis,

Please ZIP and attach a sample zlib format file here for our reference. We will investigate the intended file format on our end and provide you more information.

To ensure a timely and accurate response, please ZIP and attach the following resources here for testing:

  • Sample file(s) that your application can successfully deflate using zlib
  • Sample file(s) that Aspose.ZIP for .NET can decompress successfully
  • Sample file(s) compressed by latest (20.5) version of Aspose.ZIP for .NET (using Aspose.Zip.GzipArchive) that zlib library is unable to inflate on your end.
  • Please also create a standalone simple Console application (source code without compilation errors) that helps us to reproduce your current problem(s) on our end and attach it here for testing. Please do not include Aspose.ZIP DLL files in it to reduce the file size.

As soon as you get these pieces of information ready, we will start investigation into your scenario and provide you more information. Thanks for your cooperation.

ConsoleApp1.zip (914.7 KB)

The file csharp_cheat_sheet.pdf is the original PDF
The file zlib_deflated_file.zlib is csharp_cheat_sheet.pdf deflated with the zlib library from zlib.net

If you compress csharp_cheat_sheet.pdf with GzipArchive the result is not the same as zlib_deflated_file.zlib. The zlib library can not process the file compressed by GzipArchive.

@jeffgeis,

Thanks for the additional information.

Please also provide the C# source code of zlib.net library that is failing upon processing Aspose.ZIP for .NET generated compressed file.

Also, please provide source code that you used to generate “zlib_deflated_file.zlib” file on your end.

Thanks for your cooperation.

The zlib.net dll is not ours. It can be found at the ZLib Home Site at http://zlib.net. The source code that can not process the data compressed by Aspose is written in Powerbuilder.

Defines the external function call to uncompress in the zlib.dll:

Function integer uncompress ( &
Ref blob dest, &
Ref ulong destLen, &
Ref blob src, &
ulong srcLen &
) Library “zlib.dll” alias for “uncompress;Ansi”

Function that calls the uncompress method in zlib.dll:

public function boolean of_uncompress (blob ablob_src, unsignedlong aul_destlen, ref blob ablob_dest);

Integer li_rc
ULong lul_srclen
Blob lblob_dest

try
	SetNull(lblob_dest)	// Set to null first

	lblob_dest = Blob(Space(aul_destlen), EncodingAnsi!)
	lul_srclen = Len(ablob_src)
		
	// uncompress the blob
	li_rc = uncompress(lblob_dest, aul_destlen, ablob_src, lul_srclen)
	
	Return True
	
catch(runtimeerror err_runtime)	
	Return False
end try

end function

The source code that compressed “zlib_deflated_file.zlib” is written in Powerbuilder.

Defines the external function call to compress in the zlib.dll:

Function integer compress ( &
Ref blob dest, &
Ref ulong destLen, &
Ref blob src, &
ulong srcLen &
) Library “zlib.dll” alias for “compress;Ansi”

Function that calls the compress method in zlib.dll:

public function boolean of_compress (blob ablob_source, ref blob ablob_dest);
Integer li_rc
ULong lul_srclen, lul_destlen
Blob lblob_dest

// allocate buffer space
lul_srclen  = Len(ablob_source)
lul_destlen = (lul_srclen * 1.01) + 12  // zlib needs a little extra room
lblob_dest = Blob(Space(lul_destlen), EncodingAnsi!)

// compress the blob
li_rc = compress(lblob_dest, lul_destlen, ablob_source, lul_srclen)

Return True

end function

@jeffgeis,

Thanks for the additional information. We have logged this problem in our issue tracking system. Your ticket number is ZIPNET-511. We will further look into the details of this problem and will keep you updated on the status of the linked issue. Sorry for any inconvenience.

I was wondering if I could get an update on this issue. Thank You.

@jeffgeis,

Unfortunately, your issue is not resolved yet. We are actively working on ZIPNET-511 (and ZIPNET-516) but unfortunately cannot promise any ETA (time frame) at the moment. Rest assured, we will inform you via this thread as soon as ZIPNET-511 will get resolved in future or any updates may be available. We apologize for your inconvenience.

@jeffgeis,

Regarding ZIPNET-511, please note that ‘Aspose.ZIP for .NET’ will not be able to compress in zlib format because technically it is not actually an archive file format. Even 7-Zip software does not support it (see Decompression for zlib stream without zlib header).

We suggest you to please use .NET wrapper over native zlib for compression (a popular one is zlib.net)

We have also carried out some experiments on your deflated file and composed a simple tool that we believe will produce the results you need. Please use provided ZlibCompressor class from attachment to generate zlib-deflated files that can be extracted with zlib/PowerBuilder.