Skip to content

Commit 1a09a51

Browse files
committed
Merge branch 'develop9' into feature/embeddable-fonts-v3
2 parents 0bd13da + 95e3338 commit 1a09a51

33 files changed

Lines changed: 2627 additions & 581 deletions

src/EPPlus.Export.Pdf.Tests/EPPlus.Export.Pdf.Tests.csproj

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,25 @@
33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
55
<LangVersion>latest</LangVersion>
6-
<SignAssembly>true</SignAssembly>
7-
<AssemblyOriginatorKeyFile>EPPlus.Export.Pdf.Tests.snk</AssemblyOriginatorKeyFile>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<SignAssembly>True</SignAssembly>
8+
<IsTestProject>true</IsTestProject>
9+
<AssemblyOriginatorKeyFile>EPPlus.Export.Pdf.Tests.snk</AssemblyOriginatorKeyFile>
810
</PropertyGroup>
911

1012
<ItemGroup>
11-
<Compile Remove="FontLabs1\**" />
12-
<EmbeddedResource Remove="FontLabs1\**" />
13-
<None Remove="FontLabs1\**" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
14+
<PackageReference Include="MSTest.TestAdapter" />
15+
<PackageReference Include="MSTest.TestFramework" />
1416
</ItemGroup>
1517

1618
<ItemGroup>
19+
<ProjectReference Include="..\..\..\EPPlus\src\EPPlusTest\EPPlus.Test.csproj" />
1720
<ProjectReference Include="..\EPPlus.Export.Pdf\EPPlus.Export.Pdf.csproj" />
18-
<ProjectReference Include = "..\..\..\EPPlus\src\EPPlusTest\EPPlus.Test.csproj" />
1921
</ItemGroup>
2022

2123
<ItemGroup>
2224
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
2325
</ItemGroup>
2426

25-
<ItemGroup>
26-
<PackageReference Include="Microsoft.NET.Test.Sdk" />
27-
<PackageReference Include="MSTest.TestAdapter" />
28-
<PackageReference Include="MSTest.TestFramework" />
29-
</ItemGroup>
30-
3127
</Project>

src/EPPlus.Export.Pdf.Tests/PdfTests.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ Date Author Change
1818
using EPPlus.Export.Pdf;
1919
using EPPlus.Export.Pdf.PdfSettings;
2020
using EPPlus.Export.Pdf.PdfSettings.PdfPageSizes;
21-
using OfficeOpenXml;
2221

2322
namespace EPPlusTest.PDF
2423
{
2524
[TestClass]
26-
public class PdfTests
25+
public class PdfTests : TestBase
2726
{
2827
/* BIG PDF TODO
2928
* This should be turned into tickets on github..
@@ -34,25 +33,25 @@ public class PdfTests
3433
* Cells: Pictures in cells
3534
* Cells: Remove stroke from solid fill and adjust size and position of cell more precise and only use fill command.
3635
*
37-
* HeaderFooter: Header Footer implementation
36+
* Merged Cells: Merged cells with no color set will have the color set to white to hide gridlines. They should not have color set to keep tranparency if we want to include background.
3837
*
3938
* Tables: Table Implementation
39+
* Tables: Fix order of applying table styling. Right now Table is used if it exsists, but cell styling should be prioritised and table should be ignored if cell has styluing.
4040
*
4141
* Patterns: Adjust and make patterns look better. Fixed: DarkUp, DarkDown
4242
*
4343
* Gradients: Make diamond gradients instead of radial gradtient in from corner and center gradient
4444
*
45-
* Text: Rich Text Implementation
4645
* Text: Bold (Can now do back up bold if bold font not found)
4746
* Text: Italic (Can now do back up italic if italic font not found)
4847
* Text: Underline (Basic underline done, need double and single and double accounting)
4948
* Text: Strikethrough (Done, small adjustments to line to match excel perhaps)
5049
* Text: Superscript (Done, might need adjustments such as moving it towrds top of cell more)
5150
* Text: Subscript (Done, might need adjustments. Excel adjusts cell height and moves subscript lower inside the cell)
52-
* Text: Wrap text
5351
* Text: Equations
5452
* Text: Shrink To Fit
55-
* Text: Rotation
53+
* Text: Broken text hide when overlapping other cells with text
54+
* Text: Center vertical text
5655
*
5756
* Layout: Center on page Horizontal and vertical
5857
* Layout: Scaling
@@ -65,11 +64,9 @@ public class PdfTests
6564
* Layout: Cell range to pdf
6665
* Layout: Remove empty last page
6766
* Layout: Calculate width and height of cells more correctly
67+
* Layout: Fix Mask away stuff outside margins being broken
6868
*
6969
* Borders: Adjust and make border look better
70-
* Borders: Check Adjecent cells for border decied which cells border to use
71-
* Borders: Handle Merged cells with borders
72-
* Borders: Fix diagnal border in merged cell
7370
*
7471
* Pivot Table: Pivot table implementation
7572
*
@@ -86,7 +83,10 @@ public class PdfTests
8683
[TestMethod]
8784
public void TestWritePdf()
8885
{
89-
using var p = new ExcelPackage("C:\\epplusTest\\Workbooks\\PDFTest.xlsx");// OpenTemplatePackage("PDFTest.xlsx");
86+
using var p = OpenTemplatePackage("PDFTest.xlsx");
87+
//using var p = OpenTemplatePackage("PDFTest - Copy (2).xlsx");
88+
89+
//using var p = OpenTemplatePackage("PdfBorders.xlsx");
9090
//using var p = OpenTemplatePackage("PdfGrids\\3 2 Page Crazy Cells.xlsx");
9191
//using var p = OpenTemplatePackage("PdfGrids\\3 2 Page Crazy Cells Merged.xlsx");
9292
//using var p = OpenTemplatePackage("Gradient.xlsx");
@@ -103,7 +103,7 @@ public void TestWritePdf()
103103
pageSettings.PrintAsText = true;
104104

105105
ExcelPdf pedeef = new ExcelPdf(ws, pageSettings);
106-
pedeef.CreatePdf("c:\\epplustest\\pdf\\FullPageTest33.pdf");
106+
pedeef.CreatePdf("c:\\epplustest\\pdf\\FullPageTest40.pdf");
107107
}
108108

109109
static byte[] HexStringToBytes(string hex)

src/EPPlus.Export.Pdf/ExcelPdf.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ internal PdfFontResource GetFontResource(string fontName, FontSubFamily subFamil
112112
//Get the label to use for pattern.
113113
internal string GetPatternLabel(PdfCellLayout layout)
114114
{
115-
if ((layout.CellFillData.PattenStyle != ExcelFillStyle.Solid && layout.CellFillData.PattenStyle != ExcelFillStyle.None) || layout.CellFillData.GradientFillData != null)
115+
if ((layout.CellFillData.PatternStyle != ExcelFillStyle.Solid && layout.CellFillData.PatternStyle != ExcelFillStyle.None) || layout.CellFillData.GradientFillData != null)
116116
{
117117
var patternName = layout.CellFillData.id;
118118
if (Dictionaries.Patterns.ContainsKey(patternName))
@@ -204,24 +204,38 @@ private void AddContent(Transform pageLayout, PdfPage page)
204204
contentStream.AddCellLayout(layout, GetPatternLabel(layout));
205205
break;
206206
case PdfCellContentLayout contentLayout:
207-
contentStream.AddCellContentLayout(contentLayout, GetFontResource(contentLayout.FontData.FullFontName, contentLayout.FontData.SubFamily, contentLayout.FontData.FontSize));
207+
contentStream.AddCellContentLayout(contentLayout, Dictionaries, PageSettings);
208208
break;
209209
case PdfCellBorderLayout borderLayout:
210210
contentStream.AddBorderLayout(borderLayout);
211211
break;
212212
}
213213
}
214214
}
215-
//Close the clipping rectangle
215+
//Close the clipping rectangle.
216216
contentStream.AddCommand("Q");
217+
contentStream.AddCommand($"% Margin Clip End");
217218
if (PageSettings.ShowGridLines)
218219
{
219220
contentStream.AddOuterGridBorder(pageLayout);
220221
}
222+
//Add header and footer.
223+
AddHeaderFooter(contentStream, pageLayout, page);
221224
Document.Add(contentStream);
222225
page.contentObjectNumbers.Add(contentStream.objectNumber);
223226
}
224227

228+
//Add Header Footer
229+
private void AddHeaderFooter(PdfContentStream contentStream, Transform pageLayout, PdfPage page)
230+
{
231+
var headerFooter = pageLayout.ChildObjects.Where(t => t is PdfHeaderFooterLayout);
232+
foreach (var hf in headerFooter)
233+
{
234+
var headerFooterLayout = hf as PdfHeaderFooterLayout;
235+
contentStream.AddCellContentLayout(headerFooterLayout, Dictionaries, PageSettings);
236+
}
237+
}
238+
225239
private PdfInfoObject AddInfoObject()
226240
{
227241
var info = new PdfInfoObject(Document.Count + 1, _workheets[0].Workbook._package.File.Name);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*************************************************************************************************
2+
Required Notice: Copyright (C) EPPlus Software AB.
3+
This software is licensed under PolyForm Noncommercial License 1.0.0
4+
and may only be used for noncommercial purposes
5+
https://polyformproject.org/licenses/noncommercial/1.0.0/
6+
7+
A commercial license to use this software can be purchased at https://epplussoftware.com
8+
*************************************************************************************************
9+
Date Author Change
10+
*************************************************************************************************
11+
27/11/2025 EPPlus Software AB EPPlus 9
12+
*************************************************************************************************/
13+
14+
namespace EPPlus.Export.Pdf.PdfLayout
15+
{
16+
internal interface IBorderLayout
17+
{
18+
abstract void UpdateLocalBorderPosition();
19+
}
20+
}

src/EPPlus.Export.Pdf/PdfLayout/ILayout.cs renamed to src/EPPlus.Export.Pdf/PdfLayout/IShadingLayout.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Date Author Change
1414

1515
namespace EPPlus.Export.Pdf.PdfLayout
1616
{
17-
internal interface ILayout
17+
internal interface IShadingLayout
1818
{
19-
void ConvertCoordinates(PdfPageSettings pageSettings);
19+
abstract void UpdateShadingPositionMatrix(PdfPageSettings pageSettings);
2020
}
2121
}

0 commit comments

Comments
 (0)