[]
        
(Showing Draft Content)

Render to DOCX or RTF

Set C1WordDocument as the rendering target to generate DOCX or RTF output.

The following example renders the configured chart into a DOCX document.

using C1.Chart;
using C1.Word;

// chart is an existing configured FlexChart or FlexDiagram.

using (var doc = new C1WordDocument())
{
    float margin = 72;
    float width = doc.PageSize.Width - 2 * margin;
    float height = (doc.PageSize.Height - 2.5f * margin) / 2;

    chart.Render(doc, margin, margin, width, height);

    doc.Save("Chart.docx");
}

The Save method determines the document format from the file extension.

To generate RTF output, specify the .rtf extension.

doc.Save("Chart.rtf");

or stream-based output, C1WordDocument provides separate methods for saving DOCX and RTF documents.

The following example saves a DOCX document to an existing writable stream.

doc.Save(stream, FileFormat.OpenXml);

To save the document in RTF format, use SaveToRtf.

doc.SaveToRtf(stream);

Note: The stream-based examples assume that the document and writable stream have already been created.