Add Text Redaction Annotation using Java Annotation API v18.4

Logo ImageAt GroupDocs, we are always focused on delivering the best to our customers. In this regard, we are excitedly announcing another monthly release of Java Annotation API v18.4. Using this latest version, now users can import distance annotation for Words and also able to add text redaction annotation in Slides. Aside this, multitude fixes and improvements are also introduced in this release. We therefore recommend you to download this latest release for a better API experience.

GroupDocs.Annotation for Java v18.4 – Features

  • Import of distance annotation for Words
  • Add text redaction annotation in Slides

Document Annotation API – Improvements

  • Merge similar annotations when importing from Words
  • Import of text annotation for Words
  • Replacement annotation for text in different paragraphs
  • Point with text for text annotation
  • Export of text annotation in Slides
  • Annotation export for big font sizes for Slides
  • Accepting SVG path also with spaces not only with commas
  • Improve CleanUp for Diagrams

Java Annotation API – Fixes

  • Export distance annotation in PDF
  • Import distance,text and arrow annotation from PDF
  • AnnotationImageHandler.getPages does not respect ImageOptions.setWidth
  • Text in TextField annotations when import from Diagrams
  • Import of arrow annotations in Words
  • Polyline and distance structure after export in Diagrams
  • Coordinates of annotations after exporting Images
  • Point annotation in Slides
  • Opacity value for import in Diagrams
  • Import text field for Diagrams
  • Arrow annotation doesn’t create for Diagrams
  • Slides bug with coordinates of paragraph and portion
  • Cleanup for text redaction annotation in Words
  • Transparent colors for Words and Images
  • Underline annotation doesn’t set on text and table in Words
  • Export adds extra comment for every shape in Diagrams
  • The align of text for textfield of annotation is wrong in Words
  • After export strikeout annotation in Words
  • When importing text for textfield annotation in Diagrams
  • Importing from Words resource redaction annotation does not have color
  • The sample hangs while importing distance annotation for Slides
  • Underline property does not work in text replace functional (Incorrect removing of underline text via Strikeout annotation)
  • Annotation comments are not added while importing and exporting document

Available Channels and Resources

Here are a few channels and resources for you to download, learn, try and get technical support on Documentation Annotation API:

Feedback

As always, you are welcome to share your feedback to improve this product. We will be happy to know your thoughts. Just create a forum thread and our dedicated support team will be there to respond.

Feedback

We always appreciate and welcome to our valuable users to share their feedback to improve this product. We will be happy to know your thoughts and suggestions. Just create a forum thread and our dedicated support team will be there to respond.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
Posted in GroupDocs.Annotation Product Family | Tagged | Leave a comment

Annotate Header and Footer using GroupDocs.Annotation for .NET 18.4

GroupDocs.Annotation for .NET

The GroupDocs team is glad to announce another monthly release of .NET Annotation API version 18.4 with a feature to add annotation in header footer of Words document. Apart from that, few improvements and fixes are also introduced in this release. We therefore recommend you to download this latest release of the API for a better and smoother experience.

GroupDocs.Annotation for .NET 18.4 – New Features

  • Add annotations in header footer of Words document

.NET Annotation API – Improvements

  • PDF format annotating using metadata
  • Refactoring Imaging

Document Annotation API – Bug Fixes

  • Wrong annotation range if other annotation has already been created in the same location
  • Cleanup leaves artifacts after deleting annotations in images

Available Channels and Resources

Here are a few channels and resources for you to download, learn, try and get technical support on GroupDocs.Annotation:

Feedback

We always appreciate and welcome to our valuable users to share their feedback to improve this product. We will be happy to know your thoughts and suggestions. Just create a forum thread and our dedicated support team will be there to respond.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
Posted in GroupDocs.Annotation Product Family | Tagged | Leave a comment

Scrambled output issue is resolved in GroupDocs.Comparison for .NET 18.4

GroupDocs.ComparisonMonthly release of GroupDocs.Comparison for .NET 18.4 comes with some major bug fixes. Issues such as comparing data in tables and comparison of table of contents are resolved. This release implements comparison of HTML documents as well. Please follow the release notes here for further details. We’d recommend you to download latest version of the API and share your feedback.

GroupDocs Document Comparison API – Features

  • Implement Comparison.Html

GroupDocs.Comparison for .NET 18.4 – Bug Fixes

  • Issues in comparison of table of contents
  • Fatal error in ParagraphDiffIndex
  • Issues with comparing data in tables
  • PPTX comparison output is hidden under some panel
  • PDF Comparison – scrambled/text overlapped output

Available Channels and Resources

Here are a few channels and resources for you to download, learn, try and get technical support on GroupDocs.Comparison for .NET API:

Feedback

You are always welcome to share your feedback and suggestions to improve this product, we take it very seriously and try to incorporate it as much as its possible for upcoming releases . We will be happy to know your thoughts. Just create a forum thread and our dedicated support team will be there to respond.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
Posted in GroupDocs.Comparison Product Family | Tagged | Leave a comment

Extract TOC from EPUB Documents using GroupDocs.Text for .NET 18.4

GroupDocs.Text for .NETIt gives us immense pleasure to announce the release of version 18.4 of GroupDocs.Text for .NET. The latest version allows extracting the table of contents from the EPUB documents. Furthermore, we have added the feature of detecting media type of .one file. Following sections provide details about the newly added features.

Extracting TOC from EPUB Documents

Using version 18.4, you can now extract TOC from the EPUB documents. To access the TOC, TableOfContents property of EpubPackage class is used. Once you get the TOC from the document, you can access the following properties of TOC items using TableOfContentsItem class:

  • Text – the text of the item (usually, it is a chapter’s title)
  • PageIndex – the page index of the text (null if it is just a node without content)
  • Count – the number of sub-items (zero if the item hasn’t sub-items)
  • this[int index] – gets a sub-item
  • ExtractPage – extracts a text of the item

Following code snippet shows how to extract TOC from EPUB document.

// Create a text extractor
using (EpubTextExtractor extractor = new EpubTextExtractor(@"document.epub"))
{
    // Print TOC on the screen
    PrintToc(extractor[0].TableOfContents, 0);
}
 
private static void PrintToc(IEnumerable tableOfContents, int depth)
{
    // Use spaces to indicate the depth of the TOC item
    string spaces = new string(' ', depth);
 
    // Iterate over items
    foreach (TableOfContentsItem item in tableOfContents)
    {
        System.Console.Write(spaces);
        // Print the item's text
        System.Console.Write(item.Text);
 
        // If item has a text (it's not just a node)
        if (item.PageIndex.HasValue)
        {
            // Print the text length
            System.Console.Write(string.Format(" ({0})", item.ExtractPage().Length));
        }
 
        System.Console.WriteLine();
 
        // If the item has children
        if (item.Count > 0)
        {
            // Print them
            PrintToc(item, depth + 1);
        }
    }
}

Media Type Detector for .one Files

This feature allows detecting the media type of OneNote sections using NoteMediaTypeDetector class. Following code snippet shows how to use this feature.

// Create a media type detector
var detector = new NoteMediaTypeDetector();
// Detect a media type by the file name
Console.WriteLine(detector.Detect("section.one");
// Detect a media type by the content
Console.WriteLine(detector.Detect(stream));

GroupDocs.Text for .NET – Available Channels and Resources

Here are a few channels and resources for you to download, learn, try and get technical support on GroupDocs.Text:

Feedback

As always, you are welcome to share your feedback or suggestions to improve this product. Just create a new topic at our forum and our dedicated support team will be there to respond.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
Posted in GroupDocs.Parser Product Family | Tagged , , , , | Leave a comment

Indexing of more than 1 TB of Text Documents in GroupDocs.Search for .NET 18.4

GroupDocs.Search for .NETGroupDocs team is pleased to announce the monthly release of version 18.4 of GroupDocs.Search for .NET. Using the latest version, you can now perform indexing of more than 1 TB of text documents. We would recommend you to download the latest version for better user experience.

GroupDocs.Search for .NET API – Enhancements

Support for Indexing of more than 1 TB of Text Documents

Using GroupDocs.Search for .NET version 18.4, you can now implement indexing of text documents of more than 1 TB in size. This enhancement increases the capabilities of API to handle huge text documents.

Available Channels and Resources

Here are a few channels and resources for you to download, try, learn and get technical support on GroupDocs.Search:

Feedback

If you have any suggestions, questions, or queries related to the .NET Search API, we will be happy to hear from you. Just create a forum thread to share your thoughts.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
Posted in GroupDocs.Search Product Family | Tagged , , | Leave a comment

Search Optical Signatures using Java E-Signing API v18.4

GroupDocs.Signature

We are delighted to announce the another monthly release of GroupDocs.Signature for Java v18.4. This release comes up with many features like searching QRCode and Barcode signatures in supported documents. Aside this, few improvements and fixes are also introduced in this version of the API. We would recommend you to download the new version of API and evaluate the exciting features to enhance document e-signing experience.

eSignature API for Java v18.4 – Features

Obtain Search Progress

Obtain search progress while searching signatures in the documents.
Following code sample shows how to obtain search progress:

SignatureHandler handler = new SignatureHandler(signConfig);
handler.SearchStarted.add(new ProcessStartEventHandler() {
	public void invoke(Object sender, ProcessStartEventArgs args) {
        System.out.println("Search started for "+args.getTotalSignatures()+"-page(s) in Document "+args.getGuid()+" started at " +String.valueOf(args.getStarted()));
    }
});		

Search QR-Code and Barcode Signatures

Search QR-Code and Barcode Signatures in following documents:

  • PDF
  • Cells
  • Slides
  • Words
  • Image

Following code sample shows how to search Barcode signature in the PDF document:

PdfSearchBarcodeOptions searchOptions = new PdfSearchBarcodeOptions();
searchOptions.setText("12345678");
// specify text math type
searchOptions.setMatchType(TextMatchType.Contains);
// search document
SearchResult result = handler.search("SignedBarCode.pdf", searchOptions);

Rectangle Property for Radial Gradient Brush

Rectangle property to set borders of ellipse for Radial Gradient Brush is introduced.

Java eSignature API v18.4 – Improvements

  • Separate Brush classes for following brush styles:
  • Update dynamic Metered library with latest changes
  • Mark Brush property as Obsolete
  • e-Signing API for Java 18.4 – Bug Fixes

    • Multiple options on pages setup give duplicate page numbers
    • Result of signing methods when document provided by URL

    Available Channels and Resources

    Here are a few channels and resources for you to learn, try and get technical support on GroupDocs.Signature API for Java:

    Feedback

    As always, you are welcome to share your feedback to improve this product. We will be happy to know your thoughts. Just create a forum thread and our dedicated support team will be there to respond.

    Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
    Posted in GroupDocs.Signature Product Family | Tagged | Leave a comment

    Render Print Area in Worksheets using GroupDocs.Viewer for .NET 18.4

    Document Viewer API

    Here we go! Another monthly release of GroupDocs.Viewer for .NET is out now. In the current release, you will find new options to render print area and to include or exclude hidden columns and rows in the Cells documents. Furthermore, we have added the support of rendering POTX, PPTM, and EPS file formats. Below you find the list of new features, improvements, and fixes added in GroupDocs.Viewer for .NET 18.4.

    .NET Document Rendering API – New Features

    Supported File Formats

    We have added the support of following file formats in this version.

    • POTX (PowerPoint Open XML Presentation Template)
    • PPTM (PowerPoint Open XML Macro-Enabled Presentation)
    • EPS (Encapsulated PostScript)

    Managing Text Overflow when Rendering Cells Documents

    When cells documents are rendered into HTML, overflowed text inside the cell overlays subsequent cells until it meets non-empty cell. To expand the cell width to fit the overflowed text, we have added a new option TextOverflowMode.AutoFitColumn for CellsOptions.TextOverflowMode property of HtmlOptions, ImageOptions or PdfOptions classes. The following code sample shows how to use this feature.

    // Setup GroupDocs.Viewer config
    ViewerConfig config = new ViewerConfig();
    config.StoragePath = @"C:\storage";
       
    // Create html handler
    ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
    string guid = "document.xlsx";
       
    // Set Cells options to hide overflowing text
    HtmlOptions options = new HtmlOptions();
    options.CellsOptions.TextOverflowMode = TextOverflowMode.AutoFitColumn;
      
    // Get pages 
    List pages = htmlHandler.GetPages(guid, options);
       
    foreach (PageHtml page in pages)
    {
        Console.WriteLine("Page number: {0}", page.PageNumber);
        Console.WriteLine("Html content: {0}", page.HtmlContent);
    }

    For more details on this feature, please visit this documentation article.

    Rendering Print Area in Cells Documents

    Starting from 18.4, GroupDocs.Viewer provides a new option RenderPrintAreaOnly in GroupDocs.Viewer.Converter.Options.CellsOptions class which enables rendering sections of the worksheet(s) defined as print area. GroupDocs.Viewer renders each print area in a worksheet as a separate page. The following code sample shows how to use this feature.

    // Setup GroupDocs.Viewer config
    ViewerConfig config = new ViewerConfig();
    config.StoragePath = @"C:\storage";
      
    // Create html handler
    ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
    string guid = "document.xlsx";
      
    // Enable redering of print area
    HtmlOptions options = new HtmlOptions();
    options.CellsOptions.RenderPrintAreaOnly = true;
      
    // Get pages 
    List pages = htmlHandler.GetPages(guid, options);
      
    foreach (PageHtml page in pages)
    {
        Console.WriteLine("Page number: {0}", page.PageNumber);
        Console.WriteLine("Html content: {0}", page.HtmlContent);
    }

    For more details on this feature, please visit this documentation article.

    Rendering Hidden Rows and Columns

    Sometimes cells document may contain hidden columns and rows. By default, hidden columns and rows are not rendered by the API. However, you can now control the inclusion of hidden content in the rendering results using ShowHiddenRows and ShowHiddenColumns properties of GroupDocs.Viewer.Converter.Options.CellsOptions class as shown in the following code sample.

    // Setup GroupDocs.Viewer config
    ViewerConfig config = new ViewerConfig();
    config.StoragePath = @"C:\storage";
      
    // Create html handler
    ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
    string guid = "document.xlsx";
      
    // Enable redering of hidden rows and columns
    HtmlOptions options = new HtmlOptions();
    options.CellsOptions.ShowHiddenRows = true;
    options.CellsOptions.ShowHiddenColumns = true;
      
    // Get pages 
    List pages = htmlHandler.GetPages(guid, options);
      
    foreach (PageHtml page in pages)
    {
        Console.WriteLine("Page number: {0}", page.PageNumber);
        Console.WriteLine("Html content: {0}", page.HtmlContent);
    }

    For more details on this feature, please visit this documentation article.

    Simple File Storage Interface

    Starting from v18.4, GroupDocs.Viewer provides the simple interface IFileStorage to implement custom file storage. This interface is an alternative to complex and overloaded ICacheDataHandler and IInputDataHandler interfaces. For sample implementations of custom file storage, please visit this documentation article.

    Document Viewer API for .NET – Fixes

    Following issues are fixed in version 18.4 of GroupDocs.Viewer for .NET.

    • Invalid PDF when rendering Excel document with multiple pages per sheet
    • DefaultFontName setting is not working for rendering Text documents into PDF and image
    • Incorrect rendering of the content in header and footer of Word document
    • Local links are ignored when rendering PDF to HTML
    • Discrepancy when rendering as JPEG and HTML

    GroupDocs.Viewer for .NET 18.4 – Improvements

    Following are the improvements that we have made in version 18.4.

    • Added prefix for CSS classes when rendering Email messages
    • Minified CSS content when rendering into HTML with EnableMinification is set to true
    • Improved rendering comments from Presentation documents
    • Added support JpegQuality option when rendering Microsoft Project documents
    • Extended support for DefaultFontName setting to PDF documents when rendering into HTML
    • Responsive HTML output required in the case of HTML representation

    Related Links and Resources

    We have a few channels and resources for you to download, learn, try and get technical support on document viewer API.

    Feedback

    As always, if you have any questions or suggestions, feel free to write on our forum.

    Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
    Posted in GroupDocs.Viewer Product Family | Tagged , , , , , , | Leave a comment

    Edit Watermark’s Text and Image using GroupDocs.Watermark for Java 18.3

    GroupDocs Watermark for .NETWe are excited to announce that we have released version 18.3 of GroupDocs.Watermark for Java. The latest version supports replacing text and image for the found watermarks across all the supported formats. It also allows editing of the objects that can be considered as the watermark in PDF documents. Following are some salient features of GroupDocs.Watermark for Java 18.3

    Replacing Text and Image for Found Watermarks

    The latest version allows replacing text and image for the found possible watermarks that we get in a search result. Following sections demonstrate how to replace text and image for the found watermarks.

    Replacing Text

    Document doc = Document.load("D:\\input.pptx");
     
    TextSearchCriteria searchCriteria = new TextSearchCriteria("test", false);
    PossibleWatermarkCollection watermarks = doc.findWatermarks(searchCriteria);
    for (PossibleWatermark watermark : watermarks)
    {
        try
        {
            watermark.setText("passed");
        }
        catch (Exception e)
        {
            // Found entity may not support text editing
            // Passed argument can have inappropriate value
            // Process such cases here
        }
    }
     
    doc.save("D:\\output.pptx");
    doc.close();

    Replacing Image

    String imagePath = "D:\\test.png";
    File imageFile = new File(imagePath);
    byte[] imageBytes = new byte[(int)imageFile.length()];
    InputStream imageInputStream = new FileInputStream(imageFile);
    imageInputStream.read(imageBytes);
    imageInputStream.close();
     
    Document doc = Document.load("D:\\input.pdf");
     
    SearchCriteria searchCriteria = new ImageDctHashSearchCriteria("D:\\logo.bmp");
    PossibleWatermarkCollection watermarks = doc.findWatermarks(searchCriteria);
    for (PossibleWatermark watermark : watermarks)
    {
        try
        {
            watermark.setImageData(imageBytes);
        }
        catch (Exception e)
        {
            // Found entity may not support image replacing
            // Passed image can have inappropriate format
            // Process such cases here
        }
    }
     
    doc.save("D:\\output.pdf");
    doc.close();

    For more details on this feature, please visit this documentation article.

    Editing Watermark Objects in PDF Documents

    Replacing Text for Particular Objects

    You can now replace text for the particular XObjects, artifacts and the annotations in a PDF document. Furthermore, replacing text with formatting is also supported. Following sections demonstrate this feature with code samples.

    Replacing Text

    PdfDocument doc = Document.load(PdfDocument.class, "D:\\sample.pdf");
    // Replace text for XObjects
    for (PdfXObject xObject : doc.getPages().get_Item(0).getXObjects())
    {
        if (xObject.getText().contains("Test"))
        {
            xObject.setText("Passed");
        }
    }
    // Replace text for artifacts
    for (PdfArtifact artifact : doc.getPages().get_Item(0).getArtifacts())
    {
        if (artifact.getText().contains("Test"))
        {
            artifact.setText("Passed");
        }
    }   
    
    // Replace text for annotations
    for (PdfAnnotation annotation : doc.getPages().get_Item(0).getAnnotations())
    {
        if (annotation.getText().contains("Test"))
        {
            annotation.setText("Passed");
        }
    }
    doc.save("D:\\output.pdf");
    doc.close();
    

    Replacing Text with Formatting

    PdfDocument doc = Document.load(PdfDocument.class, "D:\\sample.pdf");
    
    // Replace text for XObjects    
    for (PdfXObject xObject : doc.getPages().get_Item(0).getXObjects())
    {
        if (xObject.getText().contains("Test"))
        {
            xObject.getFormattedTextFragments().clear();
            xObject.getFormattedTextFragments().add("Passed", new Font("Calibri", 19, FontStyle.Bold), Color.getRed(), Color.getAqua());
        }
    }
    // Replace text for artifacts
    for (PdfArtifact artifact : doc.getPages().get_Item(0).getArtifacts())
    {
        if (artifact.getText().contains("Test"))
        {
            artifact.getFormattedTextFragments().clear();
            artifact.getFormattedTextFragments().add("Passed", new Font("Calibri", 19, FontStyle.Bold), Color.getRed(), Color.getAqua());
        }
    }    
    // Replace text for annotations
    for (PdfAnnotation annotation : doc.getPages().get_Item(0).getAnnotations())
    {
        if (annotation.getText().contains("Test"))
        {
            annotation.getFormattedTextFragments().clear();
            annotation.getFormattedTextFragments().add("Passed", new Font("Calibri", 19, FontStyle.Bold), Color.getRed(), Color.getAqua());
        }
    }    
    
    doc.save("D:\\output.pdf");
    doc.close();

    Replacing Image for Particular Objects

    The version 18.3 also supports replacing image for the particular XObjects, artifacts and the annotations as shown in the following code sample.

    String imagePath = "D:\\test.png";
    File imageFile = new File(imagePath);
    byte[] imageBytes = new byte[(int)imageFile.length()];
    InputStream imageInputStream = new FileInputStream(imageFile);
    imageInputStream.read(imageBytes);
    imageInputStream.close();
    
    PdfDocument doc = Document.load(PdfDocument.class, "D:\\sample.pdf");
    
    // Replace image for XObjects
    for (PdfXObject xObject : doc.getPages().get_Item(0).getXObjects())
    {
        if (xObject.getImage() != null)
        {
            xObject.setImage(new PdfWatermarkableImage(imageBytes));
        }
    }    
    // Replace image for artifacts
    for (PdfArtifact artifact : doc.getPages().get_Item(0).getArtifacts())
    {
        if (artifact.getImage() != null)
        {
            artifact.setImage(new PdfWatermarkableImage(imageBytes));
        }
    }
    // Replace image for annotations
    for (PdfAnnotation annotation : doc.getPages().get_Item(0).getAnnotations())
    {
        if (annotation.getImage() != null)
        {
            annotation.setImage(new PdfWatermarkableImage(imageBytes));
        }
    }
    
    doc.save("D:\\output.pdf");
    doc.close();

    For more details on this feature, please visit this documentation article.

    Available Channels and Resources

    Feedback

    As always, if you have any questions or suggestions, feel free to write on our forum.

    Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
    Posted in GroupDocs.Watermark Product Family | Tagged , , , , | Leave a comment

    GroupDocs Newsletter April 2018 – Document Manipulation API Updates and Code Examples

    LinkedIn Google+ Twitter Facebook
    Share this issue:

    Monthly Newsletter

    April 2018

    Java APIs to Add & Remove Watermarks from
    PDF, Microsoft Office, Email and Image File Formats
    Perform complex watermarking operations with simple syntax, easy to use methods and a few lines of code within Java applications.
     
    Java APIs to Add & Remove Watermarks
     

    GroupDocs.Watermark for Java is a powerful document watermarking API to add, search and remove watermarks in popular business and image file formats. The watermarks added by the API are hard to be automatically removed by third-party tools, while it can be easily used for searching and removing previously added watermarks of popular types.

     

    Explore NOWDownload FREE 30-Days Trial

    Available for: .NET

    Product News

    Product News

    Product News
     
    From the Library

    From the Library

    From the Library

     
    Feedback

    Feedback

    Feedback

     
    GroupDocs for .NETGroupDocs for JavaGroupDocs for Cloud APIs
    Product Releases and Updates

    Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
    Posted in Customer Newsletters | Leave a comment

    Edit Watermark Objects in PDF Documents using GroupDocs.Watermark for .NET 18.3

    GroupDocs Watermark for .NETWe are really delighted to announce the release of version 18.3 of GroupDocs.Watermark for .NET. The latest version supports editing of the objects that can be considered as the watermark in PDF documents. Furthermore, the feature of replacing text and image for the found watermarks is also added for all the supported formats. Following are some highlighted features of version 18.3.

    Editing Watermark Objects in PDF Documents

    Replacing Text for Particular Objects

    You can replace text for the particular XObjects, artifacts and the annotations in a PDF document. Furthermore, replacing text with formatting is also supported. Following sections demonstrate this feature with code samples.

    Replacing Text

    using (PdfDocument doc = Document.Load(@"D:\xobjects.pdf"))
    {
        // Replace text for XObjects
        foreach (PdfXObject xObject in doc.Pages[0].XObjects)
        {
            if (xObject.Text.Contains("Test"))
            {
                xObject.Text = "Passed";
            }
        }
        // Replace text for artifacts
        foreach (PdfArtifact artifact in doc.Pages[0].Artifacts)
        {
            if (artifact.Text.Contains("Test"))
            {
                artifact.Text = "Passed";
            }
        }    
    
        // Replace text for annotations
        foreach (PdfAnnotation annotation in doc.Pages[0].Annotations)
        {
            if (annotation.Text.Contains("Test"))
            {
                annotation.Text = "Passed";
            }
        }
        doc.Save(@"D:\output.pdf");
    }

    Replacing Text with Formatting

    using (PdfDocument doc = Document.Load(@"D:\xobjects.pdf"))
    {
        // Replace text for XObjects    
        foreach (PdfXObject xObject in doc.Pages[0].XObjects)
        {
            if (xObject.Text.Contains("Test"))
            {
                xObject.FormattedTextFragments.Clear();
                xObject.FormattedTextFragments.Add("Passed", new Font("Calibri", 19, FontStyle.Bold), Color.Red, Color.Aqua);
            }
        }
        // Replace text for artifacts
        foreach (PdfArtifact artifact in doc.Pages[0].Artifacts)
        {
            if (artifact.Text.Contains("Test"))
            {
                artifact.FormattedTextFragments.Clear();
                artifact.FormattedTextFragments.Add("Passed", new Font("Calibri", 19, FontStyle.Bold), Color.Red, Color.Aqua);
            }
        }
        // Replace text for annotations
        foreach (PdfAnnotation annotation in doc.Pages[0].Annotations)
        {
            if (annotation.Text.Contains("Test"))
            {
                annotation.FormattedTextFragments.Clear();
                annotation.FormattedTextFragments.Add("Passed", new Font("Calibri", 19, FontStyle.Bold), Color.Red, Color.Aqua);
            }
        }
        doc.Save(@"D:\output.pdf");
    }

    Replacing Image for Particular Objects

    The version 18.3 also supports replacing image for the particular XObjects, artifacts and the annotations as shown in the following code sample.

    using (PdfDocument doc = Document.Load(@"D:\xobjects.pdf"))
    {
        // Replace image for XObjects
        foreach (PdfXObject xObject in doc.Pages[0].XObjects)
        {
            if (xObject.Image != null)
            {
                xObject.Image = new PdfWatermarkableImage(File.ReadAllBytes(@"D:\test.png"));
            }
        }
        // Replace image for artifacts
        foreach (PdfArtifact artifact in doc.Pages[0].Artifacts)
        {
            if (artifact.Image != null)
            {
                artifact.Image = new PdfWatermarkableImage(File.ReadAllBytes(@"D:\test.png"));
            }
        }
        // Replace image for annotations
        foreach (PdfAnnotation annotation in doc.Pages[0].Annotations)
        {
            if (annotation.Image != null)
            {
                annotation.Image = new PdfWatermarkableImage(File.ReadAllBytes(@"D:\test.png"));
            }
        }
        doc.Save(@"D:\output.pdf");
    }

    Replacing Text and Image for Found Watermarks

    The latest version allows replacing text and image for the found possible watermarks that we get in a search result. Following sections demonstrate how to replace text and image for the found watermarks.

    Replacing Text

    using (Document doc = Document.Load(@"D:\input.pptx"))
    {
        TextSearchCriteria searchCriteria = new TextSearchCriteria("test", false);
        PossibleWatermarkCollection watermarks = doc.FindWatermarks(searchCriteria);
        foreach (PossibleWatermark watermark in watermarks)
        {
            try
            {
                watermark.Text = "passed";
            }
            catch (Exception e)
            {
                // Found entity may not support text editing
                // Passed argument can have inappropriate value
                // Process such cases here
            }
        }
     
        doc.Save(@"D:\output.pptx");
    }

    Replacing Image

    byte[] imageData = File.ReadAllBytes(@"D:\new_logo.png");
     
    using (Document doc = Document.Load(@"D:\input.pdf"))
    {
        SearchCriteria searchCriteria = new ImageDctHashSearchCriteria(@"D:\logo.bmp");
        PossibleWatermarkCollection watermarks = doc.FindWatermarks(searchCriteria);
        foreach (PossibleWatermark watermark in watermarks)
        {
            try
            {
                watermark.ImageData = imageData;
            }
            catch (Exception e)
            {
                // Found entity may not support image replacing
                // Passed image can have inappropriate format
                // Process such cases here
            }
        }
     
        doc.Save(@"D:\output.pdf");
    }

    For more details on this feature, please visit this documentation article.

    Available Channels and Resources

    Here are a few channels and resources for you to download, learn, try and get technical support on GroupDocs.Watermark:

    Feedback

    As always, we would love to hear your queries and suggestions at our forum.

    Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
    Posted in GroupDocs.Watermark Product Family | Tagged , , , , , | Leave a comment