Click here to Skip to main content
14,208,773 members
Rate this:
Please Sign up or sign in to vote.
See more:

I have a digital signature (.pfx file) with me. I want to add this digital signature as a visible signature to a document which could be of any of these following formats- csv, word, excel or PDF. Can anybody help me to implement this on c# .net windows forms?

Thanking you...

What I have tried:

I am able to successfully attach a signature to pdf. but not able to attach the same to word and excel... please help
Updated 15-May-19 1:25am
RDBurmon 5-Mar-18 2:35am
try this one also
Rishi PJ(Member 13155151) 5-Mar-18 5:46am
Thank you.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

private void CreateNewPage()
      object missing = System.Reflection.Missing.Value;
      object fileName = @"F:\Doc\test.docx";
      object readOnly = false;
      object isVisible = true;

      //Start Word and open a document.
      Microsoft.Office.Interop.Word._Application oWord;
      Microsoft.Office.Interop.Word._Document oDoc;
      oWord = new Microsoft.Office.Interop.Word.Application();
      oWord.Visible = true;

      oDoc = oWord.Documents.Open(ref fileName, ref missing, ref readOnly,
          ref missing, ref missing, ref missing, ref missing, ref missing,
          ref missing, ref missing, ref missing, ref isVisible, ref missing,
          ref missing, ref missing, ref missing);

      //  var numberOfPages = oDoc.ComputeStatistics(Word.WdStatistic.wdStatisticPages, false);

      object oEndOfDoc = "\\endofdoc";
      object paramNextPage = Microsoft.Office.Interop.Word.WdBreakType.wdSectionBreakNextPage;

      oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range.InsertBreak(ref paramNextPage);
      //Insert a page break
      object breakPage = Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;

      object saveOption = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;
      object originalFormat = Microsoft.Office.Interop.Word.WdOriginalFormat.wdOriginalDocumentFormat;
      object routeDocument = false;

      object what = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToPage;
      object which = Microsoft.Office.Interop.Word.WdGoToDirection.wdGoToLast;
      object count = 3;

      oWord.Selection.GoTo(ref what, ref which, ref count, ref missing);

      object sigID = "{00000000-0000-0000-0000-000000000000}";


          SignatureSet signatureSet = oWord.ActiveDocument.Signatures;
          // signatureSet.ShowSignaturesPane = false;
          Signature objSignature = signatureSet.AddSignatureLine(sigID);
          objSignature.Setup.SuggestedSigner = "docSigner";
          objSignature.Setup.SuggestedSignerEmail = "";
          objSignature.Setup.ShowSignDate = true;
          //  dynamic shape = objSignature.SignatureLineShape;
      catch (Exception ex) { MessageBox.Show(ex.Message); }


      catch (Exception e) { MessageBox.Show(e.Message); }

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.190612.1 | Last Updated 15 May 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100