Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
GroupDocsGists / PrintSearchResults.java
Created December 10, 2023 15:06
Print Search Results
// Highlight and Print Search Results for all the documents
for (int i = 0 ; i < result.getDocumentCount(); i++)
{
FoundDocument document = result.getFoundDocument(i);
OutputAdapter outputAdapter = new FileOutputAdapter(OutputFormat.Html, "path/Highlight" + i + ".html");
Highlighter highlighter = new DocumentHighlighter(outputAdapter);
index.highlight(document, highlighter);
System.out.println("\tDocument: " + document.getDocumentInfo().getFilePath());
@GroupDocsGists
GroupDocsGists / PrintSearchResults.cs
Last active December 10, 2023 15:07
Print Search Results
// Highlight and Print Search Results for all the documents using C#
for (int i = 0; i < result.DocumentCount; i++)
{
FoundDocument document = result.GetFoundDocument(i);
OutputAdapter outputAdapter = new FileOutputAdapter(OutputFormat.Html, indexFolder + "/Highlight" + i + ".html");
Highlighter highlighter = new DocumentHighlighter(outputAdapter);
index.Highlight(document, highlighter);
Console.WriteLine("\tDocument: " + document.DocumentInfo.FilePath);
@GroupDocsGists
GroupDocsGists / FuzzySearch.cs
Last active December 9, 2023 03:59
Fuzzy Search in Files across Folders using C#
// Fuzzy Search multiple files across multiple folders using C#
// Creating an index folder and add document's folder to it
Index index = new Index("indexing-folder-path");
index.Add("path/parent-folder");
SearchOptions options = new SearchOptions();
options.FuzzySearch.Enabled = true; // Enabling the fuzzy search
options.FuzzySearch.FuzzyAlgorithm = new SimilarityLevel(0.8);
@GroupDocsGists
GroupDocsGists / SearchByRegex.java
Created November 24, 2023 19:00
Regex Search in Files across Folders with Java
// Regex Search multiple files across folders using Java
// Creating an index folder and add document's folder to it
Index index = new Index("path/indexing-folder-path");
index.add("path/parent-folder");
// Prepare the Regex Query and Search
// Regex here is to identify all words having any consecutive repeated characters.
String query = "^(.)\\1{1,}";
SearchResult result = index.search(query);
@GroupDocsGists
GroupDocsGists / SearchByRegex.cs
Last active November 24, 2023 15:12
Search in Files across Folders by Regex using C#
// Search by RegEx in multiple files across multiple folders using C#
// Creating an index folder and add document's folder to it
Index index = new Index("indexing-folder-path");
index.Add("path/parent-folder");
// Prepare the Regex Query and Search
// Regex here is to identify all words having any consecutive repeated characters.
string query = "^(.)\\1{1,}";
SearchResult result = index.Search(query);
@GroupDocsGists
GroupDocsGists / PrintSearchResults.cs
Last active November 22, 2023 04:21
Efficient Text Search: Handling Multiple Files and Folders in C#
// Printing the result
Console.WriteLine("Documents: " + result.DocumentCount);
Console.WriteLine("Total occurrences: " + result.OccurrenceCount);
for (int i = 0; i < result.DocumentCount; i++)
{
FoundDocument document = result.GetFoundDocument(i);
Console.WriteLine("Document: " + document.DocumentInfo.FilePath);
Console.WriteLine("Occurrences: " + document.OccurrenceCount);
for (int j = 0; j < document.FoundFields.Length; j++)
@GroupDocsGists
GroupDocsGists / PrintSearchResults.java
Last active November 21, 2023 11:52
Efficient Text Search: Handling Multiple Files and Folders using Java
// Printing Search Results ===
for (int i = 0 ; i < result.getDocumentCount(); i++)
{
FoundDocument document = result.getFoundDocument(i);
// Printing Search Results ===========
System.out.println("Occurrences: " + document.getOccurrenceCount());
for (FoundDocumentField field : document.getFoundFields()) {
System.out.println("\tField: " + field.getFieldName());
@GroupDocsGists
GroupDocsGists / ReadDublinCore.java
Created October 27, 2023 06:57
Manage EPUB Metadata using Java
// Read Dublin Core metadata using Java
try (Metadata metadata = new Metadata("path/ebook.epub")) {
EpubRootPackage root = metadata.getRootPackageGeneric();
System.out.println(root.getDublinCorePackage().getRights());
System.out.println(root.getDublinCorePackage().getPublisher());
System.out.println(root.getDublinCorePackage().getTitle());
System.out.println(root.getDublinCorePackage().getCreator());
System.out.println(root.getDublinCorePackage().getLanguage());
System.out.println(root.getDublinCorePackage().getDate());
@GroupDocsGists
GroupDocsGists / ReadDublinCore.cs
Last active October 27, 2023 06:40
Manage EPUB Metadata using C#
// Read Dublin Core metadata using C#
using (Metadata metadata = new Metadata("path/ebook.epub"))
{
var root = metadata.GetRootPackage<EpubRootPackage>();
Console.WriteLine(root.DublinCorePackage.Rights);
Console.WriteLine(root.DublinCorePackage.Publisher);
Console.WriteLine(root.DublinCorePackage.Title);
Console.WriteLine(root.DublinCorePackage.Creator);
Console.WriteLine(root.DublinCorePackage.Language);
@GroupDocsGists
GroupDocsGists / EditPresentation.java
Created October 7, 2023 09:27
Edit PowerPoint PPT/PPTX Presentations in Java
// Edit PPT/PPTX presenatations in Java using GroupDocs presentation editing and automation API
// Load Presentation
PresentationLoadOptions loadOptions = new PresentationLoadOptions();
loadOptions.setPassword("P@$$w0Rd");
// Edit Presentation
Editor editor = new Editor(new FileInputStream("path/presentation.pptx"), loadOptions);
PresentationEditOptions editOptions = new PresentationEditOptions();
editOptions.setSlideNumber(0); //1st slide