Hi Daniel,
You could do that by adding the inner TextBox
to Paragraph
which you could then add to the outer TextBox.Blocks
.
However, note that this will only work for the output PDF files, Word files don’t support having TextBox
elements inside the TextBox
element.
Anyway, try this:
var document = new DocumentModel();
document.DefaultParagraphFormat.SpaceAfter = 0;
var section = new Section(document);
document.Sections.Add(section);
var outerTextBox = new TextBox(document,
Layout.Inline(new Size(400, 120)), ShapeType.RoundedRectangle);
section.Blocks.Add(new Paragraph(document, outerTextBox));
outerTextBox.AdjustValues.Add("adj", 4600);
outerTextBox.Fill.SetSolid(Color.Blue);
outerTextBox.Blocks.Add(
new Paragraph(document,
new Run(document, "IT Service")
{ CharacterFormat = { FontColor = Color.White } }));
outerTextBox.Blocks.Add(
new Paragraph(document,
new Run(document, "3.1.VDI")
{ CharacterFormat = { FontColor = Color.White, Size = 18, Bold = true } }));
var innerTextBox = new TextBox(document,
Layout.Inline(new Size(382, 65)), ShapeType.RoundedRectangle);
outerTextBox.Blocks.Add(new Paragraph(document, innerTextBox));
innerTextBox.AdjustValues.Add("adj", 4600);
var innerParagraph = new Paragraph(document);
innerTextBox.Blocks.Add(innerParagraph);
innerParagraph.ParagraphFormat.Tabs.Add(new TabStop(80, TabStopAlignment.Right));
innerParagraph.ParagraphFormat.Tabs.Add(new TabStop(90, TabStopAlignment.Left));
innerParagraph.Inlines.Add(new SpecialCharacter(document, SpecialCharacterType.Tab));
innerParagraph.Inlines.Add(new Run(document, "Description:") { CharacterFormat = { Bold = true } });
innerParagraph.Inlines.Add(new SpecialCharacter(document, SpecialCharacterType.Tab));
innerParagraph.Inlines.Add(new Run(document, "End User Computing"));
innerParagraph = new Paragraph(document);
innerTextBox.Blocks.Add(innerParagraph);
innerParagraph.ParagraphFormat.Tabs.Add(new TabStop(80, TabStopAlignment.Right));
innerParagraph.ParagraphFormat.Tabs.Add(new TabStop(90, TabStopAlignment.Left));
innerParagraph.Inlines.Add(new SpecialCharacter(document, SpecialCharacterType.Tab));
innerParagraph.Inlines.Add(new Run(document, "Recovery Order:") { CharacterFormat = { Bold = true } });
innerParagraph.Inlines.Add(new SpecialCharacter(document, SpecialCharacterType.Tab));
innerParagraph.Inlines.Add(new Run(document, "25"));
innerParagraph = new Paragraph(document);
innerTextBox.Blocks.Add(innerParagraph);
innerParagraph.ParagraphFormat.Tabs.Add(new TabStop(80, TabStopAlignment.Right));
innerParagraph.ParagraphFormat.Tabs.Add(new TabStop(90, TabStopAlignment.Left));
innerParagraph.Inlines.Add(new SpecialCharacter(document, SpecialCharacterType.Tab));
innerParagraph.Inlines.Add(new Run(document, "Mtpd:") { CharacterFormat = { Bold = true } });
innerParagraph.Inlines.Add(new SpecialCharacter(document, SpecialCharacterType.Tab));
innerParagraph.Inlines.Add(new Run(document, "02:00 hours"));
document.Save("output.pdf");
Here is the resulting PDF:
I hope this helps.
Regards,
Mario