public LockDisplayPane() { InitializeComponent(); if (this.documentEditSignatures == null) { this.documentEditSignatures = new TemplateDetails(); } }
private void ResetDocumentInDictionary(Word.Document Doc, string oldName) { string newName = Doc.Name; if (documentEditProperties.ContainsKey(oldName)) { TemplateDetails td = documentEditProperties[oldName]; documentEditProperties.Remove(oldName); documentEditProperties.Add(newName, td); } }
private void ReleaseSignatureInfo(TemplateDetails detailes) { foreach (SignatureInfo item in detailes.SignatureInfoList) { if (Marshal.IsComObject(item.SignatureControl)) { Marshal.ReleaseComObject(item.SignatureControl); } } detailes = null; }
public SignatureDisplayPane(TemplateDetails documentEditProperties, Logger logger) : this() { try { this.documentEditProperties = documentEditProperties; this.documentEditProperties.PDFFullName = string.Empty; UpdateControl(); } catch (Exception ex) { logger.LogException(LogLevel.Error, "SignatureDisplayPane", ex); } }
internal void LockDocument() { try { TemplateDetails details = documentEditProperties[this.Application.ActiveDocument.Name]; object noReset = false; object password = details.Password; object useIRM = false; object enforceStyleLock = false; this.Application.ActiveDocument.Protect(Word.WdProtectionType.wdAllowOnlyReading, ref noReset, ref password, ref useIRM, ref enforceStyleLock); RemoveTaskPaneFromWindow(); } catch (Exception ex) { logger.LogException(LogLevel.Error, "LockDocument", ex); } }
public LockDisplayPane(TemplateDetails documentEditSignatures) : this() { // Store reference to edit times this.documentEditSignatures = documentEditSignatures; }
internal void AddSignatures() { TemplateDetails details = documentEditProperties[this.Application.ActiveDocument.Name]; Word.Document doc = Globals.ThisAddIn.Application.ActiveDocument; //Save document using SaveAs function SaveAsWordDocumentWithoutSignatures(); //12/03/2017 - unlock controls to insert signatures DocContent.UnlockHeaderSignatures(doc); DocContent.UnlockBodySignatures(doc); DocContent.UnlockFooterSignatures(doc); int selectionStart = 0; //Add Signatures to document foreach (SignatureInfo item in details.SignatureInfoList) { try { DocContent.ByteArrayToImageFilebyMemoryStream(item); if (!string.IsNullOrEmpty(item.PicturePath)) { DocContent.AddPictureToControl(doc, item.SignatureControl, item.PicturePath, ref selectionStart); if (File.Exists(item.PicturePath)) { File.Delete(item.PicturePath); } } } catch (Exception ex) { logger.LogException(LogLevel.Error, "AddSignatures1", ex); } } //Save as pdf SaveAsPDF(); try { ////09/05/2017 ////Remove pictures //foreach (SignatureInfo item in details.SignatureInfoList) //{ //// 09/05/2017 - ira // item.SignatureControl.Delete(); // DocContent.DeletePictureFromControl(doc, item.SignatureControl); //} ////logger.Log(LogLevel.Warn, "B4 SaveAsWordDocumentWithoutSignatures"); ////Save as Word Document without the signature //SaveAsWordDocumentWithoutSignatures(); ////logger.Log(LogLevel.Warn, "After SaveAsWordDocumentWithoutSignatures"); RemoveTaskPaneFromWindow(); } catch (Exception ex) { logger.LogException(LogLevel.Error, "AddSignatures2", ex); } object saveOption = Word.WdSaveOptions.wdDoNotSaveChanges; object originalFormat = Word.WdOriginalFormat.wdOriginalDocumentFormat; object routeDocument = false; doc.Close(ref saveOption, ref originalFormat, ref routeDocument); }