Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 704256510e | |||
| 9ce9ca85be |
@@ -0,0 +1,146 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using QuestPDF.Elements;
|
||||||
|
using QuestPDF.Fluent;
|
||||||
|
using QuestPDF.Helpers;
|
||||||
|
|
||||||
|
namespace QuestPDF.Examples
|
||||||
|
{
|
||||||
|
public class ProcessRunningTime
|
||||||
|
{
|
||||||
|
public TimeSpan FluentTime { get; set; }
|
||||||
|
public TimeSpan GenerationTime { get; set; }
|
||||||
|
public float Size { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GenerationBenchmark
|
||||||
|
{
|
||||||
|
public const int TestSize = 4096;
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void BenchmarkAsync()
|
||||||
|
{
|
||||||
|
RunTest(() => Enumerable
|
||||||
|
.Range(0, TestSize)
|
||||||
|
.AsParallel() // difference
|
||||||
|
.Select(GenerateAndCollect)
|
||||||
|
.ToList());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void BenchmarkSync()
|
||||||
|
{
|
||||||
|
RunTest(() => Enumerable
|
||||||
|
.Range(0, TestSize)
|
||||||
|
.Select(GenerateAndCollect)
|
||||||
|
.ToList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RunTest(Func<IEnumerable<ProcessRunningTime>> handler)
|
||||||
|
{
|
||||||
|
var totalFluentTime = TimeSpan.Zero;
|
||||||
|
var totalGenerationTime = TimeSpan.Zero;
|
||||||
|
|
||||||
|
var stopWatch = new Stopwatch();
|
||||||
|
|
||||||
|
stopWatch.Start();
|
||||||
|
var results = handler();
|
||||||
|
stopWatch.Stop();
|
||||||
|
|
||||||
|
foreach (var result in results)
|
||||||
|
{
|
||||||
|
totalFluentTime += result.FluentTime;
|
||||||
|
totalGenerationTime += result.GenerationTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Fluent: {totalFluentTime:g}");
|
||||||
|
Console.WriteLine($"Generation: {totalGenerationTime:g}");
|
||||||
|
Console.WriteLine($"Total: {stopWatch.Elapsed:g}");
|
||||||
|
}
|
||||||
|
|
||||||
|
static ProcessRunningTime GenerateAndCollect(int attemptNumber)
|
||||||
|
{
|
||||||
|
var stopwatch = new Stopwatch();
|
||||||
|
stopwatch.Start();
|
||||||
|
|
||||||
|
var container = new Container();
|
||||||
|
|
||||||
|
container
|
||||||
|
.Padding(10)
|
||||||
|
.MinimalBox()
|
||||||
|
.Border(1)
|
||||||
|
.Column(column =>
|
||||||
|
{
|
||||||
|
column.Item().Text($"Attempts {attemptNumber}");
|
||||||
|
|
||||||
|
const int numberOfRows = 100;
|
||||||
|
const int numberOfColumns = 10;
|
||||||
|
|
||||||
|
for (var y = 0; y < numberOfRows; y++)
|
||||||
|
{
|
||||||
|
column.Item().Row(row =>
|
||||||
|
{
|
||||||
|
for (var x = 0; x < numberOfColumns; x++)
|
||||||
|
{
|
||||||
|
row.RelativeItem()
|
||||||
|
|
||||||
|
.Background(Colors.Red.Lighten5)
|
||||||
|
.Padding(3)
|
||||||
|
|
||||||
|
.Background(Colors.Red.Lighten4)
|
||||||
|
.Padding(3)
|
||||||
|
|
||||||
|
.Background(Colors.Red.Lighten3)
|
||||||
|
.Padding(3)
|
||||||
|
|
||||||
|
.Background(Colors.Red.Lighten2)
|
||||||
|
.Padding(3)
|
||||||
|
|
||||||
|
.Background(Colors.Red.Lighten1)
|
||||||
|
.Padding(3)
|
||||||
|
|
||||||
|
.Background(Colors.Red.Medium)
|
||||||
|
.Padding(3)
|
||||||
|
|
||||||
|
.Background(Colors.Red.Darken1)
|
||||||
|
.Padding(3)
|
||||||
|
|
||||||
|
.Background(Colors.Red.Darken2)
|
||||||
|
.Padding(3)
|
||||||
|
|
||||||
|
.Background(Colors.Red.Darken3)
|
||||||
|
.Padding(3)
|
||||||
|
|
||||||
|
.Background(Colors.Red.Darken4)
|
||||||
|
.Height(3);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var fluentTime = stopwatch.Elapsed;
|
||||||
|
|
||||||
|
stopwatch.Reset();
|
||||||
|
stopwatch.Start();
|
||||||
|
|
||||||
|
var size = Document
|
||||||
|
.Create(x => x.Page(page => page.Content().Element(container)))
|
||||||
|
.GeneratePdf()
|
||||||
|
.Length;
|
||||||
|
|
||||||
|
var generationTime = stopwatch.Elapsed;
|
||||||
|
|
||||||
|
return new ProcessRunningTime
|
||||||
|
{
|
||||||
|
FluentTime = fluentTime,
|
||||||
|
GenerationTime = generationTime,
|
||||||
|
Size = size
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ namespace QuestPDF.Examples
|
|||||||
.PageSize(PageSizes.A4)
|
.PageSize(PageSizes.A4)
|
||||||
.ShowResults()
|
.ShowResults()
|
||||||
.MaxPages(10_000)
|
.MaxPages(10_000)
|
||||||
.EnableCaching(true)
|
//.EnableCaching(true)
|
||||||
.EnableDebugging(false)
|
.EnableDebugging(false)
|
||||||
.Render(container =>
|
.Render(container =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ namespace QuestPDF.ReportSample
|
|||||||
HeaderFields = HeaderFields(),
|
HeaderFields = HeaderFields(),
|
||||||
|
|
||||||
LogoData = Helpers.GetImage("Logo.png"),
|
LogoData = Helpers.GetImage("Logo.png"),
|
||||||
Sections = Enumerable.Range(0, 40).Select(x => GenerateSection()).ToList(),
|
Sections = Enumerable.Range(0, 2000).Select(x => GenerateSection()).ToList(),
|
||||||
Photos = Enumerable.Range(0, 25).Select(x => GetReportPhotos()).ToList()
|
Photos = Enumerable.Range(0, 200).Select(x => GetReportPhotos()).ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
List<ReportHeaderField> HeaderFields()
|
List<ReportHeaderField> HeaderFields()
|
||||||
|
|||||||
@@ -24,7 +24,10 @@ namespace QuestPDF.ReportSample
|
|||||||
[Test]
|
[Test]
|
||||||
public void GenerateAndShowPdf()
|
public void GenerateAndShowPdf()
|
||||||
{
|
{
|
||||||
//ImagePlaceholder.Solid = true;
|
Settings.DocumentLayoutExceptionThreshold = 10_000;
|
||||||
|
Settings.EnableCaching = true;
|
||||||
|
Settings.EnableDebugging = false;
|
||||||
|
ImagePlaceholder.Solid = true;
|
||||||
|
|
||||||
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"test_result.pdf");
|
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"test_result.pdf");
|
||||||
Report.GeneratePdf(path);
|
Report.GeneratePdf(path);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ namespace QuestPDF.UnitTests.TestEngine
|
|||||||
public void DrawRectangle(Position vector, Size size, string color) => DrawRectFunc(vector, size, color);
|
public void DrawRectangle(Position vector, Size size, string color) => DrawRectFunc(vector, size, color);
|
||||||
public void DrawText(SKTextBlob skTextBlob, Position position, TextStyle style) => throw new NotImplementedException();
|
public void DrawText(SKTextBlob skTextBlob, Position position, TextStyle style) => throw new NotImplementedException();
|
||||||
public void DrawImage(SKImage image, Position position, Size size) => DrawImageFunc(image, position, size);
|
public void DrawImage(SKImage image, Position position, Size size) => DrawImageFunc(image, position, size);
|
||||||
|
public void DrawPicture(SKPicture picture) => throw new NotImplementedException();
|
||||||
|
|
||||||
public void DrawHyperlink(string url, Size size) => throw new NotImplementedException();
|
public void DrawHyperlink(string url, Size size) => throw new NotImplementedException();
|
||||||
public void DrawSectionLink(string sectionName, Size size) => throw new NotImplementedException();
|
public void DrawSectionLink(string sectionName, Size size) => throw new NotImplementedException();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace QuestPDF.UnitTests.TestEngine
|
|||||||
public void DrawRectangle(Position vector, Size size, string color) => Operations.Add(new CanvasDrawRectangleOperation(vector, size, color));
|
public void DrawRectangle(Position vector, Size size, string color) => Operations.Add(new CanvasDrawRectangleOperation(vector, size, color));
|
||||||
public void DrawText(SKTextBlob skTextBlob, Position position, TextStyle style) => throw new NotImplementedException();
|
public void DrawText(SKTextBlob skTextBlob, Position position, TextStyle style) => throw new NotImplementedException();
|
||||||
public void DrawImage(SKImage image, Position position, Size size) => Operations.Add(new CanvasDrawImageOperation(position, size));
|
public void DrawImage(SKImage image, Position position, Size size) => Operations.Add(new CanvasDrawImageOperation(position, size));
|
||||||
|
public void DrawPicture(SKPicture picture) => throw new NotImplementedException();
|
||||||
|
|
||||||
public void DrawHyperlink(string url, Size size) => throw new NotImplementedException();
|
public void DrawHyperlink(string url, Size size) => throw new NotImplementedException();
|
||||||
public void DrawSectionLink(string sectionName, Size size) => throw new NotImplementedException();
|
public void DrawSectionLink(string sectionName, Size size) => throw new NotImplementedException();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using QuestPDF.Drawing.Exceptions;
|
using QuestPDF.Drawing.Exceptions;
|
||||||
@@ -64,18 +65,27 @@ namespace QuestPDF.Drawing
|
|||||||
var container = new DocumentContainer();
|
var container = new DocumentContainer();
|
||||||
document.Compose(container);
|
document.Compose(container);
|
||||||
var content = container.Compose();
|
var content = container.Compose();
|
||||||
|
|
||||||
ApplyRepeatContent(content);
|
|
||||||
ApplyDefaultTextStyle(content, TextStyle.LibraryDefault);
|
ApplyDefaultTextStyle(content, TextStyle.LibraryDefault);
|
||||||
|
|
||||||
var debuggingState = Settings.EnableDebugging ? ApplyDebugging(content) : null;
|
var debuggingState = Settings.EnableDebugging ? ApplyDebugging(content) : null;
|
||||||
|
debuggingState = null;
|
||||||
|
|
||||||
if (Settings.EnableCaching)
|
//if (Settings.EnableCaching)
|
||||||
ApplyCaching(content);
|
//ApplyCaching(content);
|
||||||
|
|
||||||
var pageContext = new PageContext();
|
var pageContext = new PageContext();
|
||||||
|
|
||||||
|
var stopwatch = new Stopwatch();
|
||||||
|
|
||||||
|
stopwatch.Restart();
|
||||||
RenderPass(pageContext, new FreeCanvas(), content, debuggingState);
|
RenderPass(pageContext, new FreeCanvas(), content, debuggingState);
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine($"Cold free: {stopwatch.Elapsed}");
|
||||||
|
|
||||||
|
stopwatch.Restart();
|
||||||
RenderPass(pageContext, canvas, content, debuggingState);
|
RenderPass(pageContext, canvas, content, debuggingState);
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine($"Canvas: {stopwatch.Elapsed}");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void RenderPass<TCanvas>(PageContext pageContext, TCanvas canvas, Container content, DebuggingState? debuggingState)
|
internal static void RenderPass<TCanvas>(PageContext pageContext, TCanvas canvas, Container content, DebuggingState? debuggingState)
|
||||||
@@ -194,23 +204,5 @@ namespace QuestPDF.Drawing
|
|||||||
foreach (var child in content.GetChildren())
|
foreach (var child in content.GetChildren())
|
||||||
ApplyDefaultTextStyle(child, documentDefaultTextStyle);
|
ApplyDefaultTextStyle(child, documentDefaultTextStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void ApplyRepeatContent(this Element? content, bool enabled = false)
|
|
||||||
{
|
|
||||||
if (content == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (content is RepeatContent repeatContent)
|
|
||||||
{
|
|
||||||
ApplyRepeatContent(repeatContent.Child, repeatContent.Repeat);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var child in content.GetChildren())
|
|
||||||
ApplyRepeatContent(child, enabled);
|
|
||||||
|
|
||||||
if (!enabled)
|
|
||||||
content.CreateProxy(y => y is IContent ? new ShowOnce { Child = y } : y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,6 +51,11 @@ namespace QuestPDF.Drawing
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DrawPicture(SKPicture picture)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void DrawHyperlink(string url, Size size)
|
public void DrawHyperlink(string url, Size size)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ namespace QuestPDF.Drawing
|
|||||||
Canvas.DrawImage(image, new SKRect(vector.X, vector.Y, size.Width, size.Height));
|
Canvas.DrawImage(image, new SKRect(vector.X, vector.Y, size.Width, size.Height));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DrawPicture(SKPicture picture)
|
||||||
|
{
|
||||||
|
Canvas.DrawPicture(picture);
|
||||||
|
}
|
||||||
|
|
||||||
public void DrawHyperlink(string url, Size size)
|
public void DrawHyperlink(string url, Size size)
|
||||||
{
|
{
|
||||||
Canvas.DrawUrlAnnotation(new SKRect(0, 0, size.Width, size.Height), url);
|
Canvas.DrawUrlAnnotation(new SKRect(0, 0, size.Width, size.Height), url);
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using QuestPDF.Helpers;
|
||||||
|
using QuestPDF.Infrastructure;
|
||||||
|
using SkiaSharp;
|
||||||
|
|
||||||
|
namespace QuestPDF.Drawing
|
||||||
|
{
|
||||||
|
internal class SkiaCaptureCanvas : SkiaCanvasBase
|
||||||
|
{
|
||||||
|
private SKPictureRecorder? PictureRecorder { get; set; }
|
||||||
|
private Size? CurrentPageSize { get; set; }
|
||||||
|
public SKPicture? CurrentPicture { get; set; }
|
||||||
|
|
||||||
|
public override void BeginDocument()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void BeginPage(Size size)
|
||||||
|
{
|
||||||
|
CurrentPageSize = size;
|
||||||
|
PictureRecorder = new SKPictureRecorder();
|
||||||
|
|
||||||
|
Canvas = PictureRecorder.BeginRecording(new SKRect(0, 0, size.Width, size.Height));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void EndPage()
|
||||||
|
{
|
||||||
|
CurrentPicture = PictureRecorder?.EndRecording();
|
||||||
|
|
||||||
|
PictureRecorder?.Dispose();
|
||||||
|
PictureRecorder = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void EndDocument() { }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ namespace QuestPDF.Elements
|
|||||||
{
|
{
|
||||||
public delegate void DrawOnCanvas(SKCanvas canvas, Size availableSpace);
|
public delegate void DrawOnCanvas(SKCanvas canvas, Size availableSpace);
|
||||||
|
|
||||||
internal class Canvas : Element, ICacheable, IContent
|
internal class Canvas : Element, ICacheable
|
||||||
{
|
{
|
||||||
public DrawOnCanvas Handler { get; set; }
|
public DrawOnCanvas Handler { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using QuestPDF.Drawing;
|
||||||
|
using QuestPDF.Helpers;
|
||||||
|
using QuestPDF.Infrastructure;
|
||||||
|
using SkiaSharp;
|
||||||
|
|
||||||
|
namespace QuestPDF.Elements
|
||||||
|
{
|
||||||
|
internal class DrawingCache : ContainerElement
|
||||||
|
{
|
||||||
|
private SkiaCaptureCanvas CaptureCanvas { get; } = new();
|
||||||
|
private Dictionary<int, SpacePlan> MeasureCache { get; } = new();
|
||||||
|
private Dictionary<int, SKPicture> DrawCache { get; } = new();
|
||||||
|
|
||||||
|
~DrawingCache()
|
||||||
|
{
|
||||||
|
foreach (var picture in DrawCache.Values)
|
||||||
|
picture.Dispose();
|
||||||
|
|
||||||
|
DrawCache.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void Initialize(IPageContext pageContext, ICanvas canvas)
|
||||||
|
{
|
||||||
|
Child.VisitChildren(x => x.Canvas = CaptureCanvas);
|
||||||
|
base.Initialize(pageContext, canvas);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override SpacePlan Measure(Size availableSpace)
|
||||||
|
{
|
||||||
|
var cacheKey = PageContext.CurrentPage;
|
||||||
|
|
||||||
|
if (MeasureCache.TryGetValue(cacheKey, out var result))
|
||||||
|
return result;
|
||||||
|
|
||||||
|
var childSize = Child?.Measure(availableSpace) ?? SpacePlan.FullRender(Size.Zero);
|
||||||
|
MeasureCache.Add(cacheKey, childSize);
|
||||||
|
return childSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void Draw(Size availableSpace)
|
||||||
|
{
|
||||||
|
var cacheKey = PageContext.CurrentPage;
|
||||||
|
|
||||||
|
if (DrawCache.TryGetValue(cacheKey, out var result))
|
||||||
|
{
|
||||||
|
Canvas.DrawPicture(result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CaptureCanvas.BeginPage(availableSpace);
|
||||||
|
Child?.Draw(availableSpace);
|
||||||
|
CaptureCanvas.EndPage();
|
||||||
|
|
||||||
|
var picture = CaptureCanvas.CurrentPicture;
|
||||||
|
DrawCache.Add(cacheKey, picture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ using QuestPDF.Infrastructure;
|
|||||||
|
|
||||||
namespace QuestPDF.Elements
|
namespace QuestPDF.Elements
|
||||||
{
|
{
|
||||||
internal class DynamicHost : Element, IStateResettable, IContent
|
internal class DynamicHost : Element, IStateResettable
|
||||||
{
|
{
|
||||||
private DynamicComponentProxy Child { get; }
|
private DynamicComponentProxy Child { get; }
|
||||||
private object InitialComponentState { get; set; }
|
private object InitialComponentState { get; set; }
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using SkiaSharp;
|
|||||||
|
|
||||||
namespace QuestPDF.Elements
|
namespace QuestPDF.Elements
|
||||||
{
|
{
|
||||||
internal class DynamicImage : Element, IContent
|
internal class DynamicImage : Element
|
||||||
{
|
{
|
||||||
public Func<Size, byte[]>? Source { get; set; }
|
public Func<Size, byte[]>? Source { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using SkiaSharp;
|
|||||||
|
|
||||||
namespace QuestPDF.Elements
|
namespace QuestPDF.Elements
|
||||||
{
|
{
|
||||||
internal class Image : Element, ICacheable, IContent
|
internal class Image : Element, ICacheable
|
||||||
{
|
{
|
||||||
public SKImage? InternalImage { get; set; }
|
public SKImage? InternalImage { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace QuestPDF.Elements
|
|||||||
Horizontal
|
Horizontal
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class Line : Element, ILine, ICacheable, IContent
|
internal class Line : Element, ILine, ICacheable
|
||||||
{
|
{
|
||||||
public LineType Type { get; set; } = LineType.Vertical;
|
public LineType Type { get; set; } = LineType.Vertical;
|
||||||
public string Color { get; set; } = Colors.Black;
|
public string Color { get; set; } = Colors.Black;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ namespace QuestPDF.Elements
|
|||||||
public void Compose(IContainer container)
|
public void Compose(IContainer container)
|
||||||
{
|
{
|
||||||
container
|
container
|
||||||
|
//.Element(new DrawingCache())
|
||||||
.Background(BackgroundColor)
|
.Background(BackgroundColor)
|
||||||
.Layers(layers =>
|
.Layers(layers =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
using QuestPDF.Infrastructure;
|
|
||||||
|
|
||||||
namespace QuestPDF.Elements
|
|
||||||
{
|
|
||||||
internal class RepeatContent : ContainerElement
|
|
||||||
{
|
|
||||||
public bool Repeat { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,7 @@ using QuestPDF.Infrastructure;
|
|||||||
|
|
||||||
namespace QuestPDF.Elements.Text
|
namespace QuestPDF.Elements.Text
|
||||||
{
|
{
|
||||||
internal class TextBlock : Element, IStateResettable, IContent
|
internal class TextBlock : Element, IStateResettable
|
||||||
{
|
{
|
||||||
public HorizontalAlignment Alignment { get; set; } = HorizontalAlignment.Left;
|
public HorizontalAlignment Alignment { get; set; } = HorizontalAlignment.Left;
|
||||||
public List<ITextBlockItem> Items { get; set; } = new List<ITextBlockItem>();
|
public List<ITextBlockItem> Items { get; set; } = new List<ITextBlockItem>();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace QuestPDF.Fluent
|
|||||||
{
|
{
|
||||||
var container = new Container();
|
var container = new Container();
|
||||||
Decoration.Before = container;
|
Decoration.Before = container;
|
||||||
return container.RepeatContent();
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Before(Action<IContainer> handler)
|
public void Before(Action<IContainer> handler)
|
||||||
@@ -36,7 +36,7 @@ namespace QuestPDF.Fluent
|
|||||||
{
|
{
|
||||||
var container = new Container();
|
var container = new Container();
|
||||||
Decoration.After = container;
|
Decoration.After = container;
|
||||||
return container.RepeatContent();
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void After(Action<IContainer> handler)
|
public void After(Action<IContainer> handler)
|
||||||
|
|||||||
@@ -195,13 +195,5 @@ namespace QuestPDF.Fluent
|
|||||||
{
|
{
|
||||||
return element.Element(new ScaleToFit());
|
return element.Element(new ScaleToFit());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IContainer RepeatContent(this IContainer element, bool enabled = true)
|
|
||||||
{
|
|
||||||
return element.Element(new RepeatContent
|
|
||||||
{
|
|
||||||
Repeat = enabled
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,17 +15,6 @@ namespace QuestPDF.Fluent
|
|||||||
return descriptor;
|
return descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T Fallback<T>(this T descriptor, TextStyle? value = null) where T : TextSpanDescriptor
|
|
||||||
{
|
|
||||||
descriptor.TextStyle.Fallback = value;
|
|
||||||
return descriptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static T Fallback<T>(this T descriptor, Func<TextStyle, TextStyle> handler) where T : TextSpanDescriptor
|
|
||||||
{
|
|
||||||
return descriptor.Fallback(handler(TextStyle.Default));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static T FontColor<T>(this T descriptor, string value) where T : TextSpanDescriptor
|
public static T FontColor<T>(this T descriptor, string value) where T : TextSpanDescriptor
|
||||||
{
|
{
|
||||||
descriptor.MutateTextStyle(x => x.FontColor(value));
|
descriptor.MutateTextStyle(x => x.FontColor(value));
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ namespace QuestPDF.Infrastructure
|
|||||||
void DrawRectangle(Position vector, Size size, string color);
|
void DrawRectangle(Position vector, Size size, string color);
|
||||||
void DrawText(SKTextBlob skTextBlob, Position position, TextStyle style);
|
void DrawText(SKTextBlob skTextBlob, Position position, TextStyle style);
|
||||||
void DrawImage(SKImage image, Position position, Size size);
|
void DrawImage(SKImage image, Position position, Size size);
|
||||||
|
void DrawPicture(SKPicture picture);
|
||||||
|
|
||||||
void DrawHyperlink(string url, Size size);
|
void DrawHyperlink(string url, Size size);
|
||||||
void DrawSectionLink(string sectionName, Size size);
|
void DrawSectionLink(string sectionName, Size size);
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace QuestPDF.Infrastructure
|
|
||||||
{
|
|
||||||
internal interface IContent
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user