I am trying to create a PDF using QuestPDF. I need to design the first page with two columns. First column show only in first page and second column to extend to next page and become full width. I try the code below but I don’t know how to break page after fill first page and continue with the rest of articles in the second page.
The code I used to generate the pdf.
using QuestPDF.Fluent;
using QuestPDF.Helpers;
using QuestPDF.Previewer;
namespace AcademicPlatform.Web.Services;
public class GeneratePdfQuestPdf
{
public void CreateAndPreviewer(List<string> articles)
{
Document.Create(container =>
{
container.Page(page =>
{
page.Size(PageSizes.A4);
page.Content().Row(row =>
{
// Left Column
row.ConstantItem(220).ShowOnce().Background("#163853").Padding(20).Column(leftColumn =>
{
leftColumn.Item().Text("Left Column Content");
});
// Right Column
row.RelativeItem()
// .ShowIf(x => x.PageNumber == 1)
.Padding(20).Column(rightColumn =>
{
rightColumn.Item().Column(col =>
{
int i = 1;
foreach (var item in articles)
{
col.Item().Row(row =>
{
row.RelativeItem().ShowEntire().Text($"{i++}- {item}").FontSize(14).Bold();
});
col.Item().ShowEntire().PaddingVertical(2).LineHorizontal(0.5f).LineColor("#1F3C88");
}
});
});
});
;
});
}).ShowInPreviewer();
}
}
public class Program
{
public static void Main()
{
QuestPDF.Settings.License = LicenseType.Community;
var articles = Enumerable.Range(1, 40).Select(i => $"Article {i}").ToList();
GeneratePdfQuestPdf generatePdfQuestPdf = new GeneratePdfQuestPdf();
generatePdfQuestPdf.CreateAndPreviewer(articles);
}
}
The generated pdf is show as: