When I use the insertDocument in aspose it shows like this:
[//one extra empty line is added by default
line1
line2
line3
line4
line5]
and I have a bookmark between “[” “]” I need that bookmark, once I use builder.currentparagraph.remove() to delete the empty line the bookmark will be gone.
How can I maintain the bookmark?
Thanks for your inquiry. Please note that DocumentBuilder.InsertDocument method mimics the MS Word behavior, as if CTRL+‘A’ (select all content) was pressed, then CTRL+‘C’ (copy selected into the buffer) inside one document and then CTRL+‘V’ (insert content from the buffer) inside another document.
It would be great if you please share following detail for investigation purposes.
Please attach your input Word documents.
Please create a standalone/runnable simple application (for example a Console Application Project) that demonstrates the code (Aspose.Words code) you used to generate your output document
Please attach the output Word file that shows the undesired behavior.
Please attach your target Word document showing the desired behavior. You can use Microsoft Word to create your target Word document. I will investigate as to how you are expecting your final document be generated like.
Unfortunately, it is difficult to say what the problem is without the Document(s) and simplified application. We need your Document(s) and simple project to reproduce the problem. As soon as you get these pieces of information to us we’ll start our investigation into your issue.
I attach the project, you can see the documents folder that contain the input, the template, the output of the project and the desiredoutput please check the code and let me know what to do to remove the starting extra line and maintain the bookmark ‘bookmark1’ I have aspose version 14.6.0.0
Thanks for sharing the document. Please use following code example to achieve your requirements. Hope this helps you. Please let us know if you have any more queries.
Module Module1
Public docReport As Document
Public InputDoc As Document
Public Builder As DocumentBuilder
Public BuilderInputDoc As DocumentBuilder
Sub Main()
Dim lic = New License()
lic.SetLicense("Aspose.Total.lic")
Dim path = IO.Path.Combine(IO.Path.GetDirectoryName(Application.ExecutablePath), "..\..\documents")
docReport = New Document(path & "\template1.docx")
InputDoc = New Document(path & "\input.docx")
Builder = New DocumentBuilder(docReport)
BuilderInputDoc = New DocumentBuilder(InputDoc)
BuilderInputDoc.MoveToDocumentEnd()
BuilderInputDoc.StartBookmark("bm_end")
BuilderInputDoc.EndBookmark("bm_end")
Dim bmk = docReport.Range.Bookmarks("bookmark1")
Builder.MoveTo(bmk.BookmarkStart)
Builder.InsertDocument(InputDoc, ImportFormatMode.KeepSourceFormatting)
Builder.MoveToBookmark("bm_end")
If Not Builder.CurrentParagraph.NextSibling Is Nothing And Builder.CurrentParagraph.NextSibling.ToString(SaveFormat.Text).Trim() = "" Then
Builder.CurrentParagraph.NextSibling.Remove()
End If
docReport.Save(path & "\output.docx")
End Sub
End Module
Thanks for your inquiry. The DocumentBuilder.InsertDocument method was introduced in Aspose.Words v15.3.0. Please check the public API changes from following link. Public API Changes in Aspose.Words 15.3.0
We suggest you please upgrade to the latest version of Aspose.Words for .NET 15.10.0 and let us know if you have any more queries.
Thank you. I will try to update to the latest version. I also found that adding new editable ranges is now supported with that version which is good.
I have a question. does aspose have an editor I mean word processing editor. so we can open the document using aspose and edit the editable range.
Thanks for your inquiry. Aspose.Words for .NET is a class library that enables your applications to perform a great range of document processing tasks. So, it does not offer any UI or web control for performing these document processing tasks on web page.
Our sister company GroupDocs.com offers a viewer app which you may consider including in your application to view the various file formats. With GroupDocs apps, you can also have limited editing functionalities. For more information, we suggest you please contact GroupDocs support through live chat or support forums of GroupDocs.
@rzeylah Could you please elaborate what features you are interested in? 14.6 version of Aspose.Words has been released about 10 years ago. There were a lot of fixes and improvements made since then. You can find the changes in our release notes: https://releases.aspose.com/words/net/release-notes/
About 120 new versions have been released since 14.6 version.
You can use Aspose.Words in .NET6 starting from 17.12 version. Starting from this version .NET Standard 2.0 version of Aspose.Words is provided. Since .NET6 is an implementation of .NET Standard 2.0, you can use 17.12 version with it. Bu I suggest you to update to the latest 24.2 version of Aspose.Words to get all new features and improvements we have made to the product.