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

Free Support Forum - aspose.com

Troubles with word document format


I’m having troubles with tables and their formats when receiving the word document, kept at the database as binary, again.

You can find the original version of the document as attached (original.doc). After getting a saved version of the document from the database, I add another title and convert it to word again. The codes I used for this operation is below and the document after getting a print out is as attached. (Printed.doc)

Document newdoc = new Document();
Section section = new Section(newdoc);
section.PageSetup.SectionStart = SectionStart.NewPage;
section.PageSetup.PaperSize = PaperSize.Letter;
Body body = new Body(newdoc);
Paragraph para = new Paragraph(newdoc);
Run run = new Run(newdoc);
run.Text = “<1>”;

binaryContext = dr.Reader[“BINARYCONTEXT”] as byte[];

if (binaryContext != null)
newdoc.Document.Range.Replace(new System.Text.RegularExpressions.Regex(@"<" + “1” + “\>”), new ReplaceEvaluatorFindAndHighlight(), false);
currentNode = Rapor.currentNode;

System.IO.MemoryStream ms = new System.IO.MemoryStream(binaryContext);
ms.Position = 0;
Document doc = new Document();
if (binaryContext.Length != 0)
doc = new Document(ms);

this.InsertDocument(currentNode.ParentNode, doc);

Document docx = new Document();
Section section = new Section(docx);
section.PageSetup.SectionStart = SectionStart.Continuous;
section.PageSetup.PaperSize = PaperSize.A4;
Body body = new Body(docx);
Paragraph para = new Paragraph(docx);
Run run = new Run(docx);
//run.Text = lblBaslik.Text;
run.Font.Bold = true;


this.InsertDocument(currentNode.ParentNode, docx);


public class ReplaceEvaluatorFindAndHighlight : IReplacingCallback
ReplaceAction IReplacingCallback.Replacing(ReplacingArgs e)
Rapor.currentNode = e.MatchNode;

return ReplaceAction.Skip;


As you can see from the screenshot as atteched “BeforeAndAfter.png”, the text on the table is shown beside the table after getting a print-out.

And the title and the table that are supposed to appear on page 3 are shown separately on different pages.

I need your urgent help on the issue.

Hi Ahmet,

Thanks for your inquiry. I suggest you please use the ImportFormatMode as UseDestinationStyles in InsertDocument method. In case you are using an older version of Aspose.Words, I would suggest you please upgrade to the latest version (v13.7.0) from here and let us know how it goes on your side.

If you still face problem, please create a simple application (for example a Console Application Project) that helps us reproduce the same problem on our end and attach it here for testing. Unfortunately, I am unable to execute your code. As soon as you get these pieces of information to us we’ll start our investigation into your issue.