/// <summary> /// Import the annotations from document /// </summary> /// <param name="docType">int</param> /// <returns>AnnotationInfo[]</returns> public AnnotationInfo[] ImportAnnotations(DocumentType docType) { AnnotationInfo[] annotations = null; if (docType.Equals(DocumentType.Images)) { annotations = annotator.ImportAnnotations(documentStream, docType); } else { annotations = annotator.ImportAnnotations(documentStream, docType, password); } return(annotations); }
/// <summary> /// Import annotations with merge functionality /// </summary> /// <param name="documentId"></param> /// <param name="fileId"></param> /// <param name="userId"></param> private void Import(long documentId, string fileId, long userId) { using (Stream inputDoc = _annotator.GetPdfFile(fileId).Stream) { _annotator.ImportAnnotations(documentId, inputDoc, DocumentType.Pdf, userId); } }
public static Document findDocumentByName(string filename) { AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler(); IDocumentDataHandler documentDataHandler = imageHandler.GetDocumentDataHandler(); Document doc = documentDataHandler.GetDocument(filename); if (doc != null) { return(doc); } long documentId = imageHandler.CreateDocument(filename); using (FileStream original = new FileStream(Utils.getStoragePath() + "/" + filename, FileMode.Create)) { imageHandler.ImportAnnotations(original, documentId); } return(documentDataHandler.Get(documentId)); }
/// <summary> /// Import annotations with merge functionality /// </summary> /// <param name="documentId"></param> /// <param name="fileId"></param> /// <param name="userId"></param> private void Import(long documentId, string fileId, long userId) { DocumentType docType; switch (Path.GetExtension(fileId).ToUpper()) { case ".DOCX": docType = DocumentType.Words; break; case ".DOC": docType = DocumentType.Words; break; case ".PPTX": docType = DocumentType.Slides; break; case ".PPT": docType = DocumentType.Slides; break; case ".XLSX": docType = DocumentType.Cells; break; case ".XLS": docType = DocumentType.Cells; break; default: docType = DocumentType.Pdf; break; } using (Stream inputDoc = _annotator.GetFile(fileId).Stream) { _annotator.ImportAnnotations(documentId, inputDoc, docType, userId); } }
/// <summary> /// Import and Export Annotations from Words document. /// </summary> /// Update CommonUtilities.filePath with path to word document files before using this function public static void ImportAndExportAnnotationsFromWords() { try { //ExStart:ImportAndExportAnnotationsFromWords // Create instance of annotator. AnnotationConfig cfg = CommonUtilities.GetConfiguration(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); // Get input file stream Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite); //importing annotations from Words document AnnotationInfo[] annotations = annotator.ImportAnnotations(inputFile, DocumentType.Words); //export imported annotation to another document (just for check) Stream clearDocument = new FileStream(CommonUtilities.MapDestinationFilePath("Clear.docx"), FileMode.Open, FileAccess.ReadWrite); Stream output = annotator.ExportAnnotationsToDocument(clearDocument, annotations.ToList(), DocumentType.Words); // Export annotation and save output file //save results after export using (FileStream fileStream = new FileStream(CommonUtilities.MapDestinationFilePath("AnnotationImportAndExportAnnotated.docx"), FileMode.Create)) { byte[] buffer = new byte[output.Length]; output.Seek(0L, SeekOrigin.Begin); output.Read(buffer, 0, buffer.Length); fileStream.Write(buffer, 0, buffer.Length); fileStream.Close(); } //ExEnd:ImportAndExportAnnotationsFromWords } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }