We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Inserting RTF in document adds extra line

When I add RTF text to a word document I always get an extra line before the start of the inserted rtf text.
Please run attached sample program to see problem.

Thomas

Hi Thomas,


Please try using the following code:

Dim rtf As New Document(MyDir & “rtfstr.rtf”)

Dim doc As New Document()

Dim builder As New DocumentBuilder(doc)

builder.Writeln("Hello World!, RTF is inserted")

builder.Writeln("Another line of text")

builder.InsertDocument(rtf, ImportFormatMode.KeepSourceFormatting)

doc.Save(MyDir & "16.12.0.docx")


Best regards,

this basically works.
but I now get an extra newline after the richttext.

now I get this:


before that I had this:



Thanks

Hi Thomas,


Please add following line before calling Save method:

doc.LastSection.Body.LastParagraph.Remove()

<o:p></o:p>


Best regards,

I’m inserting RTF into table cells.
In this case I had to do this:
builder.MoveTo(builder.CurrentParagraph.PreviousSibling)
builder.CurrentParagraph.NextSibling.Remove()

Is this correct?


Thomas

Hi Thomas,


Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document
  • Aspose.Words generated output DOCX file showing the undesired behavior
  • Please attach your expected document here for our reference. We will investigate the structure of your expected document as to how you want your final output be generated like. You can create expected document using Microsoft Word.
  • Please create a standalone console application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click ‘Reply’ button that will bring you to the ‘reply page’ and there at the bottom you can include any attachments with that post by clicking the ‘Add/Update’ button.

Best regards,