Hi there,
My apologies for another “Auto” spacing related issue, but this is unfortunately a requirement for the legacy document rendering system I am migrating. The issue I’ve just encountered is that GemBox does not render list items with ParagraphFormat.SpaceAfterAuto = true in the same manner as Word. In Word, when two lists of different styles are adjacent, Word intelligently inserts space between the two lists, however GemBox does not. I’ve attached a reproduction below, with some screenshots. Note that while this is the particular bug I experienced, there are likely other cases where Word’s behavior differs.
using GemBox.Document;
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
var doc = new DocumentModel();
var section = new Section(doc);
doc.Sections.Add(section);
var blocks = section.Blocks;
doc.DefaultParagraphFormat.SpaceAfterAuto = true;
ListStyle bulletList = new ListStyle(ListTemplateType.Bullet);
ListStyle numberedList = new ListStyle(ListTemplateType.NumberWithDot);
// Bulleted List
blocks.Add(new Paragraph(doc, "First item.")
{
ListFormat = { Style = bulletList }
});
blocks.Add(new Paragraph(doc, "Second item.")
{
ListFormat = { Style = bulletList, ListLevelNumber = 1 }
});
blocks.Add(new Paragraph(doc, "Third item.")
{
ListFormat = { Style = bulletList }
});
// Numbered List
blocks.Add(new Paragraph(doc, "First item.")
{
ListFormat = { Style = numberedList }
});
blocks.Add(new Paragraph(doc, "Second item.")
{
ListFormat = { Style = numberedList, ListLevelNumber = 1 }
});
blocks.Add(new Paragraph(doc, "Third item.")
{
ListFormat = { Style = numberedList }
});
blocks.Add(new Paragraph(doc));
doc.Save("test.docx");
doc.Save("test.pdf");
Thank you in advance for your assistance.
Best,
Michael
Hi Michael,
Please try again with this NuGet package:
Install-Package GemBox.Document -Version 2025.10.103
Does this solve your issue?
Regards,
Mario
Hi Mario,
That did resolve the original issue, but it uncovered a related issue within the same document. I have a slightly more contrived example to demonstrate the new issue being encountered, which involves the behavior of the ParagraphFormat.SpaceAfterAuto property within table cells. It looks like there should be padding after the last paragraph in a table cell with auto spacing, but GemBox does not behave this way.
using GemBox.Document;
using GemBox.Document.Tables;
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
var doc = new DocumentModel();
var section = new Section(doc);
doc.Sections.Add(section);
var cell = new TableCell(doc);
var row = new TableRow(doc, cell);
var table = new Table(doc, row);
section.Blocks.Add(table);
var blocks = cell.Blocks;
doc.DefaultParagraphFormat.SpaceAfterAuto = true;
ListStyle bulletList = new ListStyle(ListTemplateType.Bullet);
ListStyle numberedList = new ListStyle(ListTemplateType.NumberWithDot);
// Bulleted List
blocks.Add(new Paragraph(doc, "First item.")
{
ListFormat = { Style = bulletList }
});
blocks.Add(new Paragraph(doc, "Second item.")
{
ListFormat = { Style = bulletList, ListLevelNumber = 1 }
});
blocks.Add(new Paragraph(doc, "Third item.")
{
ListFormat = { Style = bulletList }
});
// Numbered List
blocks.Add(new Paragraph(doc, "First item.")
{
ListFormat = { Style = numberedList }
});
blocks.Add(new Paragraph(doc, "Second item.")
{
ListFormat = { Style = numberedList, ListLevelNumber = 1 }
});
blocks.Add(new Paragraph(doc, "Third item.")
{
ListFormat = { Style = numberedList }
});
section.Blocks.Add(new Paragraph(doc, "Not within table"));
doc.Save("test.docx");
doc.Save("test.pdf");
Regards,
Michael
Hi Michael,
Please try again with this NuGet package:
Install-Package GemBox.Document -Version 2025.10.107
Does this solve your issue?
Regards,
Mario
Hi Mario,
That version fixes the issue. Thank you for your assistance!
Best,
Michael