Guest User

Untitled

a guest
Jun 24th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. Document rtfFile = new Document(@"C:ToolsdocwithTextBox.rtf");
  2. DocumentBuilder builder = new DocumentBuilder(rtfFile);
  3. var nodes = rtfFile.GetChildNodes(NodeType.Shape, true);
  4. foreach (Shape shape in nodes)
  5. {
  6.  
  7. if (shape.ShapeType == ShapeType.TextBox)
  8. {
  9. var width = shape.Width;
  10. var height = shape.Height;
  11. string text = shape.GetText();
  12. builder.MoveTo(shape);
  13.  
  14. shape.Remove();
  15.  
  16. Aspose.Words.Tables.Table table = builder.StartTable();
  17. Cell cell = builder.InsertCell();
  18. builder.Write(text);
  19. builder.RowFormat.Height = height;
  20. builder.RowFormat.HeightRule = HeightRule.Exactly;
  21. table.PreferredWidth = PreferredWidth.FromPoints(width);
  22. builder.EndRow();
  23. builder.EndTable();
  24. }
  25. }
  26. rtfFile.Save(@"C:ToolsdocwithTextBox.rtf");
Add Comment
Please, Sign In to add comment