Spire.Doc 14.4.4 supports saving charts as templates

Spire.Doc 14.4.4 supports saving charts as templates

2026-04-21 05:53:03

We're pleased to announce the release of Spire.Doc 14.4.4. This version supports saving charts as templates and allows configuring the Producer metadata when converting to PDF via the GeneratorName property. Additionally, it supports retrieving X and Y axis data values and managing chart data label positions. Meanwhile, some issues that occurred when converting Markdown to PDF/Docx and merging Word documents have also been successfully fixed. More details are listed below.

Here is a list of changes made in this release

Category ID Description
Adjustment - Renamed ToPdfParameterList.IsAtlast to ToPdfParameterList.IsAtLeast.
ToPdfParameterList.IsAtlast-->ToPdfParameterList.IsAtLeast
New Feature SPIREDOC-10293 Supports saving charts as templates.
Document doc = new Document();
doc.LoadFromFile(inputFile);
int count = 1;
foreach (Section sec in doc.Sections)
{
    foreach (Spire.Doc.Documents.Paragraph paragraph in sec.Paragraphs)
    {
        foreach (DocumentObject obj in paragraph.ChildObjects)
        {
            if (obj is ShapeObject shape)
            {
                Chart chart = shape.Chart;
                if (chart == null)
                    continue;

                string fileName = Path.Combine(outputPath, $"{count}.crtx");
                chart.SaveAsTemplate(fileName);
                count++;
            }
        }
    }
}
New Feature SPIREDOC-11457 Adds the GeneratorName property to allow configuring the Producer metadata when converting to PDF.
string genName = "Testing For Set Producer";
 Document doc = new Document();
 doc.LoadFromFile(filename);
 ToPdfParameterList toPdf = new ToPdfParameterList();
 toPdf.GeneratorName = genName;
 doc.SaveToFile("result.pdf", toPdf);
New Feature SPIREDOC-10828 Adds XValues and YValues properties to retrieve data values for specified series in charts.
Document doc = new Document();
doc.LoadFromFile(inputFile);
StringBuilder sb = new StringBuilder();
int number = 1;

foreach (Section sec in doc.Sections)
{
    foreach (Paragraph paragraph in sec.Paragraphs)
    {
        for (int i = 0; i < paragraph.ChildObjects.Count; i++)
        {
            DocumentObject obj = paragraph.ChildObjects[i];
            if (obj is ShapeObject)
            {
                ShapeObject shape = obj as ShapeObject;
                Chart chart = shape.Chart;
                sb.Append("\r\n\r\nPage " + number + ":\r\n" + "Get all X-axis data: ");
                for (int x = 0; x < chart.XValues.Count; x++)
                {
                    ChartValue xVal = chart.XValues[x];
                    // Get all X-axis data values
                    sb.Append(xVal.StringValue + " "); 
                }
                // Get the first series
                ChartSeries series = chart.Series[0]; 
                sb.Append("\r\nGet Y-axis data: ");
                foreach (ChartValue yVal in series.YValues)
                {
                    // Get all Y-axis data values of the first series
                    sb.Append(yVal.Value + " ");  
                }
            }
        }
    }
    number++;
}
New Feature SPIREDOC-11457 Supports reading and setting chart data label positions.
Document doc = new Document();
foreach (ChartDataLabelPosition position in Enum.GetValues(typeof(ChartDataLabelPosition)))
{
    Section section = doc.AddSection();
    section.AddParagraph().AppendText(position.ToString());
    Spire.Doc.Documents.Paragraph newPara = section.AddParagraph();
    ShapeObject shape = newPara.AppendChart(ChartType.Pie, 500, 300);
    Chart chart = shape.Chart;
    chart.Series[0].HasDataLabels = true;
    chart.Series[0].DataLabels.ShowCategoryName = true;
    chart.Series[0].DataLabels.ShowValue = true;
    // Set position
    chart.Series[0].DataLabels.Position = position;

    ShapeObject shape2 = newPara.AppendChart(ChartType.Bubble, 500, 300);
    Chart chart2 = shape2.Chart;
    chart2.Series[0].HasDataLabels = true;
    chart2.Series[0].DataLabels.ShowCategoryName = true;
    chart2.Series[0].DataLabels.ShowValue = true;
    chart2.Series[0].DataLabels.Position = position;
}
doc.SaveToFile(outputFile, FileFormat.Docx);
doc.Dispose();
Bug Fix SPIREDOC-11586 Fixes the issue where tables were converted incorrectly when converting Markdown to Docx or PDF.
Bug Fix SPIREDOC-11854 Fixes the issue where merged cells in tables were split incorrectly.
Bug Fix SPIREDOC-11871 Fixes the issue where a System.InvalidCastException was thrown when merging Word documents.
Bug Fix SPIREDOC-11874 Fixes the issue where a System.NullReferenceException was thrown when loading HTML.
Click the link to download Spire.Doc 14.4.4:
More information of Spire.Doc new release or hotfix: