Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
da56da6
started work on adding embedded fonts in pdf.
AdrianEPPlus Feb 4, 2026
d7d25e1
Added more pdf objects for embedding fonts in pdf
AdrianEPPlus Feb 6, 2026
52eb11b
progress embedding fonts
AdrianEPPlus Feb 9, 2026
8ab0534
font embedding progress. making stuff binary.
AdrianEPPlus Feb 10, 2026
518d54f
Fixed many issues with embedding font. Still some issues left.
AdrianEPPlus Feb 11, 2026
51e3771
embedding font progress
AdrianEPPlus Feb 12, 2026
1ba477a
fixed t
AdrianEPPlus Feb 12, 2026
c96c9c1
Merge branch 'develop9' into feature/pdf-embedd-font
AdrianEPPlus Feb 13, 2026
dadb474
fixed issues from develop9
AdrianEPPlus Feb 16, 2026
9bf9fa7
Removed unused code, added comments and clean up some parts.
AdrianEPPlus Feb 16, 2026
03fe8ed
Rich Text added
AdrianEPPlus Feb 17, 2026
5aaf93a
Added more text features for embedding fonts.
AdrianEPPlus Feb 18, 2026
5f827ba
Add Columns For Non Wrapped Text
AdrianEPPlus Feb 19, 2026
ad5c2e4
new gridline system started.
AdrianEPPlus Feb 19, 2026
49e450c
Vertical Gridlines progress
AdrianEPPlus Feb 20, 2026
52d8101
gridlines progress.
AdrianEPPlus Feb 23, 2026
b1ff755
need better algo for gridlines.
AdrianEPPlus Feb 23, 2026
43a7f62
Refactoring page layouting
AdrianEPPlus Feb 24, 2026
9170a60
added
AdrianEPPlus Feb 25, 2026
e82c949
Improved support for fallbackfonts
swmal Feb 25, 2026
0327900
progress
AdrianEPPlus Feb 25, 2026
031208f
progress
AdrianEPPlus Feb 26, 2026
42bbc6c
Fallbackfonts refactoring
swmal Feb 26, 2026
7f38666
horizontal gridlines progress
AdrianEPPlus Feb 26, 2026
894ac37
vertical border progress.
AdrianEPPlus Feb 27, 2026
4e4549a
More work on fallback fonts. Added fallback to Archivo fonts if the p…
Feb 27, 2026
672c017
Merge branch 'develop9' into feature/fallbackfonts-v2
swmal Mar 2, 2026
80bc076
Fixed some tests
swmal Mar 2, 2026
26712c3
gridlines appear to work correctly now. Just need some smaller adjust…
AdrianEPPlus Mar 2, 2026
9323907
Merge branch 'develop9' into feature/pdf-embedd-font
AdrianEPPlus Mar 2, 2026
85fa2cd
Fixed issue with ttc files
swmal Mar 2, 2026
d10c89e
rewriting page setup started.
AdrianEPPlus Mar 2, 2026
2d23159
new system works just need some tweaks
AdrianEPPlus Mar 3, 2026
bbee712
Merge branch 'feature/fallbackfonts-v2' into feature/pdfnewfontdata
AdrianEPPlus Mar 3, 2026
d8cf224
Fallback fonts.
AdrianEPPlus Mar 3, 2026
4ed8368
progress
AdrianEPPlus Mar 4, 2026
2d79649
progress
AdrianEPPlus Mar 5, 2026
905162a
fallback fonts for emojis now work
AdrianEPPlus Mar 9, 2026
e5cdabe
Fixed border issues.
AdrianEPPlus Mar 10, 2026
7e7af11
Added headerFooter back
AdrianEPPlus Mar 11, 2026
344ba40
Added some small fixes liike adjusting cells, removing cells and clip…
AdrianEPPlus Mar 12, 2026
946bc3a
added comments
AdrianEPPlus Mar 16, 2026
437ead7
Fix for strings only containing of fallback fonts. Removed unitPerEm …
swmal Mar 16, 2026
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
164 changes: 24 additions & 140 deletions src/EPPlus.Export.Pdf.Tests/PdfTests.cs

Large diffs are not rendered by default.

115 changes: 29 additions & 86 deletions src/EPPlus.Export.Pdf/ExcelPdf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ Date Author Change
using System.Text;
using OfficeOpenXml;
using EPPlus.Graphics;
using System.Drawing;
using EPPlus.Export.Pdf.Pdfhelpers;
using EPPlus.Export.Pdf.PdfLayout;
using EPPlus.Export.Pdf.PdfObjects;
using EPPlus.Export.Pdf.PdfResources;
using EPPlus.Export.Pdf.PdfSettings;
using OfficeOpenXml.Style;
using EPPlus.Fonts.OpenType;
using OfficeOpenXml.Interfaces.Fonts;

namespace EPPlus.Export.Pdf
{
Expand Down Expand Up @@ -87,28 +86,6 @@ public ExcelPdf(ExcelRangeBase Range, PdfPageSettings pageSettings = null)
//PageSettings = pageSettings == null ? new PdfPageSettings() : pageSettings;
}

//Get font label //need to update this one too for same reasons as AddFontData
internal PdfFontResource GetFontResource(string fontName, FontSubFamily subFamily, double fontSize)
{
if (!Dictionaries.Fonts.ContainsKey(fontName))
{
int label = 1;
if (Dictionaries.Fonts.Count > 0)
{
label = Dictionaries.Fonts.Last().Value.labelNumber + 1;
}
PdfFontResource fr = new PdfFontResource(fontName, subFamily, label, PageSettings);
if (fontName != "Courier New")
{
Document.Add(fr.GetFontDescriptorObject(Document.Count + 1));
Document.Add(fr.GetWidthsObject(Document.Count + 1));
}
Document.Add(fr.GetFontObject(Document.Count + 1));
Dictionaries.Fonts.Add(fontName, fr);
}
return Dictionaries.Fonts[fontName];
}

//Get the label to use for pattern.
internal string GetPatternLabel(PdfCellLayout layout)
{
Expand All @@ -123,17 +100,32 @@ internal string GetPatternLabel(PdfCellLayout layout)
return null;
}

//Add Fonts //Need to update this method a bit. We should check for all default fonts and not only courier new?
//Add Fonts //Need to update this method a bit. We should check for all default fonts and not only courier new? Also need to check if we are allowed to embedd the font.
internal void AddFontData()
{
foreach (var font in Dictionaries.Fonts)
if (PageSettings.EmbeddFonts)
{
foreach (var font in Dictionaries.Fonts)
{
//font.Value.CreateGidsAndCharMaps();
var CidSet = font.Value.GetCidSet(Document.Count + 1);
if (CidSet != null) Document.Add(CidSet);
Document.Add(font.Value.GetEmbeddedFontStreamObject(Document.Count + 1));
Document.Add(font.Value.GetFontDescriptorObject(Document.Count + 1));
Document.Add(font.Value.GetCIDFontObject(Document.Count + 1));
Document.Add(font.Value.GetUnicodeCmapObject(Document.Count + 1));
Document.Add(font.Value.GetType0FontDictObject(Document.Count + 1));
font.Value.GetFontObject(Document.Count);
}
}
else
{
if (font.Key != "Courier New")
foreach (var font in Dictionaries.Fonts)
{
Document.Add(font.Value.GetFontDescriptorObject(Document.Count + 1));
Document.Add(font.Value.GetWidthsObject(Document.Count + 1));
Document.Add(font.Value.GetFontObject(Document.Count + 1));
}
Document.Add(font.Value.GetFontObject(Document.Count + 1));
}
}

Expand Down Expand Up @@ -167,13 +159,15 @@ private PdfPage AddPage(int pagesObjectNumber, List<int> contentObjectNumbers, P
Document.Add(page);
return page;
}

//Create Pages
private PdfPages AddPages()
{
var pages = new PdfPages(Document.Count + 1, new List<int>{});
Document.Add(pages);
return pages;
}

//Create Catalog
private PdfCatalog AddCatalog(int pagesObjectNumber)
{
Expand All @@ -187,13 +181,14 @@ private void AddContent(Transform pageLayout, PdfPage page)
{
var cells = pageLayout.ChildObjects.Where(t => t is PdfCellLayout || t is PdfCellContentLayout || t is PdfCellBorderLayout).GroupBy(t => t.Name);
var contentStream = new PdfContentStream(Document.Count + 1);
contentStream.AddCommand($"% {pageLayout.Name} start");
//Add clipping rectangle around page content.
contentStream.AddCommand("q");
contentStream.AddMarginClipping(pageLayout, PageSettings.ContentBounds);
if (PageSettings.ShowGridLines)
{
contentStream.AddInnerGridLines(pageLayout);
}
//Add clipping rectangle around page content.
contentStream.AddCommand("q");
contentStream.AddMarginClipping(pageLayout, PageSettings.ContentBounds);
foreach (var cell in cells)
{
foreach (var cellPart in cell)
Expand Down Expand Up @@ -223,6 +218,7 @@ private void AddContent(Transform pageLayout, PdfPage page)
AddHeaderFooter(contentStream, pageLayout, page);
Document.Add(contentStream);
page.contentObjectNumbers.Add(contentStream.objectNumber);
contentStream.AddCommand($"% {pageLayout.Name} end");
}

//Add Header Footer
Expand All @@ -236,6 +232,7 @@ private void AddHeaderFooter(PdfContentStream contentStream, Transform pageLayou
}
}

//Add Info
private PdfInfoObject AddInfoObject()
{
var info = new PdfInfoObject(Document.Count + 1, _workheets[0].Workbook._package.File.Name);
Expand Down Expand Up @@ -285,7 +282,7 @@ public void CreatePdf(string Filename)
foreach (var pdfobj in Document)
{
crossRefTable.AddPosition(fs.Position);
bw.Write(pdfobj.ToPdfBytes());
pdfobj.ToPdfBytes(bw);
debugString += pdfobj.ToPdfString();
}
//Write CrossReference
Expand All @@ -308,59 +305,5 @@ public void CreatePdf(string Filename)
}
}
}

#region DEBUG
//These methods need to be rewritten if they should be used.

//internal void DrawMarginAndHeaderLines(PdfContentBounds bounds, PdfPage page)
//{
// var content = new PdfContentStream(Document.Count + 1);
// //Bottom line
// DrawLine(content, Color.Black, 0, bounds.Bottom, PageSettings.PageSize.WidthPu, bounds.Bottom);
// DrawLine(content, new Color(1, 0, 1), bounds.X, bounds.Bottom, bounds.X + bounds.Width, bounds.Bottom);
// //Top line
// DrawLine(content, Color.Black, 0, bounds.Top, PageSettings.PageSize.WidthPu, bounds.Top);
// DrawLine(content, new Color(1, 0, 1), bounds.X, bounds.Top, bounds.X + bounds.Width, bounds.Top);
// //Left line
// DrawLine(content, Color.Black, bounds.Left, 0, bounds.Left, 0);
// DrawLine(content, new Color(1, 0, 1), bounds.Left, bounds.Y + bounds.Height, bounds.Left, bounds.Y + bounds.Height);
// //Right line
// DrawLine(content, Color.Black, bounds.Right, 0, bounds.Right, 0);
// DrawLine(content, new Color(1, 0, 1), bounds.Right, bounds.Y + bounds.Height, bounds.Right, bounds.Y + bounds.Height);
// //Header line
// DrawLine(content, new Color(1, 0, 1), bounds.Right, bounds.HeaderY, bounds.Left, bounds.HeaderY);
// DrawLine(content, new Color(1, 0, 1), bounds.CenterHeaderX, bounds.Top, bounds.CenterHeaderX, bounds.Top);
// DrawLine(content, new Color(1, 0, 1), bounds.RightHeaderX, bounds.Top, bounds.RightHeaderX, bounds.Top);
// //Footer line
// DrawLine(content, new Color(1, 0, 1), bounds.Right, bounds.FooterY, bounds.Left, bounds.FooterY);
// DrawLine(content, new Color(1, 0, 1), bounds.CenterFooterX, bounds.Bottom, bounds.CenterFooterX, bounds.Bottom);
// DrawLine(content, new Color(1, 0, 1), bounds.RightFooterX, bounds.Bottom, bounds.RightFooterX, bounds.Bottom);
// Document.Add(content);
// page.contentObjectNumbers.Add(content.objectNumber);
//}

//internal void DrawLine(PdfContentStream content, Color color, double x1, double y1, double x2, double y2)
//{
// content.AddCommand(color.ToStrokeCommand());
// content.AddCommand($"{x1.ToPdfString()} {y1.ToPdfString()} m");
// content.AddCommand($"{x2.ToPdfString()} {y2.ToPdfString()} l");
// content.AddCommand("S");
//}

//internal void DrawCrossHair(Color color, double x, double y, double size = 2)
//{
// var half = size / 2d;
// var content = new PdfContentStream(Document.Count + 1);
// content.AddCommand(color.ToStrokeCommand());
// content.AddCommand($"{x.ToPdfString()} {(y - half).ToPdfString()} m");
// content.AddCommand($"{x.ToPdfString()} {(y + half).ToPdfString()} l");
// content.AddCommand($"{(x - half).ToPdfString()} {y.ToPdfString()} m");
// content.AddCommand($"{(x + half).ToPdfString()} {y.ToPdfString()} l");
// content.AddCommand("S");
// Document.Add(content);
//}


#endregion
}
}
88 changes: 0 additions & 88 deletions src/EPPlus.Export.Pdf/PdfFontData/PdfFontDataReader.cs

This file was deleted.

73 changes: 0 additions & 73 deletions src/EPPlus.Export.Pdf/PdfFontData/PdfFontProperties.cs

This file was deleted.

6 changes: 6 additions & 0 deletions src/EPPlus.Export.Pdf/PdfLayout/IBorderLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ Date Author Change

namespace EPPlus.Export.Pdf.PdfLayout
{
/// <summary>
/// Interface for border objects
/// </summary>
internal interface IBorderLayout
{
/// <summary>
/// Update Border positions.
/// </summary>
abstract void UpdateLocalBorderPosition();
}
}
6 changes: 6 additions & 0 deletions src/EPPlus.Export.Pdf/PdfLayout/IShadingLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ Date Author Change

namespace EPPlus.Export.Pdf.PdfLayout
{
/// <summary>
/// Interface for shading objects.
/// </summary>
internal interface IShadingLayout
{
/// <summary>
/// Update position matrix.
/// </summary>
abstract void UpdateShadingPositionMatrix(PdfPageSettings pageSettings);
}
}
Loading