Skip to content

Commit

Permalink
Improve the performance
Browse files Browse the repository at this point in the history
  • Loading branch information
VahidN committed Feb 26, 2024
1 parent 462044f commit 8007b8f
Show file tree
Hide file tree
Showing 36 changed files with 5,122 additions and 1,887 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Build iTextSharp.LGPLv2.Core lib
run: dotnet build ./src/iTextSharp.LGPLv2.Core/iTextSharp.LGPLv2.Core.csproj --configuration Release

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Build
run: dotnet build --configuration Release

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.402",
"version": "8.0.200",
"rollForward": "latestMajor",
"allowPrerelease": false
}
Expand Down
90 changes: 90 additions & 0 deletions src/iTextSharp.LGPLv2.Core.FunctionalTests/Issues/Issue140.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.draw;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace iTextSharp.LGPLv2.Core.FunctionalTests.Issues;

internal abstract class PdfShape : VerticalPositionMark
{
public const float DefaultShapeWidth = 4.2f;
public const float DefaultCenterOffset = -4.2f;
public const float DefaultStokeThickness = 0.8f;

public static readonly BaseColor DarkBlue = new(0, 0, 139, 255);

protected float DetalY;

public PdfShape(float detalY = 0)
=> DetalY = detalY;

public sealed override void Draw(PdfContentByte canvas, float llx, float lly, float urx, float ury, float y)
=> DrawShape(canvas, urx, y);

public abstract void DrawShape(PdfContentByte canvas, float x0, float y0);
}

internal class GeoCheckMark : PdfShape
{
private readonly float _detalX;
private readonly float _detalY;

public GeoCheckMark(float detalX, float detalY)
{
_detalX = detalX;
_detalY = detalY;
}

public override void DrawShape(PdfContentByte canvas, float x0, float y0)
{
canvas.SaveState();

var _x0 = x0 + _detalX;
var _y0 = y0 + DefaultShapeWidth + _detalY;
canvas.MoveTo(_x0, _y0);
canvas.LineTo(_x0 + DefaultShapeWidth, _y0 - DefaultShapeWidth);
canvas.LineTo(_x0 + DefaultShapeWidth * 2, _y0 + DefaultShapeWidth);
canvas.LineTo(_x0 + DefaultShapeWidth, _y0 - DefaultShapeWidth / 2);
canvas.FillStroke();
canvas.Fill();

canvas.RestoreState();
}
}

/// <summary>
/// https://github.com/VahidN/iTextSharp.LGPLv2.Core/issues/140
/// </summary>
[TestClass]
public class Issue140
{
[TestMethod]
public void Test_Issue140_Verify_MissingMethodException_Works()
{
var outFile = TestUtils.GetOutputFileName();

using (var fileStream = new FileStream(outFile, FileMode.Create))
{
using var pdfDoc = new Document(PageSize.A4, 15, 15, 15, 15);
var wt = PdfWriter.GetInstance(pdfDoc, fileStream);

pdfDoc.AddAuthor(TestUtils.Author);
pdfDoc.Open();

var rootTab = new PdfPTable(1)
{
WidthPercentage = 100,
SplitLate = false,
SplitRows = true
};

var cell = new PdfPCell();
cell.AddElement(new GeoCheckMark(-22, -8));
rootTab.AddCell(cell);
pdfDoc.Add(rootTab);
}

TestUtils.VerifyPdfFileIsReadable(outFile);
}
}
2 changes: 1 addition & 1 deletion src/iTextSharp.LGPLv2.Core/iTextSharp.LGPLv2.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>iTextSharp.LGPLv2.Core is an unofficial port of the last LGPL version of the iTextSharp (V4.1.6) to .NET Core.</Description>
<VersionPrefix>3.4.17</VersionPrefix>
<VersionPrefix>3.4.18</VersionPrefix>
<LangVersion>latest</LangVersion>
<Authors>Vahid Nasiri</Authors>
<TargetFrameworks>netstandard2.0;net462;</TargetFrameworks>
Expand Down
Loading

0 comments on commit 8007b8f

Please sign in to comment.