Skip to content

Instantly share code, notes, and snippets.

Avatar

GroupDocs GroupDocsGists

View GitHub Profile
@GroupDocsGists
GroupDocsGists / RemoveWatermark.cs
Last active Nov 25, 2020
Remove watermarks from Documents in .NET
View RemoveWatermark.cs
// Remove the watermarks from Word, Excel, PowerPoint, Visio and PDF Documents using C#
using (Watermarker watermarker = new Watermarker("filepath/documentWithWatermarks.pdf"))
{
PossibleWatermarkCollection possibleWatermarks = watermarker.Search();
// Remove watermark at the specified index from the document.
possibleWatermarks.RemoveAt(0);
// Remove specified watermark from the document.
possibleWatermarks.Remove(possibleWatermarks[0]);
@GroupDocsGists
GroupDocsGists / SearchWatermarks.cs
Last active Nov 25, 2020
Search Watermarks from Documents in .NET
View SearchWatermarks.cs
// Find all the watermarks in Word, Excel, PowerPoint, Visio and PDF Documents using C#
using (Watermarker watermarker = new Watermarker("filepath/documentWithWatermarks.pdf"))
{
PossibleWatermarkCollection possibleWatermarks = watermarker.Search();
foreach (PossibleWatermark possibleWatermark in possibleWatermarks)
{
if (possibleWatermark.ImageData != null)
{
Console.WriteLine(possibleWatermark.ImageData.Length);
}
@GroupDocsGists
GroupDocsGists / SignDocsWithQRCode.cs
Last active Nov 18, 2020
Add QR Code to PDF, Excel, PPT, Word Documents, and Images using .NET and Java API
View SignDocsWithQRCode.cs
// Electronically Sign PDF, Excel, PPT, Word Documents and Images with QR Code using GroupDocs.Signature for .NET API
using (Signature signature = new Signature("filePath/document.pdf")) // Provide any DOC, PDF, XLS, PPT, PNG, JPG, WebP file.
{
// Create QR Code option with predefined text
QrCodeSignOptions options = new QrCodeSignOptions("Signed by GroupDocs")
{
EncodeType = QrCodeTypes.QR,
// Set QR Code position & appearance
Left = 50,
Top = 50,
@GroupDocsGists
GroupDocsGists / ConvertCadToPDF.cs
Last active Nov 8, 2020
Convert CAD Drawings (DWG, DGN, DWF) to PDF
View ConvertCadToPDF.cs
// Convert CAD drawing - DWG to PDF in C# using GroupDocs.Conversion for .NET
// Load Options
Contracts.Func<LoadOptions> getLoadOptions = () => new CadLoadOptions
{
LayoutNames = new []{ "Layout1", "Layout3" }, // Specifying Layouts
// Width = 1920,
// Height = 1080
};
using (Converter converter = new Converter("filePath/CAD-Drawing.dwg", getLoadOptions))
{
@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();
You can’t perform that action at this time.