Skip to content

Instantly share code, notes, and snippets.

View usman-aziz's full-sized avatar

Usman Aziz usman-aziz

  • Aspose Pty Ltd
  • Pakistan
View GitHub Profile
final Redactor redactor = new Redactor("sample.xlsx");
try
{
CellFilter filter = new CellFilter();
filter.setColumnIndex(1);
filter.setWorkSheetName("Customers");
Pattern expression = Pattern.compile("^\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
RedactorChangeLog result = redactor.apply(new CellColumnRedaction(filter, expression, new ReplacementOptions("[customer email]")));
if (result.getStatus() != RedactionStatus.Failed)
{
using (Metadata metadata = new Metadata("sample.jpeg"))
{
var root = metadata.GetRootPackage<JpegRootPackage>();
root.RemoveImageResourcePackage();
metadata.Save("output.jpeg");
}
// Load the document
using (FileStream stream = File.Open("document.docx", FileMode.Open, FileAccess.ReadWrite))
{
using (Watermarker watermarker = new Watermarker(stream))
{
// Use path to the image as constructor's parameter
using (ImageWatermark watermark = new ImageWatermark("logo.png"))
{
watermark.HorizontalAlignment = HorizontalAlignment.Center;
watermark.VerticalAlignment = VerticalAlignment.Center;
// Create an instance of Parser class
using(Parser parser = new Parser("sample.docx"))
{
// Extract text into the reader
using(TextReader reader = parser.GetText())
{
// Print text from the document
// If text extraction isn't supported, reader is null
Console.WriteLine(reader == null ? "Text extraction isn't supported." : reader.ReadToEnd());
}
// Set text for description field
const string description =
"GroupDocs.Assembly for .NET is a class library that enables you to generate documents in popular " +
"Office and email file formats based upon template documents and data obtained from various sources " +
"including databases, XML, JSON, OData, objects of custom .NET types, external documents, and more.";
// Create document assembler
DocumentAssembler assembler = new DocumentAssembler();
// Generate report
assembler.AssembleDocument(
"ReadMe.docx",
using (Signature signature = new Signature("D:\\sample.pdf"))
{
TextSignOptions options = new TextSignOptions("John Smith")
{
// set Text color
ForeColor = Color.Red
};
// sign document to file
signature.Sign("D:\\signed.pdf", options);
@usman-aziz
usman-aziz / DocumentSignature.java
Created July 31, 2019 07:39
GroupDocs.Signature for Java 19.7
// For complete examples and data files, please go to https://github.com/groupdocs-signature/GroupDocs.Signature-for-Java
public static class DocumentSignature
{
    public String getVersion(){ return Version; }
    public void setVersion(String value){ Version = value; }
    // specify SkipSerialization attribute to skip this field on serialization
    @SkipSerializationAttribute()
    public String Version;
   
    public boolean isProcessed(){ return IsProcessed; }
@usman-aziz
usman-aziz / AzureInputDataHandler.cs
Created March 20, 2018 11:59
GroupDocs.Viewer for .NET
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET
/// <summary>
/// The implementation of GroupDocs.Viewer data handler for Azure Blob Storage.
/// </summary>
public class AzureInputDataHandler : IInputDataHandler
{
/// <summary>
/// The blob delimiter.
/// </summary>
private const char Delimiter = '/';
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
try{
// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.getConfiguration();
// Create html handler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
// Get document stream
FileInputStream stream = new FileInputStream("./Data/Storage/" + fileName);
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
try{
// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.getConfiguration();
// Create html handler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
// Get document stream
FileInputStream stream = new FileInputStream("./Data/Storage/" + fileName);