Compare commits

..

2 Commits

Author SHA1 Message Date
Marcin Ziąbek 10683776bb 2021.12.0 2021-12-06 09:28:02 +01:00
Marcin Ziąbek f2c47c4fd3 2021.12.0-alpha1 2021-11-30 00:34:04 +01:00
13 changed files with 98 additions and 41 deletions
+32 -9
View File
@@ -1,3 +1,4 @@
using System.Linq;
using NUnit.Framework;
using QuestPDF.Examples.Engine;
using QuestPDF.Fluent;
@@ -43,19 +44,41 @@ namespace QuestPDF.Examples
RenderingTest
.Create()
.PageSize(300, 300)
.PageSize(400, 600)
.ProduceImages()
.ShowResults()
.Render(container =>
{
container.Extend().Canvas((canvas, size) =>
{
var bar = new BarChart
container
.Background(Colors.White)
.Padding(25)
.Stack(stack =>
{
Entries = entries,
IsAnimated = false,
};
bar.Draw(canvas, (int)size.Width, (int)size.Height);
});
stack
.Item()
.PaddingBottom(10)
.Text("Chart example", TextStyle.Default.Size(20).SemiBold().Color(Colors.Blue.Medium));
stack
.Item()
.Border(1)
.ExtendHorizontal()
.Height(300)
.Canvas((canvas, size) =>
{
var chart = new BarChart
{
Entries = entries,
LabelOrientation = Orientation.Horizontal,
ValueLabelOrientation = Orientation.Horizontal,
IsAnimated = false,
};
chart.DrawContent(canvas, (int)size.Width, (int)size.Height);
});
});
});
}
}
+3 -4
View File
@@ -16,8 +16,7 @@ namespace QuestPDF.Examples
.PageSize(PageSizes.A4)
.ProducePdf()
.ShowResults()
.Render(x => x.Image(new byte[] { 1, 2, 3 }));
//.Render(x => GenerateStructure(x, 16));
.Render(x => GenerateStructure(x, 16));
}
private void GenerateStructure(IContainer container, int level)
@@ -33,7 +32,7 @@ namespace QuestPDF.Examples
if (level % 3 == 0)
{
container
.Border(level / 10f)
.Border(level / 4f)
.BorderColor(Colors.Black)
.Row(row =>
{
@@ -44,7 +43,7 @@ namespace QuestPDF.Examples
else
{
container
.Border(level / 10f)
.Border(level / 4f)
.BorderColor(Colors.Black)
.Stack(stack =>
{
+39 -8
View File
@@ -16,17 +16,48 @@ namespace QuestPDF.Examples
.Render(container =>
{
container
.Background(Colors.White)
.Padding(15)
.Grid(grid =>
.Padding(10)
.Width(100)
.Background(Colors.Grey.Lighten3)
.DebugPointer("Example debug pointer")
.Stack(x =>
{
grid.Spacing(15);
grid.Item().Background(Colors.Grey.Medium).Text(Placeholders.LoremIpsum());
grid.Item().DebugPointer("Test").Background(Colors.Grey.Lighten1).Height(1000); // <-- problem
grid.Item().Background(Colors.Grey.Lighten2).Height(150);
x.Item().Text("Test");
x.Item().Width(150);
});
});
}
[Test]
public void Simple()
{
RenderingTest
.Create()
.PageSize(500, 360)
.Render(container =>
{
container
.Padding(10)
.Width(100)
.Background(Colors.Grey.Lighten3)
.Width(150)
.Text("Test");
});
}
[Test]
public void DebugPointer()
{
RenderingTest
.Create()
.PageSize(500, 360)
.Render(container =>
{
container
.Width(100)
.DebugPointer("Example debug pointer")
.Width(150);
});
}
}
}
+2
View File
@@ -36,6 +36,8 @@ namespace QuestPDF.Examples
RenderingTest
.Create()
.PageSize(350, 280)
.ProducePdf()
.ShowResults()
.Render(container =>
{
container
+3 -9
View File
@@ -46,16 +46,10 @@ namespace QuestPDF.Drawing
var metadata = document.GetMetadata();
var pageContext = new PageContext();
DebuggingState debuggingState = null;
if (System.Diagnostics.Debugger.IsAttached)
{
debuggingState = ApplyDebugging(content);
}
else
{
var debuggingState = metadata.ApplyDebugging ? ApplyDebugging(content) : null;
if (metadata.ApplyCaching)
ApplyCaching(content);
}
RenderPass(pageContext, new FreeCanvas(), content, metadata, debuggingState);
RenderPass(pageContext, canvas, content, metadata, debuggingState);
+4 -1
View File
@@ -23,7 +23,10 @@ namespace QuestPDF.Drawing
/// (likely due to infinite layout), the exception is thrown.
/// </summary>
public int DocumentLayoutExceptionThreshold { get; set; } = 250;
public bool ApplyCaching { get; set; } = !System.Diagnostics.Debugger.IsAttached;
public bool ApplyDebugging { get; set; } = System.Diagnostics.Debugger.IsAttached;
public static DocumentMetadata Default => new DocumentMetadata();
}
}
+2 -2
View File
@@ -76,7 +76,7 @@ namespace QuestPDF.Drawing.Proxy
title += debugPointer.Highlight ? " 🌟" : string.Empty;
}
if (item.SpacePlan.Type == SpacePlanType.Wrap)
if (item.SpacePlan.Type != SpacePlanType.FullRender)
title = "🔥 " + title;
builder.AppendLine(indent + title);
@@ -109,7 +109,7 @@ namespace QuestPDF.Drawing.Proxy
Value = x.GetValue(element)
})
.Where(x => !(x.Value is IElement))
.Where(x => !(x.Value is IEnumerable<IElement>))
.Where(x => x.Value is string || !(x.Value is IEnumerable))
.Where(x => !(x.Value is TextStyle))
.Select(x => $"{x.Property}: {FormatValue(x.Value)}");
+1 -1
View File
@@ -31,7 +31,7 @@ namespace QuestPDF.Drawing
if (Type == SpacePlanType.Wrap)
return Type.ToString();
return $"{Type} | width {Width:N2} | height {Height:N2}";
return $"{Type} (Width: {Width:N2}, Height: {Height:N2})";
}
public static implicit operator Size(SpacePlan spacePlan)
+2 -2
View File
@@ -22,9 +22,9 @@ namespace QuestPDF.Elements
if (Handler == null || skiaCanvas == null)
return;
var currentMatrix = skiaCanvas.TotalMatrix;
var originalMatrix = skiaCanvas.TotalMatrix;
Handler.Invoke(skiaCanvas, availableSpace);
skiaCanvas.SetMatrix(currentMatrix);
skiaCanvas.SetMatrix(originalMatrix);
}
}
}
+4 -2
View File
@@ -13,8 +13,10 @@ namespace QuestPDF.Elements.Text
public HorizontalAlignment Alignment { get; set; } = HorizontalAlignment.Left;
public List<ITextBlockItem> Children { get; set; } = new List<ITextBlockItem>();
public Queue<ITextBlockItem> RenderingQueue { get; set; }
public int CurrentElementIndex { get; set; }
public string Text => string.Join(" ", Children.Where(x => x is TextBlockSpan).Cast<TextBlockSpan>().Select(x => x.Text));
private Queue<ITextBlockItem> RenderingQueue { get; set; }
private int CurrentElementIndex { get; set; }
public void ResetState()
{
+1 -1
View File
@@ -16,6 +16,6 @@
Height = height;
}
public override string ToString() => $"(W: {Width}, H: {Height})";
public override string ToString() => $"(Width: {Width}, Height: {Height})";
}
}
+1 -1
View File
@@ -4,7 +4,7 @@
<Authors>MarcinZiabek</Authors>
<Company>CodeFlint</Company>
<PackageId>QuestPDF</PackageId>
<Version>2021.12.0-alpha0</Version>
<Version>2021.12.0</Version>
<PackageDescription>QuestPDF is an open-source, modern and battle-tested library that can help you with generating PDF documents by offering friendly, discoverable and predictable C# fluent API.</PackageDescription>
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/Resources/ReleaseNotes.txt"))</PackageReleaseNotes>
<LangVersion>8</LangVersion>
+4 -1
View File
@@ -1 +1,4 @@
- Added support for generating documents in the XPS file format.
- Improved debugging experience for layout-related exceptions. To make the library predictable, it is (by design) very strict about layouting rules and throws an exception when a constraint cannot be met. In this release, each exception contains an element stack that contains all information needed to identify the issue. By default, this feature is enabled only when debugger is attached.
- Improved layouting algorithm performance by introducing additional caching layer. This cache reduces the layouting time by half. By default, this feature is enabled only when debugger is not attached (mostly release mode).
- Reduced GA pressure put by the layouting algorithm. Previously, every element measurement operation was represented by an object and the paging support was done via class hierarchy. New solution uses structs (which are value-types) and enums. This also makes the code more readable and easier to follow.
- Added support for generating XPS files which are easier to print in the Windows environment. This was possible due to existing support in SkiaSharp. This change was proposed by **sbrkich**, thank you!