Load document from stream
There might be the case when source or target document is not physically located on the disk. Instead, you have the document in the form of a stream. In this case, to avoid the overhead of saving stream as a file on disk, GroupDocs.Annotation provides a way to work with document streams directly.
The following are the steps to be followed:
- Obtain document stream;
- Pass opened source document stream to Annotator class constructor.
Following code snippet describes this case.
String outputPath = "LoadDocumentFromStream.pdf"; InputStream stream = new FileInputStream("input.pdf"); final Annotator annotator = new Annotator(stream); AreaAnnotation area = new AreaAnnotation(); area.setBox(new Rectangle(100, 100, 100, 100)); area.setBackgroundColor(65535); annotator.add(area); annotator.save(outputPath); annotator.dispose();
Advanced Usage Topics
To learn more about document annotating features, please refer to the advanced usage section.
You may easily run the code above and see the feature in action in our GitHub examples:
- GroupDocs.Annotation for .NET examples, plugins, and showcase
- GroupDocs.Annotation for Java examples, plugins, and showcase
- Document Annotation for .NET MVC UI Example
- Document Annotation for .NET App WebForms UI Modern Example
- Document Annotation for Java App Dropwizard UI Modern Example
- Document Annotation for Java Spring UI Example
Free Online App
Along with full-featured Java library we provide simple, but powerful free Apps.
You are welcome to annotate your PDF, DOC or DOCX, XLS or XLSX, PPT or PPTX, PNG and other documents with free to use online GroupDocs Annotation App.