Chart.ToPdf
Contents
[
Hide
]ToPdf(string)
Saves the chart to a pdf file.
public void ToPdf(string fileName)
Parameter | Type | Description |
---|---|---|
fileName | String | the pdf file name with full path |
Examples
using System;
using Aspose.Cells;
using Aspose.Cells.Charts;
namespace AsposeCellsExamples
{
public class ChartMethodToPdfWithStringDemo
{
public static void Run()
{
// Create a new workbook
Workbook workbook = new Workbook();
// Access first worksheet and add sample data
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Cells["A1"].PutValue("Category");
worksheet.Cells["A2"].PutValue("Fruits");
worksheet.Cells["A3"].PutValue("Vegetables");
worksheet.Cells["B1"].PutValue("Value");
worksheet.Cells["B2"].PutValue(50);
worksheet.Cells["B3"].PutValue(30);
// Add a chart to the worksheet
int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 5, 0, 20, 8);
Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex];
// Set chart data source
chart.NSeries.Add("B2:B3", true);
chart.NSeries.CategoryData = "A2:A3";
// Export chart to PDF
chart.ToPdf("output_chart.pdf");
Console.WriteLine("Chart exported to PDF successfully.");
}
}
}
See Also
- class Chart
- namespace Aspose.Cells.Charts
- assembly Aspose.Cells
ToPdf(string, float, float, PageLayoutAlignmentType, PageLayoutAlignmentType)
Saves the chart to a pdf file.
public void ToPdf(string fileName, float desiredPageWidth, float desiredPageHeight,
PageLayoutAlignmentType hAlignmentType, PageLayoutAlignmentType vAlignmentType)
Parameter | Type | Description |
---|---|---|
fileName | String | the pdf file name with full path |
desiredPageWidth | Single | The desired page width in inches. |
desiredPageHeight | Single | The desired page height in inches. |
hAlignmentType | PageLayoutAlignmentType | The chart horizontal alignment type in the output page. |
vAlignmentType | PageLayoutAlignmentType | The chart vertical alignment type in the output page. |
Examples
using System;
using Aspose.Cells;
using Aspose.Cells.Charts;
namespace AsposeCellsExamples
{
public class ChartMethodToPdfWithStringSingleSinglePageLayoutAlDemo
{
public static void Run()
{
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Cells["A1"].PutValue("Data");
worksheet.Cells["A2"].PutValue(10);
worksheet.Cells["A3"].PutValue(20);
worksheet.Cells["A4"].PutValue(30);
int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5);
Chart chart = worksheet.Charts[chartIndex];
chart.SetChartDataRange("A1:A4", true);
chart.Title.Text = "Demo Chart";
chart.ToPdf("ChartDemo.pdf", 8.5f, 11f, PageLayoutAlignmentType.Center, PageLayoutAlignmentType.Center);
}
}
}
See Also
- enum PageLayoutAlignmentType
- class Chart
- namespace Aspose.Cells.Charts
- assembly Aspose.Cells
ToPdf(Stream)
Creates the chart pdf and saves it to a stream.
public void ToPdf(Stream stream)
Parameter | Type | Description |
---|---|---|
stream | Stream | The output stream. |
See Also
- class Chart
- namespace Aspose.Cells.Charts
- assembly Aspose.Cells
ToPdf(Stream, float, float, PageLayoutAlignmentType, PageLayoutAlignmentType)
Creates the chart pdf and saves it to a stream.
public void ToPdf(Stream stream, float desiredPageWidth, float desiredPageHeight,
PageLayoutAlignmentType hAlignmentType, PageLayoutAlignmentType vAlignmentType)
Parameter | Type | Description |
---|---|---|
stream | Stream | The output stream. |
desiredPageWidth | Single | The desired page width in inches. |
desiredPageHeight | Single | The desired page height in inches. |
hAlignmentType | PageLayoutAlignmentType | The chart horizontal alignment type in the output page. |
vAlignmentType | PageLayoutAlignmentType | The chart vertical alignment type in the output page. |
See Also
- enum PageLayoutAlignmentType
- class Chart
- namespace Aspose.Cells.Charts
- assembly Aspose.Cells