Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1014046
Basic standalone svg textbody
OssianEPPlus Jun 2, 2026
305e171
Removed text decoration if there is none
OssianEPPlus Jun 2, 2026
60741d9
RichTextCollection Shared + renamings
OssianEPPlus Jun 2, 2026
fe70fc7
Renaming and ensuring standalone richtext formatting is applied
OssianEPPlus Jun 2, 2026
15a89f8
Added missing files
OssianEPPlus Jun 2, 2026
32f79df
Fixed trendline data label position.
JanKallman Jun 2, 2026
033d2fb
Merge branch 'feature/DrawingRendererRefactor' of https://github.com/…
JanKallman Jun 2, 2026
742599a
Added functional DrawingRichTextFormat
OssianEPPlus Jun 2, 2026
b44a618
Started adding full support for sub and superscript
OssianEPPlus Jun 2, 2026
284627b
Merge branch 'feature/DrawingRendererRefactor' of https://github.com/…
OssianEPPlus Jun 2, 2026
cc36f8e
Fixed broken sub and superscript after refactor
OssianEPPlus Jun 2, 2026
6d92783
Re-instated textbody margins. Needs revision
OssianEPPlus Jun 2, 2026
60f41f4
Added support for capitalization and start of underline color
OssianEPPlus Jun 3, 2026
c20645a
Renamed test project and adjusted solution file
JanKallman Jun 3, 2026
bd9003d
Merge branch 'feature/DrawingRendererRefactor' of https://github.com/…
OssianEPPlus Jun 3, 2026
70f0021
Added functional colored underline
OssianEPPlus Jun 3, 2026
7d7f9d5
Removed unused method.Added _underlinecolormanager
OssianEPPlus Jun 3, 2026
9860e94
Verified new underline color handling works
OssianEPPlus Jun 3, 2026
05698e9
Cleanup: Commented code
OssianEPPlus Jun 3, 2026
0ba2d56
Cleanup: Removed unused interface
OssianEPPlus Jun 3, 2026
1973fa6
Cleanup: unused file
OssianEPPlus Jun 3, 2026
520e743
Added clearifying comments
OssianEPPlus Jun 3, 2026
7d74166
Merge branch 'develop9' into feature/DrawingRendererRefactor
OssianEPPlus Jun 3, 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
27 changes: 0 additions & 27 deletions src/DrawingRendererTest/DrawingRendererTest.csproj

This file was deleted.

11 changes: 0 additions & 11 deletions src/DrawingRendererTest/Test1.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ public void GenerateSvgForComboCharts_sheet4()
using (var p = OpenTemplatePackage("ChartForSvg.xlsx"))
{
var ws = p.Workbook.Worksheets[3];
//var ix = 1;
//var c = ws.Drawings[ix];
//var svg = renderer.RenderDrawingToSvg(c);
//SaveTextFileToWorkbook($"svg\\ChartForSvg_sheet2_{ix++}.svg", svg);
var ix = 1;
foreach (ExcelChart c in ws.Drawings)
{
var svg = c.ToSvg();
SaveTextFileToWorkbook($"svg\\ChartForSvg_Combo_Sheet4{ix++}.svg", svg);
}
var c = ws.Drawings[ix];
var svg = c.ToSvg();
SaveTextFileToWorkbook($"svg\\ChartForSvg_sheet2_{ix++}.svg", svg);
//var ix = 1;
//foreach (ExcelChart c in ws.Drawings)
//{
// var svg = c.ToSvg();
// SaveTextFileToWorkbook($"svg\\ChartForSvg_Combo_Sheet4{ix++}.svg", svg);
//}
}
}
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
using System.Text;
using System.Threading.Tasks;
using EPPlus.DrawingRenderer.RenderItems.SvgItem;
using EPPlus.Fonts.OpenType.Integration.RichText;
using EPPlus.Fonts.OpenType.Integration.DataHolders;
using System.Drawing;

namespace EPPlus.Export.ImageRenderer.Tests.DrawingShapeRenderer
{
Expand Down Expand Up @@ -52,12 +55,12 @@ public void SvgRectTest()
}

[TestMethod]
public void SvgTextBoxTest()
public void SvgTextRun()
{
BoundingBox bounds = new BoundingBox(0, 0, 500, 500);
StringBuilder sb = new StringBuilder();
var svgShapeRenderer = new SvgShapeRenderer(bounds, sb);


var baseGroup = new GroupRenderItem(bounds);

Expand All @@ -67,31 +70,72 @@ public void SvgTextBoxTest()
background.Height = bounds.Height;
background.FillColor = "aliceBlue";

//var textBody = new RenderTextBody(baseGroup.Bounds, true);
baseGroup.AddChildItem(background);

var rt = new RichTextFormatSimple();
rt.Text = "My text";
rt.UnderlineType = 1;
rt.FontColor = System.Drawing.Color.Black;
rt.Family = "Archivo Narrow";
rt.SubFamily = OfficeOpenXml.Interfaces.Fonts.FontSubFamily.Regular;
rt.Size = 12f;

//var paragraph = new SvgParagraphRenderItem()

var textRun = new SvgTextRunRenderItem(baseGroup.Bounds, rt, rt.Text);
baseGroup.AddChildItem(textRun);


List<RenderItem> items = new List<RenderItem>() { baseGroup };

svgShapeRenderer.Render(items);

var svg = sb.ToString();


SaveTextFileToWorkbook("svg\\textRunStandAlone.svg", svg);
}

[TestMethod]
public void SvgTextBodyTest()
{
BoundingBox bounds = new BoundingBox(0, 0, 500, 500);
StringBuilder sb = new StringBuilder();
var svgShapeRenderer = new SvgShapeRenderer(bounds, sb);

//textBody.
//textBody.Text = "Hello";
//var para = new SvgParagraphRenderItem(textBody, textBody.Bounds);


//var para2 = new DrawingParagraphRenderItem(textBody, textBody.Bounds);
//textBody.Paragraphs.Add
var baseGroup = new GroupRenderItem(bounds);

var background = new RectRenderItem(baseGroup.Bounds);

//para.Runs.Add()
background.Width = bounds.Width;
background.Height = bounds.Height;
background.FillColor = "aliceBlue";

//baseGroup.AddChildItem(background);
//baseGroup.AddChildItem(textBody);
baseGroup.Bounds.Width = bounds.Width;
baseGroup.Bounds.Height = bounds.Height;

var textBody = new SvgTextBodyRenderItem(baseGroup.Bounds, true);
var paragraph = textBody.AddParagraph("Hello");

paragraph.AddText(" There");

var rtItem = new RichTextFormatSimple("Second paragraph", "Archivo Narrow", 16f, true);
rtItem.FontColor = Color.DarkGreen;
var para2 = textBody.AddParagraph(rtItem);

baseGroup.AddChildItem(textBody);
baseGroup.AddChildItem(background);

List<RenderItem> items = new List<RenderItem>() { baseGroup };
textBody.AppendRenderItems(items);

svgShapeRenderer.Render(items);

var svg = sb.ToString();


SaveTextFileToWorkbook("svg\\textBoxStandAlone.svg", svg);
SaveTextFileToWorkbook("svg\\textBodyStandAlone.svg", svg);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>EPPlus.Export.ImageRenderer.Tests.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>EPPlus.DrawingRenderer.Tests.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,5 +637,20 @@ public void CreateChartsWithDifferentSize()
SaveAndCleanup(p);
}
}

[TestMethod]
public void SuperAndSubScript()
{
ExcelPackage.License.SetNonCommercialOrganization("EPPlus Project");
using (var p = OpenTemplatePackage("SuperAndSubScript.xlsx"))
{
var ws = p.Workbook.Worksheets[0];

var currShape = ws.Drawings[0];

var svg = currShape.ToSvg();
SaveTextFileToWorkbook("svg\\SuperAndSubScript.svg", svg);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
using EPPlus.Export.ImageRenderer.RenderItems.Shared;
using EPPlus.Fonts.OpenType.Integration.DataHolders;
using EPPlus.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace EPPlus.DrawingRenderer.RenderItems.SvgItem
{
public class SvgParagraphRenderItem : ParagraphRenderItem
{
public SvgParagraphRenderItem(RenderTextBody body, BoundingBox parent) : base(parent)
public SvgParagraphRenderItem(RenderTextBody body, BoundingBox parent, string text, bool setDefaultFont = true) : base(parent, body, text, setDefaultFont)
{
ImportStyles();
}
public SvgParagraphRenderItem(RenderTextBody textBody, BoundingBox parent, IRichTextFormatSimple rtFormat): base(parent, textBody, rtFormat)
{
ImportStyles();
}

private void ImportStyles()
{
//Import RichText data to each run
foreach (var run in Runs)
{
var textRun = (SvgTextRunRenderItem)run;
var rtOptions = _layoutSystem.InputFragments[run.OriginalRtIdx].RichTextOptions;
if (_layoutSystem.InputFragments.Count != 0 && run.OriginalRtIdx != -1 && rtOptions is IRichTextFormatSimple)
{
textRun.ImportRichTextData((IRichTextFormatSimple)rtOptions);
}
else
{
//If not use the default for the whole paragraph (potentially user specified)
run.ImportFontData(DefaultParagraphFont);
}
}
}

public override RenderItemType Type => RenderItemType.Paragraph;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using EPPlus.Export.ImageRenderer.RenderItems.Shared;
using EPPlus.Fonts.OpenType.Integration.DataHolders;
using EPPlus.Graphics;


namespace EPPlus.DrawingRenderer.RenderItems.SvgItem
{
public class SvgTextBodyRenderItem : RenderTextBody
{
public SvgTextBodyRenderItem(BoundingBox parent, bool autoSize) : base(parent, autoSize)
{
}

public SvgTextBodyRenderItem(BoundingBox parent, double left, double top, double maxWidth, double maxHeight, bool clampedToParent = false, bool autoSize = false) : base(parent, left, top, maxWidth, maxHeight, clampedToParent, autoSize)
{

}

protected override ParagraphRenderItem CreateParagraph(BoundingBox parent, string textIfEmpty = "")
{
return new SvgParagraphRenderItem(this, parent, textIfEmpty);
}

protected override ParagraphRenderItem CreateParagraph(BoundingBox parent, IRichTextFormatSimple richText)
{
return new SvgParagraphRenderItem(this, parent, richText);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace EPPlus.DrawingRenderer.RenderItems.SvgItem
{
internal class SvgTextRunRenderItem : TextRunRenderItem
public class SvgTextRunRenderItem : TextRunRenderItem
{
public SvgTextRunRenderItem(BoundingBox parent) : base(parent)
{
Expand Down
Loading
Loading