Printout CHART to C1Document

Originally Posted 5 September 2016, 3:07 am EST

  • Originally Posted 5 September 2016, 3:07 am EST

    If I want to put a chart into C1Document I try is as follow:

    C1PrintDocument pDoc;

    RenderTable btChart = new RenderTable(pDoc);

    btChart.Cols.Insert(0, 1);
    btChart.Rows.Insert(0, 1);
    btChart.Cols[0].Width = new Unit(100, UnitTypeEnum.Mm);
    btChart.Rows[0].Height = new Unit(150, UnitTypeEnum.Mm);
    btChart.Cells[0, 0].Style.ImageAlign.BestFit = true;
    btChart.Cells[0, 0].Style.ImageAlign.StretchHorz = true;
    btChart.Cells[0, 0].Style.ImageAlign.StretchVert = true;
    btChart.Cells[0, 0].Style.ImageAlign.AlignHorz = C1.C1Preview.ImageAlignHorzEnum.Center;
    btChart.Cells[0, 0].Style.ImageAlign.AlignVert = C1.C1Preview.ImageAlignVertEnum.Top;

    Size lSz = new Size();

    lSz.Height = (int)((150 / 25.4 * 100) * 1.5); //Do know why - so it works!!
    lSz.Width = (int)((100 / 25.4 * 100) * 1.5);

    Image ChartImg = pChart.GetImage(System.Drawing.Imaging.ImageFormat.Png, lSz);
    RenderImage ri = new RenderImage(rTable.Document);
    ri.Image = ChartImg;
    rTable.Cells[0,0].RenderObject = ri;

    Is this the right way?
    What ist the unit for lSz (Size)?

    For example:
    I have a Y-Axis with the range 0...100.
    I want that the length of this axis is 10cm on the printout.
    Is there a easy way to do this?

    Thanks Horst
  • Marked as Answer


    Hi Horst,

    Thanks for providing the code snippet.

    The procedure you are using to show the chart in C1PrintDocument is the right way.

    Furthermore, the unit of the Size structure objects are mostly measured in Pixels. For more information follow the link given below:

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels