Load document from URL

On this page

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

string url = "https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-.NET/blob/master/Examples/Resources/SampleFiles/input.pdf?raw=true";


using (Annotator annotator = new Annotator(GetRemoteFile(url)))
{
	AreaAnnotation area = new AreaAnnotation()
	{
		Box = new Rectangle(100, 100, 100, 100),
		BackgroundColor = 65535,
	};
	annotator.Add(area);
	annotator.Save("result.pdf");
}

private static Stream GetRemoteFile(string url)
{
	WebRequest request = WebRequest.Create(url);
	using (WebResponse response = request.GetResponse())
		return GetFileStream(response);
}

private static Stream GetFileStream(WebResponse response)
{
	MemoryStream fileStream = new MemoryStream();
	using (Stream responseStream = response.GetResponseStream())
		responseStream.CopyTo(fileStream);
		fileStream.Position = 0;
		return fileStream;
}

On this page