Beispiel #1
0
        public void TextElements()
        {
            RenderingTest
            .Create()
            .PageSize(PageSizes.A4)
            .ProducePdf()
            .ShowResults()
            .Render(container =>
            {
                container
                .Padding(20)
                .Padding(10)
                .MinimalBox()
                .Border(1)
                .Padding(5)
                .Padding(10)
                .Text(text =>
                {
                    text.DefaultTextStyle(TextStyle.Default);
                    text.AlignLeft();
                    text.ParagraphSpacing(10);

                    text.Line(Placeholders.LoremIpsum());

                    text.Span($"This is target text that should show up. {DateTime.UtcNow:T} > This is a short sentence that will be wrapped into second line hopefully, right? <").Underline();
                });
            });
        }
Beispiel #2
0
        public void BreakingLongWord()
        {
            RenderingTest
            .Create()
            .ProduceImages()
            .ShowResults()
            .RenderDocument(container =>
            {
                container.Page(page =>
                {
                    page.Margin(50);
                    page.PageColor(Colors.White);

                    page.Size(PageSizes.A4);

                    page.Content().Column(column =>
                    {
                        column.Item().Text(null);

                        column.Item().Text(text =>
                        {
                            text.DefaultTextStyle(x => x.BackgroundColor(Colors.Red.Lighten3).FontSize(24));

                            text.Span("       " + Placeholders.LoremIpsum());
                            text.Span(" 0123456789012345678901234567890123456789012345678901234567890123456789         ").WrapAnywhere();
                        });
                    });
                });
            });
        }
Beispiel #3
0
        public void Example()
        {
            RenderingTest
            .Create()
            .PageSize(300, 250)
            .ProduceImages()
            .ShowResults()
            .Render(container =>
            {
                container
                .Padding(25)
                .DefaultTextStyle(TextStyle.Default.Size(14))
                .Decoration(decoration =>
                {
                    decoration
                    .Before()
                    .Text(text =>
                    {
                        text.DefaultTextStyle(TextStyle.Default.SemiBold().Color(Colors.Blue.Medium));

                        text.Span("Page ");
                        text.CurrentPageNumber();
                    });

                    decoration
                    .Content()
                    .Column(column =>
                    {
                        column.Spacing(25);
                        column.Item().StopPaging().Text(Placeholders.LoremIpsum());
                        column.Item().ExtendHorizontal().Height(75).Background(Colors.Grey.Lighten2);
                    });
                });
            });
        }
Beispiel #4
0
        public void EnsureSpaceWith()
        {
            RenderingTest
            .Create()
            .ProduceImages()
            .ShowResults()
            .RenderDocument(container =>
            {
                container.Page(page =>
                {
                    page.Margin(20);
                    page.Size(PageSizes.A7.Landscape());
                    page.PageColor(Colors.White);

                    page.Header().Text("With ensure space").SemiBold();

                    page.Content().Column(column =>
                    {
                        column
                        .Item()
                        .ExtendHorizontal()
                        .Height(75)
                        .Background(Colors.Grey.Lighten2);

                        column
                        .Item()
                        .EnsureSpace(100)
                        .Text(Placeholders.LoremIpsum());
                    });

                    page.Footer().Text(text =>
                    {
                        text.Span("Page ");
                        text.CurrentPageNumber();
                        text.Span(" out of ");
                        text.TotalPages();
                    });
                });
            });
        }
Beispiel #5
0
        public void MinimalApi()
        {
            Document
            .Create(container =>
            {
                container.Page(page =>
                {
                    page.Size(PageSizes.A4);
                    page.Margin(2, Unit.Centimetre);
                    page.PageColor(Colors.White);
                    page.DefaultTextStyle(x => x.FontSize(20));

                    page.Header()
                    .Text("Hello PDF!")
                    .SemiBold().FontSize(36).FontColor(Colors.Blue.Medium);

                    page.Content()
                    .PaddingVertical(1, Unit.Centimetre)
                    .Column(x =>
                    {
                        x.Spacing(20);

                        x.Item().Text(Placeholders.LoremIpsum());
                        x.Item().Image(Placeholders.Image(200, 100));
                    });

                    page.Footer()
                    .AlignCenter()
                    .Text(x =>
                    {
                        x.Span("Page ");
                        x.CurrentPageNumber();
                    });
                });
            })
            .GeneratePdf("hello.pdf");

            Process.Start("explorer.exe", "hello.pdf");
        }
Beispiel #6
0
        public void SpaceIssue()
        {
            RenderingTest
            .Create()
            .PageSize(PageSizes.A4)
            .ProducePdf()
            .ShowResults()
            .Render(container =>
            {
                container
                .Padding(20)
                .Padding(10)
                .MinimalBox()
                .Border(1)
                .Padding(5)
                .Padding(10)
                .Text(text =>
                {
                    text.DefaultTextStyle(x => x.Bold());

                    text.DefaultTextStyle(TextStyle.Default);
                    text.AlignLeft();
                    text.ParagraphSpacing(10);

                    text.Span(Placeholders.LoremIpsum());

                    text.EmptyLine();

                    text.Span("This text is a normal text, ");
                    text.Span("this is a bold text, ").Bold();
                    text.Span("this is a red and underlined text, ").FontColor(Colors.Red.Medium).Underline();
                    text.Span("and this is slightly bigger text.").FontSize(16);

                    text.EmptyLine();

                    text.Span("The new text element also supports injecting custom content between words: ");
                    text.Element().PaddingBottom(-4).Height(16).Width(32).Image(Placeholders.Image);
                    text.Span(".");

                    text.EmptyLine();

                    text.Span("This is page number ");
                    text.CurrentPageNumber();
                    text.Span(" out of ");
                    text.TotalPages();

                    text.EmptyLine();

                    text.Hyperlink("Please visit QuestPDF website", "https://www.questpdf.com");

                    text.EmptyLine();

                    text.Span(Placeholders.Paragraphs());


                    text.EmptyLine();

                    text.Span(Placeholders.Paragraphs()).Italic();

                    text.Line("This is target text that does not show up. " + Placeholders.Paragraph());
                });
            });
        }