Skip to content

Instantly share code, notes, and snippets.

Avatar

GroupDocs GroupDocsGists

View GitHub Profile
@GroupDocsGists
GroupDocsGists / ExtractImagesFromDocument.cs
Last active Oct 28, 2020
Extract Images from Word, Excel, PowerPoint, PDF Documents Programmatically
View ExtractImagesFromDocument.cs
// Extract Images from Word, Excel, PPT, PDF in C# using GroupDocs.Parser for .NET
using (Parser parser = new Parser("path/document.pdf"))
{
IEnumerable<PageImageArea> images = parser.GetImages();
ImageOptions options = new ImageOptions(ImageFormat.Png);
int imageNumber = 0;
// Iterate over retrieved images
foreach (PageImageArea image in images)
{
// Save Image and print page index, rectangle and image type:
@GroupDocsGists
GroupDocsGists / EmbedDocumentToPresentationsOLE.java
Created Oct 10, 2020
Embed Document into Presentations as OLE Object in Java
View EmbedDocumentToPresentationsOLE.java
// Embed Spreadsheet into a Presentations as an OLE object
int pageNumber = 1;
OlePresentationOptions oleSlidesOptions = new OlePresentationOptions("spreadsheet.xlsx", pageNumber);
// Set Coordinates and Dimensions
oleSlidesOptions.setX(10);
oleSlidesOptions.setY(10);
oleSlidesOptions.setHeight(200);
oleSlidesOptions.setWidth(200);
// Import the Spreadsheet into Presentation
Merger merger = new Merger("presentation.pptx");
@GroupDocsGists
GroupDocsGists / EmbedDocumentToExcelOLE.java
Last active Oct 10, 2020
Embed Document into Excel Spreadsheet as OLE Object in Java
View EmbedDocumentToExcelOLE.java
// Embed Word Document into an Excel Spreadsheet as an OLE object
int pageNumber = 1;
OleSpreadsheetOptions oleCellsOptions = new OleSpreadsheetOptions("document.docx", pageNumber);
oleCellsOptions.setRowIndex(2); // Set row & column number of Spreasheet to embedded document
oleCellsOptions.setColumnIndex(1);
// Import the Word document into Spreadsheet
Merger merger = new Merger("spreadsheet.xlsx"); // Source Spreadsheet
merger.importDocument(oleCellsOptions);
merger.save("output-spreadsheet.xlsx");
@GroupDocsGists
GroupDocsGists / EmbedDocumentToWordOLE.java
Last active Oct 10, 2020
Embed Document into Word Document as OLE Object using Java
View EmbedDocumentToWordOLE.java
// Embed PDF into a Word Document as an OLE object
int pageNumber = 1;
OleWordProcessingOptions oleWordsOptions = new OleWordProcessingOptions("PDF-document.pdf", pageNumber);
oleWordsOptions.setWidth(200); // Setting the width and height of embedded document
oleWordsOptions.setHeight(200);
// Import the PDF into Word Document
Merger merger = new Merger("document.docx"); // Source Word document
merger.importDocument(oleWordsOptions);
merger.save("output-document.docx");
@GroupDocsGists
GroupDocsGists / VerifyDigitalSignature.java
Last active Oct 6, 2020
Verify Digital Signatures in Documents using Java
View VerifyDigitalSignature.java
// Verifying Digital Signatures in a PDF document using Signature API for Java by GroupDocs
Signature signature = new Signature("sample_signed.pdf");
DigitalVerifyOptions options = new DigitalVerifyOptions("certificate.pfx");
options.setComments("Test comment");
options.setPassword("1234567890");
// Verify Document Signatures
VerificationResult result = signature.verify(options);
if (result.isValid()) {
@GroupDocsGists
GroupDocsGists / AddImageWatermarkToImage.java
Created Sep 12, 2020
Add Image Watermark to Images using Java
View AddImageWatermarkToImage.java
// Add PNG Image Watermark to JPG using Java
ImageWatermark watermark = new ImageWatermark(Constants.Watermark_PNG);
watermark.setX(20);
watermark.setY(80);
// Add watermark to the source JPG Image and save the output
Watermarker watermarker = new Watermarker(Constants.JPG_IMAGE);
watermarker.add(watermark);
watermarker.save(Constants.JPG_IMAGE_OUTPUT);
watermark.close();
watermarker.close();
@GroupDocsGists
GroupDocsGists / AddTextWatermarkToJPG.java
Last active Sep 12, 2020
Add Text Watermark to Images using Java (JPG , PNG)
View AddTextWatermarkToJPG.java
// Add Text Watermark to JPG using Java
TextWatermark watermark = new TextWatermark("GroupDocs", new Font("Arial", 30, FontStyle.Bold | FontStyle.Italic));
// Set Watermark properties
watermark.setForegroundColor(Color.getRed());
watermark.setTextAlignment(TextAlignment.Right);
watermark.setOpacity(0.4);
watermark.setX(70);
watermark.setY(130);
@GroupDocsGists
GroupDocsGists / ConvertEmlToPdf.java
Created Aug 26, 2020
Convert MSG and EML to PDF in Java
View ConvertEmlToPdf.java
// Convert EML message to PDF
public void convertEmltoPDF(String filePath)
{
Converter converter = new Converter(filePath + "emailMessage.eml");
PdfConvertOptions options = new PdfConvertOptions();
converter.convert(filePath + "eml-Message.pdf", options);
}
View DynamicBookmarkInsertionWord.cs
//setting up source
const String strDocumentTemplate = "Word Templates/Dynamic bookmarks.docx";
//Setting up destination
const String strDocumentReport = "Word Reports/Dynamic bookmarks.docx";
//Setting up Uri Expression
const String bookmark_expression = "gd_bookmark";
//Setting up Display Text Expression
const String displayTextExpression = "GroupDocs";
try
{
View PasswordProtection.cs
// For complete examples and data files, please go to https://github.com/groupdocs-redaction/GroupDocs.Redaction-for-.NET
public override void Load(System.IO.Stream input)
{
try
{
// check security and load document
SetAccessGranted(true);
}
catch (SomeSecurityException)
You can’t perform that action at this time.