Load document from URL

On this page

The following example shows how to load a document using its URL:

// This example demonstrates loading document from URL.


String url = "https://raw.githubusercontent.com/groupdocs-annotation/GroupDocs.Annotation-for-Java/master/Examples/Resources/SampleFiles/input.pdf?raw=true";

// Create an instance of Annotator class
Annotator annotator = new Annotator(new URL(url).openStream());
try {
    // Create an instance of AreaAnnotation class and set options
    AreaAnnotation area = new AreaAnnotation();
    area.setBox(new Rectangle(100, 100, 100, 100));
    area.setBackgroundColor(65535);
    
    // Add annotation and save to file
    annotator.add(area);
    annotator.save("outputPath");
} finally {
    if (annotator != null) {
        annotator.dispose();
    }
}

On this page