Skip to content

Instantly share code, notes, and snippets.

View atirtahirgroupdocs's full-sized avatar
🏠
Working from home

Atir Tahir atirtahirgroupdocs

🏠
Working from home
View GitHub Profile
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
AnnotationConfig cfg = Utilities.getConfiguration();
AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
InputStream cleanDiagramFile = new FileInputStream(Utilities.storagePath + File.separator + fileName);
// FileInputStream input = new
// FileInputStream("AddAnnotations.TestData.");
// //Assembly.GetExecutingAssembly().GetManifestResourceStream("AddAnnotations.TestData.");
List<AnnotationInfo> annotations = new ArrayList<AnnotationInfo>();
// Area annotation with 2 replies
AnnotationInfo areaAnnnotation = new AnnotationInfo();
AnnotationConfig cfg = Utilities.getConfiguration();
AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
DocumentInfoContainer documentInfoContainer = annotator.getDocumentInfo(fileName);
// Go through all pages
for (PageData pageData : documentInfoContainer.getPages()) {
System.out.println("Page number: " + pageData.getNumber());
// Go through all page rows
for (int i = 0; i < pageData.getRows().size(); i++) {
RowData rowData = pageData.getRows().get(i);
AnnotationConfig cfg = Utilities.getConfiguration();
AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
List<PageImage> images = annotator.getPages(fileName, new ImageOptions());
for (int i = 0; i < images.size(); i++) {
OutputStream fileStream = new FileOutputStream(Utilities.outputPath + File.separator + "image_" + i + ".png");
final PageImage pageImage = images.get(i);
IOUtils.copy(pageImage.getStream(), fileStream);
}
// For complete examples and data files, please go to https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java
AnnotationConfig cfg = Utilities.getConfiguration();
AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
//there can be also documents of Emlx Msg formats
InputStream cleanDoc = new FileInputStream(Utilities.storagePath + File.separator + fileName); //"../../ClearEmailDocument.eml"
List<AnnotationInfo> annotations = new ArrayList<AnnotationInfo>();
AnnotationInfo textAnnotation = new AnnotationInfo();
textAnnotation.setPageNumber(0);
// For complete examples and data files, please go to https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java
AnnotationConfig cfg = Utilities.getConfiguration();
AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
//there can be also documents of Emlx Msg formats
InputStream cleanDoc = new FileInputStream(Utilities.storagePath + File.separator + fileName); //"../../ClearEmailDocument.eml"
List<AnnotationInfo> annotations = new ArrayList<AnnotationInfo>();
AnnotationInfo textAnnotation = new AnnotationInfo();
textAnnotation.setPageNumber(0);
// For complete examples and data files, please go to https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java
AnnotationConfig cfg = Utilities.getConfiguration();
AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
annotator.createDocument(fileName);
DocumentInfoContainer documentInfoContainer = annotator.getDocumentInfo(fileName);
// Go through all pages
for (PageData pageData : documentInfoContainer.getPages())
{
System.out.println("Page number: " + pageData.getNumber());
// For complete examples and data files, please go to https://github.com/groupdocs-signature/GroupDocs.Signature-for-Java
// setup Signature configuration
SignatureConfig signConfig = CommonUtilities.getConfiguration();
// instantiating the conversion handler
SignatureHandler<String> handler = new SignatureHandler<String>(signConfig);
DocumentDescription docInfo = handler.getDocumentDescription(CommonUtilities.getStoragePath(fileName), "");
System.out.println("Document " + docInfo.getGuid() + " contains " + docInfo.getPageCount() + " pages");
System.out.println("Width of first page is " + docInfo.getPages().get(0).getWidth()) ;
// Image from specified page
byte[] bytesImage = handler.getPageImage(CommonUtilities.getStoragePath(fileName), 1, null, null, null);
// For complete examples and data files, please go to https://github.com/groupdocs-signature/GroupDocs.Signature-for-Java
// setup Signature configuration
SignatureConfig signConfig = CommonUtilities.getConfiguration();
// instantiating the conversion handler
SignatureHandler<String> handler = new SignatureHandler<String>(signConfig);
PdfSignTextOptions signOptions = new PdfSignTextOptions("John Smith");
signOptions.setForeColor(Color.RED);
//setup text position on a page in 5 centimeters from top
signOptions.setLocationMeasureType(MeasureType.Millimeters);
signOptions.setTop(50);
// For complete examples and data files, please go to https://github.com/groupdocs-signature/GroupDocs.Signature-for-Java
// setup Signature configuration
SignatureConfig signConfig = CommonUtilities.getConfiguration();
// instantiating the conversion handler
SignatureHandler<String> handler = new SignatureHandler<String>(signConfig);
// setup image signature options with relative path - image file stores in config.ImagesPath folder
PdfSignTextOptions signOptions = new PdfSignTextOptions("John Smith");
signOptions.setLeft(100);
signOptions.setTop(100);
signOptions.setHeight(200);