Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alignment of nested lists breaks across pages #108

Closed
RyanCarroll7 opened this issue Jan 7, 2025 · 2 comments
Closed

Alignment of nested lists breaks across pages #108

RyanCarroll7 opened this issue Jan 7, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@RyanCarroll7
Copy link

Describe the bug
When a nested list spans a page boundary, the indentation is reset. This causes the nested items to be unaligned from each other.

To Reproduce
Steps to reproduce the behavior:

  1. Place an IContainer.Markdown() element that contains a long, nested list on a document
    Example string (uses QuestPDF.Helpers.Placeholders): textExample.txt
  2. Generate and view the document

Expected behavior
The indentation of each level of the nested list should persist across page boundaries.

Screenshots
example
(The items that should be aligned are connected by the colored lines)

Environment (please complete the following information):

  • OS and version: Windows 11 24H2
  • OS Platform: x64
  • QuestPDF Version: 2024.12.2
  • QuestPDF.Markdown Version: 1.28.0

Additional context
The root cause of the problem seems to be that the width of AutoItem does not persist across pages. This can be seen in the Companion App: cause

@RyanCarroll7 RyanCarroll7 added the bug Something isn't working label Jan 7, 2025
@christiaanderidder
Copy link
Owner

Hi @RyanCarroll7

I had a look at the problem and the same issue seems to occur when only using QuestPDF itself and building a list as suggested in the QuestPDF docs:

var doc = Document.Create(container =>
{
    container.Page(page =>
    {
        page.Size(PageSizes.A4);
        page.Margin(1, Unit.Centimetre);
        page.DefaultTextStyle(text =>
        {
            text.FontFamily(Fonts.Arial);
            text.LineHeight(1.5f);
            return text;
        });

        page.Content()
            .PaddingVertical(20)
            .Column(main =>
            {
                main.Spacing(20);
                main.Item()
                    .Column(c1 =>
                    {
                        foreach (var i in Enumerable.Range(1, 5))
                        {
                            c1.Item().Row(r1 =>
                            {
                                r1.Spacing(5);
                                r1.AutoItem().Text($"{i}."); // text or image
                                r1.RelativeItem().Column(c2 =>
                                {
                                    foreach (var j in Enumerable.Range(1, 15))
                                    {
                                        c2.Item().Row(r2 =>
                                        {
                                            r2.Spacing(5);
                                            r2.AutoItem().Text($"{j}."); // text or image
                                            r2.RelativeItem().Text(Placeholders.Sentence());
                                        });
                                    }
                                });
                            });
                        }
                    });
            });
    });
});
companion

You are indeed correct that the problem is the AutoItem not retaining its width across the page boundary, but I think this might be an issue with QuestPDF itself.

@christiaanderidder
Copy link
Owner

I've submitted an issue on the QuestPDF repository, you can find it here: QuestPDF/QuestPDF#1091

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants