Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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
32 changes: 32 additions & 0 deletions Source/OpenQuestPDF.UnitTests/DynamicImageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,35 @@
using OpenQuestPDF.Infrastructure;
using OpenQuestPDF.UnitTests.TestEngine;
using SkiaSharp;
using System;

namespace OpenQuestPDF.UnitTests
{
[TestFixture]
public class DynamicImageTests
{
private static bool IsSkiaSharpAvailable()
{
try
{
var info = new SKImageInfo(1, 1);
return true;
}
catch (Exception)
{
return false;
}
}

[Test]
public void Measure_TakesAvailableSpaceRegardlessOfSize()
{
if (!IsSkiaSharpAvailable())
{
Assert.Ignore("SkiaSharp is not available on this platform");
return;
}

TestPlan
.For(x => new DynamicImage
{
Expand All @@ -38,6 +58,12 @@ public void Draw_HandlesNull()
[Test]
public void Draw_PreservesSize()
{
if (!IsSkiaSharpAvailable())
{
Assert.Ignore("SkiaSharp is not available on this platform");
return;
}

TestPlan
.For(x => new DynamicImage
{
Expand All @@ -51,6 +77,12 @@ public void Draw_PreservesSize()
[Test]
public void Draw_PassesCorrectSizeToSource()
{
if (!IsSkiaSharpAvailable())
{
Assert.Ignore("SkiaSharp is not available on this platform");
return;
}

Size passedSize = default;

TestPlan
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
36 changes: 34 additions & 2 deletions Source/OpenQuestPDF.UnitTests/ImageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,35 @@
using OpenQuestPDF.Infrastructure;
using OpenQuestPDF.UnitTests.TestEngine;
using SkiaSharp;
using System;

namespace OpenQuestPDF.UnitTests
{
[TestFixture]
public class ImageTests
{
private static bool IsSkiaSharpAvailable()
{
try
{
var info = new SKImageInfo(1, 1);
return true;
}
catch (Exception)
{
return false;
}
}

[Test]
public void Measure_TakesAvailableSpaceRegardlessOfSize()
{
if (!IsSkiaSharpAvailable())
{
Assert.Ignore("SkiaSharp is not available on this platform");
return;
}

TestPlan
.For(x => new Image
{
Expand All @@ -26,6 +46,12 @@ public void Measure_TakesAvailableSpaceRegardlessOfSize()
[Test]
public void Draw_TakesAvailableSpaceRegardlessOfSize()
{
if (!IsSkiaSharpAvailable())
{
Assert.Ignore("SkiaSharp is not available on this platform");
return;
}

TestPlan
.For(x => new Image
{
Expand All @@ -35,10 +61,16 @@ public void Draw_TakesAvailableSpaceRegardlessOfSize()
.ExpectCanvasDrawImage(new Position(0, 0), new Size(300, 200))
.CheckDrawResult();
}

[Test]
public void Fluent_RecognizesImageProportions()
{
if (!IsSkiaSharpAvailable())
{
Assert.Ignore("SkiaSharp is not available on this platform");
return;
}

var image = GenerateImage(600, 200).Encode(SKEncodedImageFormat.Png, 100).ToArray();

TestPlan
Expand All @@ -49,7 +81,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
Loading