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 / add-pst-password.py
Created September 16, 2024 12:28
Manage Password-Protected PST in Python
if not pst.store.is_password_protected:
pst.store.change_password("your_new_password")
print("Password added successfully.")
@aspose-com-gists
aspose-com-gists / AddPhotoToVCard.cs
Created September 16, 2024 12:12
Managing vCard Files in C#
// Load the saved photo data
var photoData = File.ReadAllBytes("saved_photo.jpg");
// Create a new vCard photo object
var photo = new VCardPhoto
{
Data = photoData,
PhotoType = VCardPhotoType.JPEG // Specify the photo format
};
@aspose-com-gists
aspose-com-gists / convert-epub-to-docm.cs
Last active September 17, 2024 10:03
EPUB Files Conversion and Manipulation using .NET
Document document = new Document("template.epub");
document.Save("DocOutput.doc", SaveFormat.Doc);
var outputDocument = new Aspose.Words.Document("DocOutput.doc");
outputDocument.Save("output.docm", SaveFormat.Docm);
@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");