Create bookmark "ex novo"

Posted by: old_lore on 16 September 2017, 8:36 am EST

    • Post Options:
    • Link

    Posted 16 September 2017, 8:36 am EST

    good morning.

    in my project I must add some data marked by bookmark in word documents. The documents changes, and so I cannot construct a “skeleton” with the bookmark I need.

    Can I add bookmark to the body of document regardless of word initial document? do you have some sample?

    I work with VS2015 / win10 (vb.net)

    thank you

  • Posted 16 September 2017, 8:36 am EST

    Hi,

    You can add bookmarks in a word document using the AddBookmark, AddBookmarkStart and AddBookmarkEnd methods. You can learn more about them from the Public Methods section in the below documentation link:

    http://helpcentral.componentone.com/nethelp/C1wordWin/C1.C1Word.4~C1.C1Word.C1WordDocument_members.html

    To make a bookmark to have text “ex novo”, you may traverse C1Word’s MainSection.Content to check if the current text is “RtfBookmarkStart” or “RtfBookmarkEnd” and then, add the text accordingly. A sample has been attached for your reference.

    We are a little unsure about this: “Can I add bookmark to the body of document regardless of word initial document?”. In case the provided solution does not meet your requirements, we request you to explain your use case in detail, so that we can assist you further.

    Regards,

    Esha

    2017/07/prj_C1Word_Bookmark.zip

  • Posted 16 September 2017, 8:36 am EST

    Thank you for your answer. I have tried your sample, and it add bookmark… but lose header and footer. I send you my sample docx (“vuota.docx”) and the result of the program test (“simple.docx”). I have two other question: as You can see in my “Button1_click”, I have tried to change font style, but this means to add a new paragraph. can I chang font without add paragraph (paragraphs adds lines). the other question is e curiosity: why “addparagraph” doesn’t add the markers like “addbookmarkstart” and “Addbookmarkend”?

    Thank again for you patience.

    2017/07/vuota.docx

    2017/07/simple.docx

    2017/07/button1_click.txt

  • Posted 16 September 2017, 8:36 am EST

    Hi,

    We are discussing your requirements with the developers and will get back to you once we hear from them.

    Regards,

    Esha

  • Posted 16 September 2017, 8:36 am EST

    Hi,

    1. You can change font for an existing paragraph using the below code snippet:
    
    For Each obj In C1WordDocument1.MainSection.Header
      Dim paragraph As RtfParagraph = TryCast(obj, RtfParagraph)
      If Not paragraph Is Nothing Then
        paragraph.Font = font
      End If
    Next
    
    

    You may also use a paragraph context (RtfString objects).

    1. AddParagraph method not adding the markers is a limitation as of now.

    Regards,

    Esha

  • Posted 16 September 2017, 8:36 am EST

    Ok, thank you, but what about the disappearing of header / footer? FYI, i recall the problem: I have some documents, with header and/or footer. I must insert some bookmarks in these, some of this with different font (Bcode, for example). When I have opened the results doc, header / footer has gone… Thank You again. NB - in my previous post there are my tests

  • Posted 16 September 2017, 8:36 am EST

    Hi,

    In your sample, bookmark text “ex novo” is not shown in the output because it is covered with the image “La Presidente” in the “vuota.docx”. Please refer to the attached output file for more clarity.

    Regards,

    Esha

    2017/08/output.docx

  • Posted 10 October 2019, 9:57 pm EST

    Hello,

    The following issues are fixed:

    -Exception is not thrown when click the “Create Document” button in the sample.

    -Bookmark text “ex novo” is shown in output “simple.docx”.

    You can use the following builds to test the same:

    http://prerelease.componentone.com/dotnet40/c1winforms/2017-t3/C1WinForms.4_4.0.20173.291.zip

    http://prerelease.componentone.com/dotnet40/c1winforms/2019-t2/C1WinForms.4_4.0.20192.375.zip

    Thanks,

    Esha

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels