none
Creating SignatureLine in .docx file using OpenXML Formats... RRS feed

  • Question

  • Hello,

    My name is Raj, i am new to this news group. I have almost read all the
    posts and pretty impressed with reply's from different people.

    I recently faced a problem with MS Word 2007 and i would like to explain my
    problem and hopefully expect an reply to my query, thanks in advance.

    Problem:
    I wanted to create a digital signatureLine in my MS Word 2007 Document through
    C# programming. I have been using the windowsbase.dll for word document
    processing in 2007 and tried with different classes present in that namespace
    with no result.

    After reading much of the posts I came to know that using OpenXML Formats I can get to the solution much easily.
    I wanted to create this digital signature in the document dynamically from programming. I have that, much of the post are explaining how to validate the Signatures through the code using Open XML Formats, but I want to create a Signature Line in my document by Programmatic approach using C#.

    Please provide a solution or any respective link from which i could try out to reach for solution.

    Thank You,
    With Regards,
    Raj...
    Tuesday, June 16, 2009 11:47 AM

All replies

  • Hi Raj,

    For your problem, I strongly recommend the Document Reflector tool with SDK to generate the C# code for you. You firstly generate the document you expect via app, then open it in Document Reflector. You can see how to generate such document programmatically in C#. Baiscally, you need to add a new SignatureLine object and leverage DrawingML to genereate the look of the signature line.
    Try the tools, it will ease your learning curve.

    Besides, could you tell me why do you need to add the signature line to your documents? how about the whole user scenario? and what's the data/content in the documents? what's the purpose of the documents (print, archive, download...)? I'm interested in what solution are you building with SDK, any information will be helpful. Thanks!

    Shuangshuang (MS)
    Wednesday, June 17, 2009 10:34 AM
  • Hi Shuang,

    Thank You so much for replying my thread. Sorry for late reply, since i was in tour these days so didn't get time to check out my threads. As u suggested I have also used Document Reflector and found the it gives huge amount of code in which all the XML tags are built that to just for a single Signature Line and I am fully confused with that code. No Idea where to start with.

    Specification:
    Actually the document consists of a Table with two columns and also a section which has data in it. One of the columns in the Table is Signatures and the Other is User Name. This document (ie .docx file) I use it as a Template for my application.

    Requirement:
    Client wants a program in which he will select the User's and click the button, (say suppose he has selected 3 users) now the document should make a copy of the above Template and generate three rows dynamically by inserting there user names in the specified column and also create there Signature Lines in the respective column and save the document for further processing.

    I could able to dynamically create the specified number of rows and also could able to add the username's in the respective column but Creating a Digital Signature Dynamically through programming is still a mystery.

    If you have any suggestions regarding my problem please do reply my post. Thank you in Advance...

    Thank You,
    With Regards,
    Raj...
    Monday, June 22, 2009 10:31 AM
  • Hi Ankush,

    Thank You so much for replying my thread. Sorry for late reply, since i was in tour these days so didn't get time to check out my threads.

    I have seen your Post early back and its excellent and I have learned how to sign a document dynamically through program. Due to your post i could able to complete the next part of my application successfully. I think you the right person who can help me out of this problem. Thank you so much for the post.

    Your post explains how to sign the document through code If a signature Line is create using Office 2007 interface. Here I wanted to create a Signature Line in a document without Signing the Signature.

    Details:

    Specification:
    Actually the document consists of a Table with two columns and also a section which has data in it. One of the columns in the Table is Signatures and the Other is User Name. This document (ie .docx file) I use it as a Template for my application.

    Requirement:
    Client wants a program in which he will select the User's and click the button, (say suppose he has selected 3 users) now the document should make a copy of the above Template and generate three rows dynamically by inserting there user names in the specified column and also create there Signature Lines in the respective column and save the document for further processing.

    I could able to dynamically create the specified number of rows and also could able to add the username's in the respective column but Creating a Digital Signature Dynamically through programming is still a mystery.

    If you have any suggestions regarding my problem please do reply my post. Thank you in Advance...


    Thank You,
    With regards,
    Raj...



    Monday, June 22, 2009 10:42 AM
  • Hi Raj,

    Here are my suggestions based on your requirnment.

    a. You need to use VML in order to create the SignatureLine programmatically. For this, please create a document with 2-3 SignatureLine in it and then analyze the document.xml.  Basically for creating a SignatureLine, you need the following:

     

    <w:p w:rsidR="00A7304C" w:rsidRDefault="00664E1A">

          <w:r>

            <w:pict>

              <v:shape id="_x0000_i1025" type="#_x0000_t75" alt="Microsoft Office Signature Line..." style="width:192pt;height:96pt">

                <v:imagedata r:id="rId4" o:title=""/>

                <o:lock v:ext="edit" ungrouping="t" rotation="t" cropping="t" verticies="t" text="t" grouping="t"/>

                <o:signatureline v:ext="edit" id="{FB27DB93-6018-45D5-AFE9-D0D2F8C80A3F}" provid="{00000000-0000-0000-0000-000000000000}" o:suggestedsigner="test1" o:suggestedsigner2="test2" o:suggestedsigneremail="test3" issignatureline="t"/>

              </v:shape>

            </w:pict>

          </w:r>

        </w:p>

    Where <v:imagedata r:id="rId4" o:title=""/> tag defines the image to be shown on the SignatureLine. This is done via a relationship to an image.

     

    In the  o:signatureline tag, you can replace the suggestedsigner and orther values to match yours.

    So basically, open the package and insert the above XML in document.xml in order to insert a SignatureLine.

    Have a look at this for more information:

    http://msdn.microsoft.com/en-us/library/documentformat.openxml.vml.office.signatureline(office.14).aspx

    Please note that if you would like to have more than 1 SignatureLine in the document, and then please make sure that value of the ID tag is unique for the Signatures in the document.xml.

    Other Suggestions:

    • If you are not doing this from ASP.NET or from a Windows Service then you can automate Word to create a SignatureLine (ActiveDocument.Signatures.AddSignatureLine). Please note that automating Word,Excel or any Office applications from an un-attended mode is not recommended. Please have a look at this for more information http://support.microsoft.com/kb/257757
    • If you have created a template, please have a SignatureLine in the template and then based on the requirement, you can copy the XML and change the GUID to create more.

    HTH,
    Ankush

     

     

    Monday, June 22, 2009 8:07 PM
  • Hi Ankush,

    I think this information which you have posted me is most valuable to attain the solution to my problem, I am very glad, thank you so much Ankush. I will have a complete time on this and see that I will complete my task. After I complete my task I will post the solution with code for reference. In this due course if I come across any problems I will feel free to post it.

    Once again thank you so much Ankush for your time and kindness. Have a great day...

    Thank You,
    With Regards,
    Raj...
    Tuesday, June 23, 2009 6:06 AM