Browse Source

Documentation examples: Page

Marcin Ziąbek 10 tháng trước cách đây
mục cha
commit
b821a010a5

+ 149 - 0
Source/QuestPDF.DocumentationExamples/PageExamples.cs

@@ -0,0 +1,149 @@
+using QuestPDF.Companion;
+using QuestPDF.Fluent;
+using QuestPDF.Helpers;
+using QuestPDF.Infrastructure;
+
+namespace QuestPDF.DocumentationExamples;
+
+public class PageExamples
+{
+    [Test]
+    public void Simple()
+    {
+        Document
+            .Create(document =>
+            {
+                document.Page(page =>
+                {
+                    page.Size(PageSizes.A5);
+                    page.Margin(2, Unit.Centimetre);
+                    page.DefaultTextStyle(x => x.FontSize(24));
+
+                    page.Header()
+                        .Text("Hello, World!")
+                        .FontSize(48).Bold();
+
+                    page.Content()
+                        .PaddingVertical(25)
+                        .Text(Placeholders.LoremIpsum())
+                        .Justify();
+        
+                    page.Footer()
+                        .AlignCenter() 
+                        .Text(text =>
+                        {
+                            text.CurrentPageNumber();
+                            text.Span(" / ");
+                            text.TotalPages();
+                        });
+                });
+            })
+            .GenerateImages(x => "page-simple.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
+    }
+    
+    [Test]
+    public void MainSlots()
+    {
+        Document
+            .Create(document =>
+            {
+                document.Page(page =>
+                {
+                    page.Size(PageSizes.A4);
+                    page.Margin(2, Unit.Centimetre);
+                    page.DefaultTextStyle(x => x.FontSize(24));
+
+                    page.Header()
+                        .Background(Colors.Grey.Lighten1)
+                        .Height(125)
+                        .AlignCenter()
+                        .AlignMiddle()
+                        .Text("Header");
+                    
+                    page.Content()
+                        .Background(Colors.Grey.Lighten2)
+                        .AlignCenter()
+                        .AlignMiddle()
+                        .Text("Content");
+                    
+                    page.Footer()
+                        .Background(Colors.Grey.Lighten1)
+                        .Height(75)
+                        .AlignCenter()
+                        .AlignMiddle()
+                        .Text("Footer");
+                });
+            })
+            .GenerateImages(x => "page-main-slots.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
+    }
+    
+    [Test]
+    public void Foreground()
+    {
+        Document
+            .Create(document =>
+            {
+                document.Page(page =>
+                {
+                    page.Size(PageSizes.A4);
+                    page.Margin(2, Unit.Centimetre);
+                    page.DefaultTextStyle(x => x.FontSize(20));
+
+                    page.Header()
+                        .PaddingBottom(1, Unit.Centimetre)
+                        .Text("Report")
+                        .FontSize(30)
+                        .Bold();
+                    
+                    page.Content()
+                        .Text(Placeholders.Paragraphs())
+                        .ParagraphSpacing(1, Unit.Centimetre)
+                        .Justify();
+ 
+                    page.Foreground().Svg("Resources/draft-foreground.svg").FitArea();
+                });
+            })
+            .GenerateImages(x => "page-foreground.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.High, RasterDpi = 144 });
+    }
+    
+    [Test]
+    public void Background()
+    {
+        Document
+            .Create(document =>
+            {
+                document.Page(page =>
+                { 
+                    page.Size(PageSizes.A4.Landscape());
+
+                    page.Background().Svg("Resources/certificate-background.svg").FitArea();
+
+                    page.Content() 
+                        .PaddingLeft(10, Unit.Centimetre)
+                        .PaddingRight(5 , Unit.Centimetre)
+                        .AlignMiddle()
+                        .Column(column =>
+                        {
+                            column.Item().Height(50).Svg("Resources/questpdf-logo.svg");
+                            
+                            column.Item().Height(50);
+                            
+                            column.Item().Text("CERTIFICATE").FontSize(64).ExtraBlack();
+                            
+                            column.Item().Height(25);
+                            
+                            column.Item()
+                                .Shrink().BorderBottom(1).Padding(10)
+                                .Text("Marcin Ziąbek").FontSize(32).Italic();
+                            
+                            column.Item().Height(10); 
+                            
+                            column.Item()
+                                .Text($"has successfully completed the course \"QuestPDF Basics\" on {DateTime.Now:dd MMM yyyy}.")
+                                .FontSize(20).Light();
+                        });
+                });
+            })
+            .GenerateImages(x => $"page-background.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.Best, RasterDpi = 144 });
+    }
+}

+ 26 - 0
Source/QuestPDF.DocumentationExamples/Resources/certificate-background.svg

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg width="100%" height="100%" viewBox="0 0 3508 2481" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
+    <g transform="matrix(0.881407,0,0,0.969742,335.337,50.1032)">
+        <path d="M3425.2,314.181L3425.2,2142.51C3425.2,2263.76 3316.89,2362.2 3183.49,2362.2L926.75,2362.2C793.346,2362.2 685.039,2263.76 685.039,2142.51L685.039,314.181C685.039,192.929 793.346,94.488 926.75,94.488L3183.49,94.488C3316.89,94.488 3425.2,192.929 3425.2,314.181Z" style="fill:url(#_Linear1);"/>
+    </g>
+    <g transform="matrix(0.998954,-0.0457311,0.0457311,0.998954,-156.94,12.3141)">
+        <path d="M-157,-152C-157,-152 309.775,-437.729 596,-213C1371.99,396.264 -543.556,1998.81 492,2592C1060.59,2917.7 -378,2605 -378,2605L-157,-152Z" style="fill:url(#_Linear2);"/>
+    </g>
+    <g transform="matrix(0.998954,-0.0457311,0.0457311,0.998954,-1006.37,-134.68)">
+        <circle cx="522" cy="2502" r="681" style="fill:url(#_Linear3);"/>
+    </g>
+    <g transform="matrix(0.998954,-0.0457311,0.0457311,0.998954,-377.749,-2540.94)">
+        <circle cx="522" cy="2502" r="681" style="fill:url(#_Linear4);"/>
+    </g>
+    <g transform="matrix(1.40843,-0.0644767,0.0644767,1.40843,524.262,-1279.09)">
+        <circle cx="-603" cy="1596" r="666" style="fill:url(#_Linear5);"/>
+    </g>
+    <defs>
+        <linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(2740.16,-2.32211e-13,1.85742e-13,3425.7,685.039,1155.97)"><stop offset="0" style="stop-color:rgb(226,226,226);stop-opacity:0"/><stop offset="1" style="stop-color:rgb(227,227,227);stop-opacity:1"/></linearGradient>
+        <linearGradient id="_Linear2" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1051.58,2434.77,-2434.77,-1051.58,1095.49,37.8235)"><stop offset="0" style="stop-color:rgb(0,229,255);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(41,121,255);stop-opacity:1"/></linearGradient>
+        <linearGradient id="_Linear3" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1051.58,2434.77,-2434.77,-1051.58,1937.31,223.509)"><stop offset="0" style="stop-color:rgb(0,229,255);stop-opacity:0.4"/><stop offset="1" style="stop-color:rgb(41,121,255);stop-opacity:0.4"/></linearGradient>
+        <linearGradient id="_Linear4" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1051.58,2434.77,-2434.77,-1051.58,1199.31,2598.51)"><stop offset="0" style="stop-color:rgb(0,229,255);stop-opacity:0.4"/><stop offset="1" style="stop-color:rgb(41,121,255);stop-opacity:0.4"/></linearGradient>
+        <linearGradient id="_Linear5" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-745.85,1726.9,-1726.9,-745.85,252.46,919.722)"><stop offset="0" style="stop-color:rgb(0,229,255);stop-opacity:0.4"/><stop offset="1" style="stop-color:rgb(41,121,255);stop-opacity:0.4"/></linearGradient>
+    </defs>
+</svg>

+ 38 - 0
Source/QuestPDF.DocumentationExamples/Resources/draft-foreground.svg

@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg width="100%" height="100%" viewBox="0 0 2481 3508" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
+    <g transform="matrix(0.707107,0.707107,-0.707107,0.707107,1544.52,-1262.46)">
+        <g transform="matrix(600,0,0,600,448.819,2125.98)">
+            <path d="M0.072,-0.716L0.336,-0.716C0.396,-0.716 0.441,-0.711 0.473,-0.702C0.515,-0.69 0.551,-0.668 0.581,-0.636C0.611,-0.605 0.633,-0.566 0.649,-0.52C0.665,-0.475 0.672,-0.418 0.672,-0.351C0.672,-0.292 0.665,-0.241 0.65,-0.199C0.632,-0.147 0.607,-0.104 0.574,-0.072C0.549,-0.048 0.515,-0.029 0.472,-0.015C0.44,-0.005 0.398,-0 0.344,-0L0.072,-0L0.072,-0.716ZM0.217,-0.595L0.217,-0.121L0.325,-0.121C0.365,-0.121 0.394,-0.123 0.412,-0.127C0.436,-0.133 0.455,-0.143 0.47,-0.157C0.486,-0.171 0.499,-0.194 0.508,-0.226C0.518,-0.258 0.523,-0.302 0.523,-0.357C0.523,-0.413 0.518,-0.455 0.508,-0.485C0.499,-0.514 0.485,-0.538 0.467,-0.554C0.45,-0.571 0.427,-0.582 0.4,-0.588C0.38,-0.592 0.341,-0.595 0.282,-0.595L0.217,-0.595Z" style="fill:rgb(255,0,0);fill-opacity:0.3;fill-rule:nonzero;"/>
+        </g>
+        <g transform="matrix(600,0,0,600,882.12,2125.98)">
+            <path d="M0.073,-0L0.073,-0.716L0.377,-0.716C0.454,-0.716 0.51,-0.709 0.544,-0.697C0.579,-0.684 0.607,-0.661 0.627,-0.628C0.648,-0.595 0.659,-0.557 0.659,-0.515C0.659,-0.461 0.643,-0.417 0.611,-0.382C0.58,-0.347 0.533,-0.325 0.47,-0.316C0.501,-0.298 0.527,-0.278 0.547,-0.256C0.567,-0.234 0.595,-0.195 0.629,-0.14L0.717,-0L0.544,-0L0.439,-0.156C0.402,-0.211 0.377,-0.247 0.363,-0.261C0.35,-0.275 0.335,-0.285 0.32,-0.291C0.305,-0.296 0.28,-0.299 0.247,-0.299L0.218,-0.299L0.218,-0L0.073,-0ZM0.218,-0.413L0.325,-0.413C0.394,-0.413 0.437,-0.416 0.455,-0.422C0.472,-0.428 0.485,-0.438 0.495,-0.452C0.505,-0.466 0.51,-0.484 0.51,-0.506C0.51,-0.53 0.503,-0.549 0.49,-0.564C0.478,-0.579 0.459,-0.588 0.436,-0.592C0.424,-0.594 0.389,-0.595 0.331,-0.595L0.218,-0.595L0.218,-0.413Z" style="fill:rgb(255,0,0);fill-opacity:0.3;fill-rule:nonzero;"/>
+        </g>
+        <g transform="matrix(600,0,0,600,1315.42,2125.98)">
+            <path d="M0.718,-0L0.561,-0L0.499,-0.163L0.212,-0.163L0.153,-0L0,-0L0.279,-0.716L0.432,-0.716L0.718,-0ZM0.452,-0.283L0.354,-0.549L0.257,-0.283L0.452,-0.283Z" style="fill:rgb(255,0,0);fill-opacity:0.3;fill-rule:nonzero;"/>
+        </g>
+        <g transform="matrix(600,0,0,600,1748.72,2125.98)">
+            <path d="M0.074,-0L0.074,-0.716L0.564,-0.716L0.564,-0.595L0.218,-0.595L0.218,-0.425L0.517,-0.425L0.517,-0.304L0.218,-0.304L0.218,-0L0.074,-0Z" style="fill:rgb(255,0,0);fill-opacity:0.3;fill-rule:nonzero;"/>
+        </g>
+        <g transform="matrix(600,0,0,600,2115.23,2125.98)">
+            <path d="M0.234,-0L0.234,-0.595L0.021,-0.595L0.021,-0.716L0.59,-0.716L0.59,-0.595L0.378,-0.595L0.378,-0L0.234,-0Z" style="fill:rgb(255,0,0);fill-opacity:0.3;fill-rule:nonzero;"/>
+        </g>
+    </g>
+    <g transform="matrix(0.707107,0.707107,-0.707107,0.707107,1544.52,63.1775)">
+        <g transform="matrix(600,0,0,600,448.819,2125.98)">
+            <path d="M0.072,-0.716L0.336,-0.716C0.396,-0.716 0.441,-0.711 0.473,-0.702C0.515,-0.69 0.551,-0.668 0.581,-0.636C0.611,-0.605 0.633,-0.566 0.649,-0.52C0.665,-0.475 0.672,-0.418 0.672,-0.351C0.672,-0.292 0.665,-0.241 0.65,-0.199C0.632,-0.147 0.607,-0.104 0.574,-0.072C0.549,-0.048 0.515,-0.029 0.472,-0.015C0.44,-0.005 0.398,-0 0.344,-0L0.072,-0L0.072,-0.716ZM0.217,-0.595L0.217,-0.121L0.325,-0.121C0.365,-0.121 0.394,-0.123 0.412,-0.127C0.436,-0.133 0.455,-0.143 0.47,-0.157C0.486,-0.171 0.499,-0.194 0.508,-0.226C0.518,-0.258 0.523,-0.302 0.523,-0.357C0.523,-0.413 0.518,-0.455 0.508,-0.485C0.499,-0.514 0.485,-0.538 0.467,-0.554C0.45,-0.571 0.427,-0.582 0.4,-0.588C0.38,-0.592 0.341,-0.595 0.282,-0.595L0.217,-0.595Z" style="fill:rgb(255,0,0);fill-opacity:0.3;fill-rule:nonzero;"/>
+        </g>
+        <g transform="matrix(600,0,0,600,882.12,2125.98)">
+            <path d="M0.073,-0L0.073,-0.716L0.377,-0.716C0.454,-0.716 0.51,-0.709 0.544,-0.697C0.579,-0.684 0.607,-0.661 0.627,-0.628C0.648,-0.595 0.659,-0.557 0.659,-0.515C0.659,-0.461 0.643,-0.417 0.611,-0.382C0.58,-0.347 0.533,-0.325 0.47,-0.316C0.501,-0.298 0.527,-0.278 0.547,-0.256C0.567,-0.234 0.595,-0.195 0.629,-0.14L0.717,-0L0.544,-0L0.439,-0.156C0.402,-0.211 0.377,-0.247 0.363,-0.261C0.35,-0.275 0.335,-0.285 0.32,-0.291C0.305,-0.296 0.28,-0.299 0.247,-0.299L0.218,-0.299L0.218,-0L0.073,-0ZM0.218,-0.413L0.325,-0.413C0.394,-0.413 0.437,-0.416 0.455,-0.422C0.472,-0.428 0.485,-0.438 0.495,-0.452C0.505,-0.466 0.51,-0.484 0.51,-0.506C0.51,-0.53 0.503,-0.549 0.49,-0.564C0.478,-0.579 0.459,-0.588 0.436,-0.592C0.424,-0.594 0.389,-0.595 0.331,-0.595L0.218,-0.595L0.218,-0.413Z" style="fill:rgb(255,0,0);fill-opacity:0.3;fill-rule:nonzero;"/>
+        </g>
+        <g transform="matrix(600,0,0,600,1315.42,2125.98)">
+            <path d="M0.718,-0L0.561,-0L0.499,-0.163L0.212,-0.163L0.153,-0L0,-0L0.279,-0.716L0.432,-0.716L0.718,-0ZM0.452,-0.283L0.354,-0.549L0.257,-0.283L0.452,-0.283Z" style="fill:rgb(255,0,0);fill-opacity:0.3;fill-rule:nonzero;"/>
+        </g>
+        <g transform="matrix(600,0,0,600,1748.72,2125.98)">
+            <path d="M0.074,-0L0.074,-0.716L0.564,-0.716L0.564,-0.595L0.218,-0.595L0.218,-0.425L0.517,-0.425L0.517,-0.304L0.218,-0.304L0.218,-0L0.074,-0Z" style="fill:rgb(255,0,0);fill-opacity:0.3;fill-rule:nonzero;"/>
+        </g>
+        <g transform="matrix(600,0,0,600,2115.23,2125.98)">
+            <path d="M0.234,-0L0.234,-0.595L0.021,-0.595L0.021,-0.716L0.59,-0.716L0.59,-0.595L0.378,-0.595L0.378,-0L0.234,-0Z" style="fill:rgb(255,0,0);fill-opacity:0.3;fill-rule:nonzero;"/>
+        </g>
+    </g>
+</svg>

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 5 - 0
Source/QuestPDF.DocumentationExamples/Resources/questpdf-logo.svg


Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác