Convert contents of RAR or ZIP to different formats and compress
Leave feedback
GroupDocs.Conversion provides a flexible API to control the conversion of archives that contain other documents.
The following code snippet shows how to convert each constituent file of a RAR archive into a PDF format and then compress them to a single ZIP archive:
With v24.10 and later:
FluentConverter.Load("sample.rar")
.ConvertTo((SaveContext saveContext) => new MemoryStream()).WithOptions(new PdfConvertOptions())
.Compress(new CompressionConvertOptions { Format = CompressionFileType.Zip }).OnCompressionCompleted(
compressedStream =>
{
using (var fs = new FileStream("converted.zip", FileMode.Create))
{
compressedStream.CopyTo(fs);
}
})
.Convert();
Before v24.10:
FluentConverter.Load("sample.rar")
.ConvertTo(() => new MemoryStream()).WithOptions(new PdfConvertOptions())
.Compress(new CompressionConvertOptions { Format = CompressionFileType.Zip }).OnCompressionCompleted(
compressedStream =>
{
using (var fs = new FileStream("converted.zip", FileMode.Create))
{
compressedStream.CopyTo(fs);
}
})
.Convert();
The following code snippet shows how to convert each constituent file of a ZIP archive to a PDF format and then compress them as password-protected ZIP archive:
With v24.10 and later:
FluentConverter.Load("sample.zip")
.ConvertTo((SaveContext saveContext) => new MemoryStream()).WithOptions(new PdfConvertOptions())
.Compress(new CompressionConvertOptions
{
Format = CompressionFileType.Zip,
Password = "123"
}).OnCompressionCompleted(
compressedStream =>
{
using (var fs = new FileStream("converted.zip", FileMode.Create))
{
compressedStream.CopyTo(fs);
}
})
.Convert();
Before v24.10:
FluentConverter.Load("sample.zip")
.ConvertTo(() => new MemoryStream()).WithOptions(new PdfConvertOptions())
.Compress(new CompressionConvertOptions
{
Format = CompressionFileType.Zip,
Password = "123"
}).OnCompressionCompleted(
compressedStream =>
{
using (var fs = new FileStream("converted.zip", FileMode.Create))
{
compressedStream.CopyTo(fs);
}
})
.Convert();
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.