Exemple #1
0
 private void ImportAnnotationWithCleaning(string fileId)
 {
     using (Stream inputDoc = _annotator.GetPdfFile(fileId).Stream)
     {
         SaveCleanDocument(inputDoc, fileId);
     }
 }
        /// <summary>
        /// Get Password Protected Documents
        /// </summary>
        public static FileContainer GetPasswordProtectedDocuments(Stream protectedDocument, String password)
        {
            //ExStart:GetPasswordProtectedDocuments
            AnnotationConfig       cfg       = CommonUtilities.GetConfiguration();
            AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);

            FileContainer convertedDocument = annotator.GetPdfFile(protectedDocument, password);

            return(convertedDocument);

            //ExEnd:GetPasswordProtectedDocuments
        }
Exemple #3
0
        /// <summary>
        /// Converts a document to PDF format
        /// </summary>
        /// <param name="connectionId">Socket connection identifier to validate user permissions for</param>
        /// <param name="fileId">The document path to convert</param>
        /// <returns>A path to the converted file</returns>
        public string GetAsPdf(string connectionId, string fileId)
        {
            var document = _documentSvc.GetDocument(fileId);
            var reviewer = _annotationBroadcaster.GetConnectionUser(connectionId);

            if (reviewer == null)
            {
                throw new AnnotatorException("There is no such reviewer.");
            }
            var user = _userSvc.GetUserByGuid(reviewer.Value.UserGuid);

            _annotator.CheckReviewerPermissions(user.Id, document.Id, AnnotationReviewerRights.CanDownload);
            //var tempStorage = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
            var fileName = Path.ChangeExtension(Path.GetRandomFileName(), "pdf");

            using (Stream inputDoc = _annotator.GetPdfFile(fileId).Stream)
                using (var tempDoc = new FileStream(Path.Combine(storagePath, fileName), FileMode.Create))
                {
                    inputDoc.Position = 0;
                    inputDoc.CopyTo(tempDoc);
                    return(fileName);
                }
        }