File compression is a process aimed at reducing file sizes by eliminating unnecessary data. This compression technique enables the creation of smaller file archives, simplifying the transfer and backup of large files or file collections. Additionally, compressed files facilitate faster and more convenient downloads while maximizing the storage capacity of removable media. Below, we are going to guide you on converting the most popular compression file formats using GroupDocs.Conversion.
Using GroupDocs.Conversion, you can convert the archive content to your desired format.
To illustrate, here is a code sample showcasing how to convert the content of a ZIP archive to PDF format:
importcom.groupdocs.conversion.Converter;importcom.groupdocs.conversion.contracts.ConvertOptionsProvider;importcom.groupdocs.conversion.contracts.SaveDocumentStreamForFileType;importcom.groupdocs.conversion.options.convert.PdfConvertOptions;importjava.io.File;importjava.io.FileNotFoundException;importjava.io.FileOutputStream;StringoutputFolder="converted";newFile(outputFolder).mkdirs();finalint[]index={0};// Create an output stream for each converted archive item
SaveDocumentStreamForFileTypeconvertedStreamProvider=(fileType)->{FileoutputFile=newFile(outputFolder,String.format("converted-%d.pdf",index[0]));index[0]++;try{returnnewFileOutputStream(outputFile);}catch(FileNotFoundExceptione){thrownewRuntimeException(e);}};// Convert each archive item to PDF
ConvertOptionsProviderconvertOptionsProvider=(sourceFileName,fileType)->newPdfConvertOptions();// Load the source ZIP file
try(Converterconverter=newConverter("sample.zip")){converter.convert(convertedStreamProvider,convertOptionsProvider);}
With this code snippet, you can effortlessly convert the content of a ZIP archive to PDF format using GroupDocs.Conversion in Java. Enjoy the simplicity and flexibility of converting your archive content to meet your specific needs.
Note
Refer to the API reference for more conversion options and customizations.
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.
On this page
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.