Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
GroupDocsGists / EditPresentation.cs
Last active October 7, 2023 04:24
Edit PowerPoint PPT/PPTX Presentations using C#
// Edit PPT/PPTX presenatations in C# using GroupDocs presentation editing and automation API
using (FileStream fs = File.OpenRead("path/presentation.pptx"))
{
// Load Presentation
Options.PresentationLoadOptions loadOptions = new PresentationLoadOptions();
loadOptions.Password = "P@$$w0Rd";
// Edit Presentation
using (Editor editor = new Editor(delegate { return fs; }, delegate { return loadOptions; }))
{
@GroupDocsGists
GroupDocsGists / ImageWatermarkToWordDoc.java
Last active August 31, 2023 12:45
Add Watermarks to Word Documents using Java | Text and Image Watermarks
// Apply Image Watermark to specific page(s) of Word file using Java
Watermarker watermarker = new Watermarker("path/document.docx");
ImageWatermark watermark = new ImageWatermark("path/watermark-logo.png");
watermark.setOpacity(0.7);
watermark.setHorizontalAlignment(HorizontalAlignment.Center);
watermark.setVerticalAlignment(VerticalAlignment.Center);
// Add watermark to the last page
WordProcessingContent content = watermarker.getContent(WordProcessingContent.class);
@GroupDocsGists
GroupDocsGists / ImageWatermarkToWordDoc.cs
Last active August 29, 2023 15:27
Add Watermarks to Word Documents using C# | Text and Image Watermarks
// Add Watermark Image to specific page(s) of Word document using C#
using (Watermarker watermarker = new Watermarker("path/multipage-document.docx"))
{
ImageWatermark watermark = new ImageWatermark("path/image.png")
{
Opacity = .5,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
};
@GroupDocsGists
GroupDocsGists / ChangeSpreadsheetPassword.java
Last active August 10, 2023 12:20
Protection of Excel Spreadsheets by Adding, Removing, and Changing Password using Java
/*
* Update password of the protected spreadsheet files using Java
*/
LoadOptions loadOptions = new LoadOptions("mySECRETpassWORD");
UpdatePasswordOptions updateOptions = new UpdatePasswordOptions("TOPSECRET_pa22WORD");
Merger merger = new Merger("path/protected-spreadsheet.xlsx", loadOptions);
merger.updatePassword(updateOptions);
merger.save("path/pwd-changed-spreadsheet.xlsx");
@GroupDocsGists
GroupDocsGists / ChangeSpreadsheetPassword.cs
Last active August 10, 2023 08:10
Protection of Excel Spreadsheets by Adding, Removing, and Changing Password using C#
/*
* Change password of protected Excel spreadsheets using C#
*/
string filePath = @"path/protected-spreadsheet.xlsx";
LoadOptions loadOptions = new LoadOptions("mySECRETpassWORD");
UpdatePasswordOptions updateOptions = new UpdatePasswordOptions("TOPSECRET_pa22WORD");
using (Merger merger = new Merger(filePath, loadOptions))
{
@GroupDocsGists
GroupDocsGists / MergeSelectedWordPages.java
Last active June 8, 2023 08:21
Merge Word Documents with Java
// Merge Selective Pages of Word Documents using Java
Merger merger = new Merger("source_document.docx"))
{
// Set the merging options
JoinOptions joinOptions = new JoinOptions(2,3); // Specify the starting and ending page number
// Merge the documents
merger.join("document_to_merge.docx", joinOptions); // using joining settings
merger.join("another_document_to_merge.docx", new JoinOptions(new int[] { 2, 4, 6 })); // Specifying page number(s)
@GroupDocsGists
GroupDocsGists / MergeSelectedWordPages.cs
Last active June 8, 2023 08:21
Merge Word Documents using C#
// Merge Selective Pages of Word Documents using C#
using (Merger merger = new Merger("source_document.docx"))
{
// Set the merging options
JoinOptions joinOptions = new JoinOptions(2,3); // Specify the starting and ending page number
// Merge the documents
merger.Join("document_to_merge.docx", joinOptions); // using joining settings
merger.Join("another_document_to_merge.docx", new JoinOptions(new[] { 2, 4, 6 })); // Specifying page number(s)
@GroupDocsGists
GroupDocsGists / ScanBarcode.java
Last active May 23, 2023 12:17
Scan Barcode & QR Code using Java
// Scan Barcode using Java
try(Parser parser = new Parser("/path/barcode.png"))
{
// Extract all Barcodes.
Iterable<PageBarcodeArea> barcodes = parser.getBarcodes();
// Iterate
for(PageBarcodeArea barcode : barcodes)
{
// Print the Identified Barcode values
@GroupDocsGists
GroupDocsGists / ScanBarcode.cs
Last active May 23, 2023 12:13
Scan Barcode & QR Code using C#
// Scan Barcode using C#
using (Parser parser = new Parser("/path/barcode.png"))
{
// Extract all Barcodes.
IEnumerable<PageBarcodeArea> barcodes = parser.GetBarcodes();
// Iterate over Barcodes
foreach (PageBarcodeArea barcode in barcodes)
{
// Print the Identified Barcode values
@GroupDocsGists
GroupDocsGists / AcceptRejectPdfComparisonChanges.java
Last active April 7, 2023 04:37
Compare PDF Documents, Find Differences, and Accept or Reject Changes using Java
// Accept and reject identified changes by comparing PDF documents using Java
Comparer comparer = new Comparer("path/document-1.pdf");
comparer.add("path/document-2.pdf");
ChangeInfo[] changes = comparer.getChanges();
changes[0].setComparisonAction(ComparisonAction.REJECT);
changes[1].setComparisonAction(ComparisonAction.ACCEPT);