简体   繁体   中英

how to insert caption to table and figure in aspose.word

我想创建一个图形表和一个表表,但是第一个表和图应该有标题才能识别。我需要在表和图上插入标题

Please try using the following code.

Document doc = new Document(MyDir + "in.docx"); 
DocumentBuilder builder = new DocumentBuilder(doc);

builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;

// Insert caption above the Table
builder.MoveTo(doc.FirstSection.Body.Tables[0].PreviousSibling);
builder.Write("Table: ");
builder.InsertField(@"SEQ Table \* ARABIC", "");

// Insert caption below the Figure
builder.MoveToDocumentEnd();
builder.InsertParagraph();
builder.Write("Figure: ");
builder.InsertField(@"SEQ Figure \* ARABIC", "");

doc.UpdateFields();

doc.Save(MyDir + @"17.11.docx");

I work with Aspose as Developer Evangelist.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM