Skip to content

Instantly share code, notes, and snippets.

View aspose-com-gists's full-sized avatar

Aspose.com Gists aspose-com-gists

View GitHub Profile
@aspose-com-gists
aspose-com-gists / Decrypt-RAR-Files.java
Created September 12, 2024 21:58
Decrypt RAR Files in Java
// Define the path for the working directory.
String dir = "/Desktop/";
// Instantiate a FileInputStream object to read input bytes from a file located in the file system.
try (FileInputStream fs = new FileInputStream(dir + "encrypted.rar")) {
// Create an object of the RarArchiveLoadOptions class.
RarArchiveLoadOptions options = new RarArchiveLoadOptions();
// Invoke the setDecryptionPassword method to set password to decrypt the RAR file.
options.setDecryptionPassword("p@s$");
// Initialize a new instance of the RarArchive class.
try (RarArchive archive = new RarArchive(fs, options)) {
@aspose-com-gists
aspose-com-gists / Extract-an-Entry.java
Created September 11, 2024 20:21
Extract an Entry of RAR Archive
try (FileInputStream fs = new FileInputStream(dir + "sample.rar")) {
try (RarArchive archive = new RarArchive(fs)) {
// The extract method extracts the entry to the filesystem by the path provided.
archive.getEntries().get(0).extract(dir + "sample-1_1.webp");
}
} catch (IOException e) {
e.printStackTrace();
}
@aspose-com-gists
aspose-com-gists / extract-RAR-files.java
Created September 11, 2024 20:19
extract RAR files in Java
String dir = "/Desktop/";
// Create an object of the FileInputStream class to obtain input bytes from a file in a file system.
try (FileInputStream fs = new FileInputStream(dir + "sample.rar")) {
// Initialize a new instance of the RarArchive class with the input stream.
RarArchive archive = new RarArchive(fs);
// Call extractToDirectory method to extract the files in the directory.
archive.extractToDirectory(dir + "DecompressRar_out");
} catch (IOException e) {
e.printStackTrace();
}
@aspose-com-gists
aspose-com-gists / publisher-to-png-in-java.md
Created September 11, 2024 05:11
Convert Publisher to PNG in Java
@aspose-com-gists
aspose-com-gists / Password-Protect-RAR-file.java
Last active September 10, 2024 08:46
Password-Protect RAR File in Java
// Define path for the working directory.
String dir = "/Desktop/";
// Initialize a new object of the TraditionalEncryptionSettings class with a desired password.
TraditionalEncryptionSettings traditionalEncryptionSettings = new TraditionalEncryptionSettings("asdf");
// Instantiate an instance of the ArchiveEntrySettings class.
ArchiveEntrySettings archiveEntrySettings = new ArchiveEntrySettings(null,traditionalEncryptionSettings);
// Create an object of the Archive class and initialize it with the object of the ArchiveEntrySettings class.
try (Archive archive = new Archive(archiveEntrySettings)) {
// Call the createEntry method to create single entry within the archive.
archive.createEntry("picture.png", dir+"picture.png");
@aspose-com-gists
aspose-com-gists / convert-email-formats-to-images.cs
Last active September 9, 2024 11:44
Email Formats Conversion Using .NET
//sourceFile.eml, sourceFile.emlx, sourceFile.oft
MailMessage message = MailMessage.Load("sourceFile.msg");
message.Save("HtmlOutput.html", SaveOptions.DefaultHtml);
Document document = new Document("HtmlOutput.html");
// SaveFormat.Png, Bmp, Gif, Jpeg, Tiff
document.Save("output.png", SaveFormat.Png);
@aspose-com-gists
aspose-com-gists / convert-docx-to-pptx.cs
Last active September 9, 2024 04:10
Word Document Conversion using .NET
//DOC DOCM DOCX DOT DOTM DOTX
Aspose.Words.Document docx = new Aspose.Words.Document("sourceWordFile.docx");
// Save DOCX file to HTML
docx.Save("filepath\\test.html", SaveFormat.Html);
// To convert multi pages DOCX documents, export each page to HTML separately using Aspose.Words and then use the below code to convert to PPTX.
using (Presentation pptx = new Presentation()){
@aspose-com-gists
aspose-com-gists / convert-csv-to-powerpoint.cs
Last active September 8, 2024 16:19
CSV Files Conversion using .NET
var book = new Aspose.Cells.Workbook("input.csv");
book.Save("pdfOutput.pdf", Aspose.Cells.SaveFormat.Auto);
var document = new Aspose.Pdf.Document("pdfOutput.pdf");
// save document in PPTX format
document.Save("output.pptx", SaveFormat.Pptx);