Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/OpenQuestPDF.Examples/DefaultTextStyleExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void DefaultTextStyle()
container.Page(page =>
{
// all text in this set of pages has size 20
page.DefaultTextStyle(TextStyle.Default.Size(20));
page.DefaultTextStyle(TextStyle.Default.FontSize(20));

page.Margin(20);
page.Size(PageSizes.A4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void Placeholder()

page.Footer().AlignCenter().Text(text =>
{
text.DefaultTextStyle(TextStyle.Default.Size(16));
text.DefaultTextStyle(TextStyle.Default.FontSize(16));

text.CurrentPageNumber();
text.Span(" / ");
Expand Down
8 changes: 4 additions & 4 deletions Source/OpenQuestPDF.Examples/ElementExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void GridExample()
.PageSize(400, 230)
.Render(container =>
{
var textStyle = TextStyle.Default.Size(14);
var textStyle = TextStyle.Default.FontSize(14);

container
.Padding(15)
Expand Down Expand Up @@ -503,8 +503,8 @@ public void Scale()
{
var headerFontStyle = TextStyle
.Default
.Size(20)
.Color(Colors.Blue.Darken2)
.FontSize(20)
.FontColor(Colors.Blue.Darken2)
.SemiBold();

decoration
Expand All @@ -525,7 +525,7 @@ public void Scale()
? Colors.Red.Lighten4
: Colors.Green.Lighten4;

var fontStyle = TextStyle.Default.Size(16);
var fontStyle = TextStyle.Default.FontSize(16);

column
.Item()
Expand Down
2 changes: 1 addition & 1 deletion Source/OpenQuestPDF.Examples/ExecutionOrderExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void Example()
.Render(container =>
{
container
.DefaultTextStyle(TextStyle.Default.Size(18))
.DefaultTextStyle(TextStyle.Default.FontSize(18))
.Padding(25)
.Row(row =>
{
Expand Down
2 changes: 1 addition & 1 deletion Source/OpenQuestPDF.Examples/InlinedExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void Inlined()
{
decoration.Before().Text(text =>
{
text.DefaultTextStyle(TextStyle.Default.Size(20));
text.DefaultTextStyle(TextStyle.Default.FontSize(20));

text.CurrentPageNumber();
text.Span(" / ");
Expand Down
4 changes: 2 additions & 2 deletions Source/OpenQuestPDF.Examples/LineExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void LineHorizontal()
container
.Padding(15)
.MinimalBox()
.DefaultTextStyle(TextStyle.Default.Size(16))
.DefaultTextStyle(TextStyle.Default.FontSize(16))
.Column(column =>
{
column.Item().Text("Above text");
Expand All @@ -44,7 +44,7 @@ public void LineVertical()
{
container
.Padding(15)
.DefaultTextStyle(TextStyle.Default.Size(16))
.DefaultTextStyle(TextStyle.Default.FontSize(16))
.Row(row =>
{
row.AutoItem().Text("Left text");
Expand Down
4 changes: 2 additions & 2 deletions Source/OpenQuestPDF.Examples/StopPaging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ public void Example()
{
container
.Padding(25)
.DefaultTextStyle(TextStyle.Default.Size(14))
.DefaultTextStyle(TextStyle.Default.FontSize(14))
.Decoration(decoration =>
{
decoration
.Before()
.Text(text =>
{
text.DefaultTextStyle(TextStyle.Default.SemiBold().Color(Colors.Blue.Medium));
text.DefaultTextStyle(TextStyle.Default.SemiBold().FontColor(Colors.Blue.Medium));

text.Span("Page ");
text.CurrentPageNumber();
Expand Down
2 changes: 1 addition & 1 deletion Source/OpenQuestPDF.Examples/TableExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void DefaultCellStyle()
.Padding(10)
.MinimalBox()
.Border(1)
.DefaultTextStyle(TextStyle.Default.Size(16))
.DefaultTextStyle(TextStyle.Default.FontSize(16))
.Table(table =>
{
table.ColumnsDefinition(columns =>
Expand Down
4 changes: 2 additions & 2 deletions Source/OpenQuestPDF.Examples/TextBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ private static IEnumerable<BookChapter> GetBookChapters()

private void ComposeBook(IDocumentContainer container, ICollection<BookChapter> chapters)
{
var subtitleStyle = TextStyle.Default.Size(24).SemiBold().Color(Colors.Blue.Medium);
var normalStyle = TextStyle.Default.Size(14);
var subtitleStyle = TextStyle.Default.FontSize(24).SemiBold().FontColor(Colors.Blue.Medium);
var normalStyle = TextStyle.Default.FontSize(14);

container.Page(page =>
{
Expand Down
4 changes: 2 additions & 2 deletions Source/OpenQuestPDF.Examples/TextExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ public void SpaceIssue()

text.EmptyLine();

text.Hyperlink("Please visit QuestPDF website", "https://www.questpdf.com");
text.Hyperlink("Please visit OpenQuestPDF GitHub repository", "https://www.github.com/LM-Development/OpenQuestPDF");

text.EmptyLine();

Expand Down Expand Up @@ -549,7 +549,7 @@ public void HugeList()
{
text.Line($"{i}: {Placeholders.Paragraph()}");

text.Hyperlink("Please visit QuestPDF website. ", "https://www.questpdf.com");
text.Hyperlink("Please visit OpenQuestPDF project page. ", "https://www.github.com/LM-Development/OpenQuestPDF");

text.Span("This is page number ");
text.CurrentPageNumber();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ToolCommandName>questpdf-previewer</ToolCommandName>
<PackageDescription>OpenQuestPDF 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>Initial release.</PackageReleaseNotes>
<RepositoryUrl>https://github.com/LMDevelopment/OpenQuestPDF.git</RepositoryUrl>
<RepositoryUrl>https://github.com/LM-Development/OpenQuestPDF.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Copyright>LM IT Services AG, OpenQuestPDF contributors</Copyright>
<PackageTags>pdf report file export generate generation tool create creation render portable document format quest html library converter open source free standard core previewer</PackageTags>
Expand Down
4 changes: 2 additions & 2 deletions Source/OpenQuestPDF.UnitTests/FontManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ public void LoadFontFromFile()
[Test]
public void LoadFontFromEmbeddedResource()
{
FontManager.RegisterFontFromEmbeddedResource("QuestPDF.UnitTests.Resources.FontEmbeddedResource.ttf");
FontManager.RegisterFontFromEmbeddedResource("OpenQuestPDF.UnitTests.Resources.FontEmbeddedResource.ttf");
}

[Test]
public void LoadFontFromEmbeddedResource_ShouldThrowException_WhenResourceIsNotAvailable()
{
Assert.Throws<ArgumentException>(() =>
{
FontManager.RegisterFontFromEmbeddedResource("QuestPDF.UnitTests.WrongPath.ttf");
FontManager.RegisterFontFromEmbeddedResource("OpenQuestPDF.UnitTests.WrongPath.ttf");
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/OpenQuestPDF.UnitTests/ImageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void Fluent_RecognizesImageProportions()
return container;
})
.MeasureElement(new Size(300, 200))
.CheckMeasureResult(SpacePlan.FullRender(300, 100));;
.CheckMeasureResult(SpacePlan.FullRender(300, 100));
}

SKImage GenerateImage(int width, int height)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<PackageReference Include="NUnit3TestAdapter" Version="5.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="SkiaSharp" Version="3.119.0" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="3.119.0" />
</ItemGroup>

<ItemGroup>
Expand Down
54 changes: 27 additions & 27 deletions Source/OpenQuestPDF.UnitTests/TestEngine/TestPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,43 +54,43 @@ private ICanvas CreateCanvas()
{
var expected = GetExpected<CanvasTranslateOperation>();

Assert.AreEqual(expected.Position.X, position.X, "Translate X");
Assert.AreEqual(expected.Position.Y, position.Y, "Translate Y");
Assert.That(position.X, Is.EqualTo(expected.Position.X), "Translate X");
Assert.That(position.Y, Is.EqualTo(expected.Position.Y), "Translate Y");
},
RotateFunc = angle =>
{
var expected = GetExpected<CanvasRotateOperation>();

Assert.AreEqual(expected.Angle, angle, "Rotate angle");
Assert.That(angle, Is.EqualTo(expected.Angle), "Rotate angle");
},
ScaleFunc = (scaleX, scaleY) =>
{
var expected = GetExpected<CanvasScaleOperation>();

Assert.AreEqual(expected.ScaleX, scaleX, "Scale X");
Assert.AreEqual(expected.ScaleY, scaleY, "Scale Y");
Assert.That(scaleX, Is.EqualTo(expected.ScaleX), "Scale X");
Assert.That(scaleY, Is.EqualTo(expected.ScaleY), "Scale Y");
},
DrawRectFunc = (position, size, color) =>
{
var expected = GetExpected<CanvasDrawRectangleOperation>();

Assert.AreEqual(expected.Position.X, position.X, "Draw rectangle: X");
Assert.AreEqual(expected.Position.Y, position.Y, "Draw rectangle: Y");
Assert.That(position.X, Is.EqualTo(expected.Position.X), "Draw rectangle: X");
Assert.That(position.Y, Is.EqualTo(expected.Position.Y), "Draw rectangle: Y");

Assert.AreEqual(expected.Size.Width, size.Width, "Draw rectangle: width");
Assert.AreEqual(expected.Size.Height, size.Height, "Draw rectangle: height");
Assert.That(size.Width, Is.EqualTo(expected.Size.Width), "Draw rectangle: width");
Assert.That(size.Height, Is.EqualTo(expected.Size.Height), "Draw rectangle: height");

Assert.AreEqual(expected.Color, color, "Draw rectangle: color");
Assert.That(color, Is.EqualTo(expected.Color), "Draw rectangle: color");
},
DrawImageFunc = (image, position, size) =>
{
var expected = GetExpected<CanvasDrawImageOperation>();

Assert.AreEqual(expected.Position.X, position.X, "Draw image: X");
Assert.AreEqual(expected.Position.Y, position.Y, "Draw image: Y");
Assert.That(position.X, Is.EqualTo(expected.Position.X), "Draw image: X");
Assert.That(position.Y, Is.EqualTo(expected.Position.Y), "Draw image: Y");

Assert.AreEqual(expected.Size.Width, size.Width, "Draw image: width");
Assert.AreEqual(expected.Size.Height, size.Height, "Draw image: height");
Assert.That(size.Width, Is.EqualTo(expected.Size.Width), "Draw image: width");
Assert.That(size.Height, Is.EqualTo(expected.Size.Height), "Draw image: height");
}
};
}
Expand All @@ -106,21 +106,21 @@ public Element CreateChild(string id)
{
var expected = GetExpected<ChildMeasureOperation>();

Assert.AreEqual(expected.ChildId, id);
Assert.That(id, Is.EqualTo(expected.ChildId));

Assert.AreEqual(expected.Input.Width, availableSpace.Width, $"Measure: width of child '{expected.ChildId}'");
Assert.AreEqual(expected.Input.Height, availableSpace.Height, $"Measure: height of child '{expected.ChildId}'");
Assert.That(availableSpace.Width, Is.EqualTo(expected.Input.Width), $"Measure: width of child '{expected.ChildId}'");
Assert.That(availableSpace.Height, Is.EqualTo(expected.Input.Height), $"Measure: height of child '{expected.ChildId}'");

return expected.Output;
},
DrawFunc = availableSpace =>
{
var expected = GetExpected<ChildDrawOperation>();

Assert.AreEqual(expected.ChildId, id);
Assert.That(id, Is.EqualTo(expected.ChildId));

Assert.AreEqual(expected.Input.Width, availableSpace.Width, $"Draw: width of child '{expected.ChildId}'");
Assert.AreEqual(expected.Input.Height, availableSpace.Height, $"Draw: width of child '{expected.ChildId}'");
Assert.That(availableSpace.Width, Is.EqualTo(expected.Input.Width), $"Draw: width of child '{expected.ChildId}'");
Assert.That(availableSpace.Height, Is.EqualTo(expected.Input.Height), $"Draw: width of child '{expected.ChildId}'");
}
};
}
Expand Down Expand Up @@ -199,11 +199,11 @@ public TestPlan CheckMeasureResult(SpacePlan expected)

var actual = Element.Measure(OperationInput);

Assert.AreEqual(expected.GetType(), actual.GetType());
Assert.That(actual.GetType(), Is.EqualTo(expected.GetType()));

Assert.AreEqual(expected.Width, actual.Width, "Measure: width");
Assert.AreEqual(expected.Height, actual.Height, "Measure: height");
Assert.AreEqual(expected.Type, actual.Type, "Measure: height");
Assert.That(actual.Width, Is.EqualTo(expected.Width), "Measure: width");
Assert.That(actual.Height, Is.EqualTo(expected.Height), "Measure: height");
Assert.That(actual.Type, Is.EqualTo(expected.Type), "Measure: height");

return this;
}
Expand All @@ -217,14 +217,14 @@ public TestPlan CheckDrawResult()

public TestPlan CheckState(Func<Element, bool> condition)
{
Assert.IsTrue(condition(Element), "Checking condition");
Assert.That(condition(Element), Is.True, "Checking condition");
return this;
}

public TestPlan CheckState<T>(Func<T, bool> condition) where T : Element
{
Assert.IsTrue(Element is T);
Assert.IsTrue(condition(Element as T), "Checking condition");
Assert.That(Element, Is.InstanceOf<T>());
Assert.That(condition(Element as T), Is.True, "Checking condition");
return this;
}

Expand Down
22 changes: 0 additions & 22 deletions Source/OpenQuestPDF.UnitTests/TestsBase.cs

This file was deleted.

7 changes: 6 additions & 1 deletion Source/OpenQuestPDF.UnitTests/TextStyleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ public void ApplyInheritedAndGlobalStyle()
}
};

targetStyle.Should().BeEquivalentTo(expectedStyle);
targetStyle.Should().BeEquivalentTo(expectedStyle, options => options
.IncludingNestedObjects()
.IncludingInternalProperties()
.IncludingInternalFields()
.AllowingInfiniteRecursion()
.WithStrictOrdering());
}
}
}
2 changes: 1 addition & 1 deletion Source/OpenQuestPDF/Elements/Hyperlink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace OpenQuestPDF.Elements
{
internal class Hyperlink : ContainerElement
{
public string Url { get; set; } = "https://www.questpdf.com";
public string Url { get; set; } = string.Empty;

internal override void Draw(Size availableSpace)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace OpenQuestPDF.Elements.Text.Calculation
{
internal class TextDrawingRequest
{
public ICanvas Canvas { get; set; }
public IPageContext PageContext { get; set; }
public required ICanvas Canvas { get; set; }
public required IPageContext PageContext { get; set; }

public int StartIndex { get; set; }
public int EndIndex { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ namespace OpenQuestPDF.Elements.Text.Calculation
{
internal class TextMeasurementRequest
{
public ICanvas Canvas { get; set; }
public IPageContext PageContext { get; set; }
public required ICanvas Canvas { get; set; }
public required IPageContext PageContext { get; set; }

public int StartIndex { get; set; }
public float AvailableWidth { get; set; }
Expand Down
Loading