Load compression document with options
Leave feedback
On this page
GroupDocs.Conversion provides CompressionLoadOptions to control how source compression files are processed. Compression files include formats like ZIP, 7Z, RAR, TAR, GZIP, and other archive formats.
The following options are available:
| Option | Description |
|---|---|
| Format | The document type is auto-detected during loading, but you can explicitly specify the source format. Available options include: SevenZ, Bz2, Cab, Cpio, Gz, Gzip, Lz, Lzma, Rar, Tar, Xz, Z, Zip |
| Password | Set password to load protected archive |
| ConvertOwned | The owned documents will be converted (read-only, set to true by default) |
| ConvertOwner | The owner will not be converted (read-only, set to false by default) |
| Depth | Controls recursion depth for nested documents. Default value is 3. |
The following code snippet shows how to load a ZIP archive with explicit format specification:
With v24.10 and later:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadContext, LoadOptions> getLoadOptions = loadContext => new CompressionLoadOptions
{
Format = CompressionFileType.Zip
};
using (Converter converter = new Converter("documents-archive.zip", getLoadOptions))
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert("documents-archive.pdf", options);
}
Before v24.10:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadOptions> getLoadOptions = () => new CompressionLoadOptions
{
Format = CompressionFileType.Zip
};
using (Converter converter = new Converter("documents-archive.zip", getLoadOptions))
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert("documents-archive.pdf", options);
}
The following code snippet shows how to load a RAR archive:
With v24.10 and later:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadContext, LoadOptions> getLoadOptions = loadContext => new CompressionLoadOptions
{
Format = CompressionFileType.Rar
};
using (Converter converter = new Converter("backup-files.rar", getLoadOptions))
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert("backup-files.pdf", options);
}
Before v24.10:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadOptions> getLoadOptions = () => new CompressionLoadOptions
{
Format = CompressionFileType.Rar
};
using (Converter converter = new Converter("backup-files.rar", getLoadOptions))
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert("backup-files.pdf", options);
}
The following code snippet shows how to load a 7Z archive:
With v24.10 and later:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadContext, LoadOptions> getLoadOptions = loadContext => new CompressionLoadOptions
{
Format = CompressionFileType.SevenZ
};
using (Converter converter = new Converter("project-files.7z", getLoadOptions))
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert("project-files.pdf", options);
}
Before v24.10:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadOptions> getLoadOptions = () => new CompressionLoadOptions
{
Format = CompressionFileType.SevenZ
};
using (Converter converter = new Converter("project-files.7z", getLoadOptions))
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert("project-files.pdf", options);
}
The following code snippet shows how to convert from ZIP to 7Z format:
With v24.10 and later:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadContext, LoadOptions> getLoadOptions = loadContext => new CompressionLoadOptions
{
Format = CompressionFileType.Zip
};
using (Converter converter = new Converter("source-archive.zip", getLoadOptions))
{
CompressionConvertOptions options = new CompressionConvertOptions
{
Format = CompressionFileType.SevenZ
};
converter.Convert("source-archive.7z", options);
}
Before v24.10:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadOptions> getLoadOptions = () => new CompressionLoadOptions
{
Format = CompressionFileType.Zip
};
using (Converter converter = new Converter("source-archive.zip", getLoadOptions))
{
CompressionConvertOptions options = new CompressionConvertOptions
{
Format = CompressionFileType.SevenZ
};
converter.Convert("source-archive.7z", options);
}
The following code snippet shows how to load a password-protected ZIP archive:
With v24.10 and later:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadContext, LoadOptions> getLoadOptions = loadContext => new CompressionLoadOptions
{
Format = CompressionFileType.Zip,
Password = "archive-password"
};
using (Converter converter = new Converter("protected-archive.zip", getLoadOptions))
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert("protected-archive.pdf", options);
}
Before v24.10:
using GroupDocs.Conversion;
using GroupDocs.Conversion.FileTypes;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
Func<LoadOptions> getLoadOptions = () => new CompressionLoadOptions
{
Format = CompressionFileType.Zip,
Password = "archive-password"
};
using (Converter converter = new Converter("protected-archive.zip", getLoadOptions))
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert("protected-archive.pdf", options);
}
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.