Skip to content

Instantly share code, notes, and snippets.

@groupdocscloud
Last active September 27, 2018 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save groupdocscloud/024c8d6fda257f009f47dd55141c959f to your computer and use it in GitHub Desktop.
Save groupdocscloud/024c8d6fda257f009f47dd55141c959f to your computer and use it in GitHub Desktop.
This Gist contains .NET examples of GroupDocs.Annotation Cloud
Annotation-CSharp
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
var configuration = new Configuration
{
AppSid = Sid,
AppKey = Key
};
var apiInstance = new ImagePagesApi(configuration);
try
{
var request = new DeletePagesRequest()
{
Name = "Annotated.pdf",
Folder = null,
};
// Delete previously generated images for document pages
var response = apiInstance.DeletePages(request);
Debug.Print("previously generated images for document pages deleted");
}
catch (Exception e)
{
Debug.Print("Exception when deleting previously generated images for document pages: " + e.Message);
}
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
var configuration = new Configuration
{
AppSid = Sid,
AppKey = Key
};
var apiInstance = new AnnotationApi(configuration);
try
{
var request = new DeleteCleanDocumentRequest()
{
Name = "Annotated.pdf",
Folder = null,
Password = null
};
// Remove annotations from document.
var response = apiInstance.DeleteCleanDocument(request);
Debug.Print("Annotations removed from document");
}
catch (Exception e)
{
Debug.Print("Exception when removing Annotation from Document: " + e.Message);
}
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
var configuration = new Configuration
{
AppSid = Sid,
AppKey = Key
};
var apiInstance = new AnnotationApi(configuration);
try
{
var request = new GetImportRequest()
{
Name = "Annotated.pdf",
Folder = null,
Password = null
};
// Import annotations from document
var response = apiInstance.GetImport(request);
foreach (var entry in response)
Debug.Print("Box :" + entry.Box);
}
catch (Exception e)
{
Debug.Print("Exception when getting Annotation Information: " + e.Message);
}
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
var configuration = new Configuration
{
AppSid = Sid,
AppKey = Key
};
var apiInstance = new ImageInfoApi(configuration);
try
{
var request = new GetInfoRequest()
{
Name = "Annotated.pdf",
Folder = null,
Password = null
};
// Get document Info from document.
var response = apiInstance.GetInfo(request);
Debug.Print("File Name: " + response.Name);
Debug.Print("Pages Count: " + response.Pages.Count);
}
catch (Exception e)
{
Debug.Print("Exception when getting document information: " + e.Message);
}
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
var configuration = new Configuration
{
AppSid = Sid,
AppKey = Key
};
var apiInstance = new ImagePagesApi(configuration);
try
{
var request = new GetPageRequest()
{
Name = "Annotated.pdf",
PageNumber=0,
Folder = null,
};
// Get link of specific document page image
var response = apiInstance.GetPage(request);
Debug.Print("Page Number :" + response.Number);
Debug.Print("Page Link :" + response.Link.Href);
}
catch (Exception e)
{
Debug.Print("Exception when getting link of specific document page image: " + e.Message);
}
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
var configuration = new Configuration
{
AppSid = Sid,
AppKey = Key
};
var apiInstance = new ImagePagesApi(configuration);
try
{
var request = new GetPagesRequest()
{
Name = "Annotated.pdf",
Folder = null,
};
// Get links of previously generated images for document pages
var response = apiInstance.GetPages(request);
Debug.Print("Total Pages: " + response.TotalCount);
foreach (var entry in response.Entries)
{
Debug.Print("Page Number :" + entry.Number);
Debug.Print("Page Link :" + entry.Link.Href);
}
}
catch (Exception e)
{
Debug.Print("Exception when get links of previously generated images for document pages: " + e.Message);
}
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
var configuration = new Configuration
{
AppSid = Sid,
AppKey = Key
};
var apiInstance = new PdfFileApi(configuration);
try
{
var request = new GetPdfRequest()
{
Name = "one-page.docx",
Folder = null,
Password=null
};
// Render document to PDF document
var response = apiInstance.GetPdf(request);
Debug.Print("Document Processed");
}
catch (Exception e)
{
Debug.Print("Exception when rednering document to PDF with Storage Output: " + e.Message);
}
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
var configuration = new Configuration
{
AppSid = Sid,
AppKey = Key
};
var apiInstance = new PdfFileApi(configuration);
try
{
var request = new GetPdfStreamRequest()
{
Name = "one-page.docx",
Folder = null,
Password = null
};
// Render document to PDF document
var response = apiInstance.GetPdfStream(request);
Debug.Print("Document Processed");
}
catch (Exception e)
{
Debug.Print("Exception when rednering document ot PDF with Stream Output: " + e.Message);
}
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
var configuration = new Configuration
{
AppSid = Sid,
AppKey = Key
};
var apiInstance = new ImagePagesApi(configuration);
try
{
var request = new PostPagesRequest()
{
Name = "Annotated.pdf",
Folder = null,
Password = null
};
// Geerate Images of Document Pages
var response = apiInstance.PostPages(request);
Debug.Print("Total Pages: " + response.TotalCount);
foreach (var entry in response.Entries)
{
Debug.Print("Page Number :" + entry.Number);
Debug.Print("Page Link :" + entry.Link.Href);
}
}
catch (Exception e)
{
Debug.Print("Exception when generating image of Document pages: " + e.Message);
}
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
var configuration = new Configuration
{
AppSid = Sid,
AppKey = Key
};
var apiInstance = new AnnotationApi(configuration);
try
{
List<AnnotationInfo> annotations = new List<AnnotationInfo>();
AnnotationInfo annotation = new AnnotationInfo
{
AnnotationPosition = new Point(852, 154.31),
Replies = new[]
{
new AnnotationReplyInfo {Message = "reply text", RepliedOn = DateTime.Now, UserName = "Admin"},
new AnnotationReplyInfo
{
Message = "reply2 text",
RepliedOn = DateTime.Now,
UserName = "Commentator"
}
},
Box = new Rectangle((float)173.29, (float)154.31, (float)142.5, 9),
PageNumber = 0,
SvgPath =
"[{\"x\":173.2986,\"y\":687.5769},{\"x\":315.7985,\"y\":687.5769},{\"x\":173.2986,\"y\":678.5769},{\"x\":315.7985,\"y\":678.5769}]",
Type = AnnotationType.Text,
CreatorName = "Anonym A."
};
annotations.Add(annotation);
PutExportRequest request = new PutExportRequest()
{
Name ="Annotated.pdf",
Folder=null,
Password=null,
Body=annotations,
};
// Insert/Export annotations to document.
var response = apiInstance.PutExport(request);
Debug.Print("Document Processsed and stream length: " + response.Length);
}
catch (Exception e)
{
Debug.Print("Exception when inserting Annotation to document: " + e.Message);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment