Last active
March 4, 2021 02:03
-
-
Save aspose-com-gists/a56eda38c01ad33dc653116c7bae4293 to your computer and use it in GitHub Desktop.
Aspose.Slides for .NET
This gist exceeds the recommended number of files (~10).
To access all files, please clone this gist.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Added gist for Aspose.Slides for .NET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_ActiveX(); | |
string dataVideo = RunExamples.GetDataDir_Video(); | |
// Instantiate Presentation class that represents PPTX file | |
Presentation presentation = new Presentation(dataDir + "template.pptx"); | |
// Create empty presentation instance | |
Presentation newPresentation = new Presentation(); | |
// Remove default slide | |
newPresentation.Slides.RemoveAt(0); | |
// Clone slide with Media Player ActiveX Control | |
newPresentation.Slides.InsertClone(0, presentation.Slides[0]); | |
// Access the Media Player ActiveX control and set the video path | |
newPresentation.Slides[0].Controls[0].Properties["URL"] = dataVideo + "Wildlife.mp4"; | |
// Save the Presentation | |
newPresentation.Save(dataDir + "LinkingVideoActiveXControl_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_ActiveX(); | |
// Accessing the presentation with ActiveX controls | |
Presentation presentation = new Presentation(dataDir + "ActiveX.pptm"); | |
// Accessing the first slide in presentation | |
ISlide slide = presentation.Slides[0]; | |
// changing TextBox text | |
IControl control = slide.Controls[0]; | |
if (control.Name == "TextBox1" && control.Properties != null) | |
{ | |
string newText = "Changed text"; | |
control.Properties["Value"] = newText; | |
// changing substitute image. Powerpoint will replace this image during activeX activation, so sometime it's OK to leave image unchanged. | |
Bitmap image = new Bitmap((int)control.Frame.Width, (int)control.Frame.Height); | |
Graphics graphics = Graphics.FromImage(image); | |
Brush brush = new SolidBrush(Color.FromKnownColor(KnownColor.Window)); | |
graphics.FillRectangle(brush, 0, 0, image.Width, image.Height); | |
brush.Dispose(); | |
System.Drawing.Font font = new System.Drawing.Font(control.Properties["FontName"], 14); | |
brush = new SolidBrush(Color.FromKnownColor(KnownColor.WindowText)); | |
graphics.DrawString(newText, font, brush, 10, 4); | |
brush.Dispose(); | |
Pen pen = new Pen(Color.FromKnownColor(KnownColor.ControlDark), 1); | |
graphics.DrawLines( | |
pen, new System.Drawing.Point[] { new System.Drawing.Point(0, image.Height - 1), new System.Drawing.Point(0, 0), new System.Drawing.Point(image.Width - 1, 0) }); | |
pen.Dispose(); | |
pen = new Pen(Color.FromKnownColor(KnownColor.ControlDarkDark), 1); | |
graphics.DrawLines(pen, new System.Drawing.Point[] { new System.Drawing.Point(1, image.Height - 2), new System.Drawing.Point(1, 1), new System.Drawing.Point(image.Width - 2, 1) }); | |
pen.Dispose(); | |
pen = new Pen(Color.FromKnownColor(KnownColor.ControlLight), 1); | |
graphics.DrawLines(pen, new System.Drawing.Point[] | |
{ | |
new System.Drawing.Point(1, image.Height - 1), new System.Drawing.Point(image.Width - 1, image.Height - 1), | |
new System.Drawing.Point(image.Width - 1, 1) | |
}); | |
pen.Dispose(); | |
pen = new Pen(Color.FromKnownColor(KnownColor.ControlLightLight), 1); | |
graphics.DrawLines(pen,new System.Drawing.Point[] { new System.Drawing.Point(0, image.Height), new System.Drawing.Point(image.Width, image.Height), new System.Drawing.Point(image.Width, 0) }); | |
pen.Dispose(); | |
graphics.Dispose(); | |
control.SubstitutePictureFormat.Picture.Image = presentation.Images.AddImage(image); | |
} | |
// changing Button caption | |
control = slide.Controls[1]; | |
if (control.Name == "CommandButton1" && control.Properties != null) | |
{ | |
String newCaption = "MessageBox"; | |
control.Properties["Caption"] = newCaption; | |
// changing substitute | |
Bitmap image = new Bitmap((int)control.Frame.Width, (int)control.Frame.Height); | |
Graphics graphics = Graphics.FromImage(image); | |
Brush brush = new SolidBrush(Color.FromKnownColor(KnownColor.Control)); | |
graphics.FillRectangle(brush, 0, 0, image.Width, image.Height); | |
brush.Dispose(); | |
System.Drawing.Font font = new System.Drawing.Font(control.Properties["FontName"], 14); | |
brush = new SolidBrush(Color.FromKnownColor(KnownColor.WindowText)); | |
SizeF textSize = graphics.MeasureString(newCaption, font, int.MaxValue); | |
graphics.DrawString(newCaption, font, brush, (image.Width - textSize.Width) / 2, (image.Height - textSize.Height) / 2); | |
brush.Dispose(); | |
Pen pen = new Pen(Color.FromKnownColor(KnownColor.ControlLightLight), 1); | |
graphics.DrawLines(pen, new System.Drawing.Point[] { new System.Drawing.Point(0, image.Height - 1), new System.Drawing.Point(0, 0), new System.Drawing.Point(image.Width - 1, 0) }); | |
pen.Dispose(); | |
pen = new Pen(Color.FromKnownColor(KnownColor.ControlLight), 1); | |
graphics.DrawLines(pen, new System.Drawing.Point[] { new System.Drawing.Point(1, image.Height - 2), new System.Drawing.Point(1, 1), new System.Drawing.Point(image.Width - 2, 1) }); | |
pen.Dispose(); | |
pen = new Pen(Color.FromKnownColor(KnownColor.ControlDark), 1); | |
graphics.DrawLines(pen,new System.Drawing.Point[] | |
{ | |
new System.Drawing.Point(1, image.Height - 1), | |
new System.Drawing.Point(image.Width - 1, image.Height - 1), | |
new System.Drawing.Point(image.Width - 1, 1) | |
}); | |
pen.Dispose(); | |
pen = new Pen(Color.FromKnownColor(KnownColor.ControlDarkDark), 1); | |
graphics.DrawLines(pen,new System.Drawing.Point[] { new System.Drawing.Point(0, image.Height), new System.Drawing.Point(image.Width, image.Height), new System.Drawing.Point(image.Width, 0) }); | |
pen.Dispose(); | |
graphics.Dispose(); | |
control.SubstitutePictureFormat.Picture.Image = presentation.Images.AddImage(image); | |
} | |
// Moving ActiveX frames 100 points down | |
foreach (Control ctl in slide.Controls) | |
{ | |
IShapeFrame frame = control.Frame; | |
control.Frame = new ShapeFrame( | |
frame.X, frame.Y + 100, frame.Width, frame.Height, frame.FlipH, frame.FlipV, frame.Rotation); | |
} | |
// Save the presentation with Edited ActiveX Controls | |
presentation.Save(dataDir + "withActiveX-edited_out.pptm", Aspose.Slides.Export.SaveFormat.Pptm); | |
// Now removing controls | |
slide.Controls.Clear(); | |
// Saving the presentation with cleared ActiveX controls | |
presentation.Save(dataDir + "withActiveX.cleared_out.pptm", Aspose.Slides.Export.SaveFormat.Pptm); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create an instance of CAD Metered class | |
Aspose.Slides.Metered metered = new Aspose.Slides.Metered(); | |
// Access the setMeteredKey property and pass public and private keys as parameters | |
metered.SetMeteredKey("*****", "*****"); | |
// Get metered data amount before calling API | |
decimal amountbefore = Aspose.Slides.Metered.GetConsumptionQuantity(); | |
// Display information | |
Console.WriteLine("Amount Consumed Before: " + amountbefore.ToString()); | |
// Get metered data amount After calling API | |
decimal amountafter = Aspose.Slides.Metered.GetConsumptionQuantity(); | |
// Display information | |
Console.WriteLine("Amount Consumed After: " + amountafter.ToString()); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Creating empty presentation | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Creating a bubble chart | |
IChart chart = presentation.Slides[0].Shapes.AddChart(ChartType.Bubble, 50, 50, 400, 300, true); | |
// Adding custom Error bars and setting its format | |
IChartSeries series = chart.ChartData.Series[0]; | |
IErrorBarsFormat errBarX = series.ErrorBarsXFormat; | |
IErrorBarsFormat errBarY = series.ErrorBarsYFormat; | |
errBarX.IsVisible = true; | |
errBarY.IsVisible = true; | |
errBarX.ValueType = ErrorBarValueType.Custom; | |
errBarY.ValueType = ErrorBarValueType.Custom; | |
// Accessing chart series data point and setting error bars values for individual point | |
IChartDataPointCollection points = series.DataPoints; | |
points.DataSourceTypeForErrorBarsCustomValues.DataSourceTypeForXPlusValues = DataSourceType.DoubleLiterals; | |
points.DataSourceTypeForErrorBarsCustomValues.DataSourceTypeForXMinusValues = DataSourceType.DoubleLiterals; | |
points.DataSourceTypeForErrorBarsCustomValues.DataSourceTypeForYPlusValues = DataSourceType.DoubleLiterals; | |
points.DataSourceTypeForErrorBarsCustomValues.DataSourceTypeForYMinusValues = DataSourceType.DoubleLiterals; | |
// Setting error bars for chart series points | |
for (int i = 0; i < points.Count; i++) | |
{ | |
points[i].ErrorBarsCustomValues.XMinus.AsLiteralDouble = i + 1; | |
points[i].ErrorBarsCustomValues.XPlus.AsLiteralDouble = i + 1; | |
points[i].ErrorBarsCustomValues.YMinus.AsLiteralDouble = i + 1; | |
points[i].ErrorBarsCustomValues.YPlus.AsLiteralDouble = i + 1; | |
} | |
// Saving presentation | |
presentation.Save(dataDir + "ErrorBarsCustomValues_out.pptx", SaveFormat.Pptx); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string dataDir = RunExamples.GetDataDir_Charts(); | |
Presentation pres = new Presentation(dataDir+"testc.pptx"); | |
ISlide slide = pres.Slides[0]; | |
IChart chart = slide.Shapes.AddChart(ChartType.Doughnut, 10, 10, 500, 500, false); | |
IChartDataWorkbook workBook = chart.ChartData.ChartDataWorkbook; | |
chart.ChartData.Series.Clear(); | |
chart.ChartData.Categories.Clear(); | |
chart.HasLegend = false; | |
int seriesIndex = 0; | |
while (seriesIndex < 15) | |
{ | |
IChartSeries series = chart.ChartData.Series.Add(workBook.GetCell(0, 0, seriesIndex + 1, "SERIES " + seriesIndex), chart.Type); | |
series.Explosion = 0; | |
series.ParentSeriesGroup.DoughnutHoleSize = (byte)20; | |
series.ParentSeriesGroup.FirstSliceAngle = 351; | |
seriesIndex++; | |
} | |
int categoryIndex = 0; | |
while (categoryIndex < 15) | |
{ | |
chart.ChartData.Categories.Add(workBook.GetCell(0, categoryIndex + 1, 0, "CATEGORY " + categoryIndex)); | |
int i = 0; | |
while (i < chart.ChartData.Series.Count) | |
{ | |
IChartSeries iCS = chart.ChartData.Series[i]; | |
IChartDataPoint dataPoint = iCS.DataPoints.AddDataPointForDoughnutSeries(workBook.GetCell(0, categoryIndex + 1, i + 1, 1)); | |
dataPoint.Format.Fill.FillType = FillType.Solid; | |
dataPoint.Format.Line.FillFormat.FillType = FillType.Solid; | |
dataPoint.Format.Line.FillFormat.SolidFillColor.Color = Color.White; | |
dataPoint.Format.Line.Width = 1; | |
dataPoint.Format.Line.Style = LineStyle.Single; | |
dataPoint.Format.Line.DashStyle = LineDashStyle.Solid; | |
if (i == chart.ChartData.Series.Count - 1) | |
{ | |
IDataLabel lbl = dataPoint.Label; | |
lbl.TextFormat.TextBlockFormat.AutofitType = TextAutofitType.Shape; | |
lbl.DataLabelFormat.TextFormat.PortionFormat.FontBold = NullableBool.True; | |
lbl.DataLabelFormat.TextFormat.PortionFormat.LatinFont = new FontData("DINPro-Bold"); | |
lbl.DataLabelFormat.TextFormat.PortionFormat.FontHeight = 12; | |
lbl.DataLabelFormat.TextFormat.PortionFormat.FillFormat.FillType = FillType.Solid; | |
lbl.DataLabelFormat.TextFormat.PortionFormat.FillFormat.SolidFillColor.Color = Color.LightGray; | |
lbl.DataLabelFormat.Format.Line.FillFormat.SolidFillColor.Color = Color.White; | |
lbl.DataLabelFormat.ShowValue = false; | |
lbl.DataLabelFormat.ShowCategoryName = true; | |
lbl.DataLabelFormat.ShowSeriesName = false; | |
//lbl.DataLabelFormat.ShowLabelAsDataCallout = true; | |
lbl.DataLabelFormat.ShowLeaderLines = true; | |
lbl.DataLabelFormat.ShowLabelAsDataCallout = false; | |
chart.ValidateChartLayout(); | |
lbl.AsILayoutable.X = (float)lbl.AsILayoutable.X + (float)0.5; | |
lbl.AsILayoutable.Y = (float)lbl.AsILayoutable.Y + (float)0.5; | |
} | |
i++; | |
} | |
categoryIndex++; | |
} | |
pres.Save(dataDir+"chart.pptx", Aspose.Slides.Export.SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Creating empty presentation | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Creating a bubble chart | |
IChart chart = presentation.Slides[0].Shapes.AddChart(ChartType.Bubble, 50, 50, 400, 300, true); | |
// Adding Error bars and setting its format | |
IErrorBarsFormat errBarX = chart.ChartData.Series[0].ErrorBarsXFormat; | |
IErrorBarsFormat errBarY = chart.ChartData.Series[0].ErrorBarsYFormat; | |
errBarX.IsVisible = true; | |
errBarY.IsVisible = true; | |
errBarX.ValueType = ErrorBarValueType.Fixed; | |
errBarX.Value = 0.1f; | |
errBarY.ValueType = ErrorBarValueType.Percentage; | |
errBarY.Value = 5; | |
errBarX.Type = ErrorBarType.Plus; | |
errBarY.Format.Line.Width = 2; | |
errBarX.HasEndCap = true; | |
// Saving presentation | |
presentation.Save(dataDir + "ErrorBars_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation()) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 100, 100, 500, 400); | |
IAutoShape shape = chart.UserShapes.Shapes.AddAutoShape(ShapeType.Line, 0, chart.Height / 2, chart.Width, 0); | |
shape.LineFormat.FillFormat.FillType = FillType.Solid; | |
shape.LineFormat.FillFormat.SolidFillColor.Color = Color.Red; | |
pres.Save(dataDir + "AddCustomLines.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation presentation = new Presentation(dataDir + "ExistingChart.pptx")) | |
{ | |
// Get reference of the chart object | |
var slide = presentation.Slides[0] as Slide; | |
var shapes = slide.Shapes as ShapeCollection; | |
var chart = shapes[0] as IChart; | |
// Animate categories' elements | |
slide.Timeline.MainSequence.AddEffect(chart, EffectType.Fade, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInCategory, 0, 0, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInCategory, 0, 1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInCategory, 0, 2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInCategory, 0, 3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInCategory, 1, 0, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInCategory, 1, 1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInCategory, 1, 2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInCategory, 1, 3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInCategory, 2, 0, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInCategory, 2, 1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInCategory, 2, 2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInCategory, 2, 3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
// Write the presentation file to disk | |
presentation.Save(dataDir + "AnimatingCategoriesElements_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Instantiate Presentation class that represents a presentation file | |
using (Presentation presentation = new Presentation(dataDir + "ExistingChart.pptx")) | |
{ | |
// Get reference of the chart object | |
var slide = presentation.Slides[0] as Slide; | |
var shapes = slide.Shapes as ShapeCollection; | |
var chart = shapes[0] as IChart; | |
// Animate the series | |
slide.Timeline.MainSequence.AddEffect(chart, EffectType.Fade, EffectSubtype.None, | |
EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, | |
EffectChartMajorGroupingType.BySeries, 0, | |
EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, | |
EffectChartMajorGroupingType.BySeries, 1, | |
EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, | |
EffectChartMajorGroupingType.BySeries, 2, | |
EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, | |
EffectChartMajorGroupingType.BySeries, 3, | |
EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
// Write the modified presentation to disk | |
presentation.Save(dataDir + "AnimatingSeries_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Load a presentation | |
using (Presentation presentation = new Presentation(dataDir + "ExistingChart.pptx")) | |
{ | |
// Get reference of the chart object | |
var slide = presentation.Slides[0] as Slide; | |
var shapes = slide.Shapes as ShapeCollection; | |
var chart = shapes[0] as IChart; | |
// Animate series elements | |
slide.Timeline.MainSequence.AddEffect(chart, EffectType.Fade, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInSeries, 0, 0, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInSeries, 0, 1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInSeries, 0, 2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInSeries, 0, 3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInSeries, 1, 0, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInSeries, 1, 1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInSeries, 1, 2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInSeries, 1, 3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInSeries, 2, 0, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInSeries, 2, 1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInSeries, 2, 2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
((Sequence)slide.Timeline.MainSequence).AddEffect(chart, EffectChartMinorGroupingType.ByElementInSeries, 2, 3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
// Write the presentation file to disk | |
presentation.Save(dataDir + "AnimatingSeriesElements_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(); | |
// Access first slide | |
ISlide slide = presentation.Slides[0]; | |
// Add chart with default data | |
IChart chart = slide.Shapes.AddChart(ChartType.ClusteredColumn, 0, 0, 500, 500); | |
// Set first series to Show Values | |
chart.ChartData.Series[0].Labels.DefaultDataLabelFormat.ShowValue = true; | |
// Setting the index of chart data sheet | |
int defaultWorksheetIndex = 0; | |
// Getting the chart data worksheet | |
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook; | |
// Delete default generated series and categories | |
chart.ChartData.Series.Clear(); | |
chart.ChartData.Categories.Clear(); | |
int s = chart.ChartData.Series.Count; | |
s = chart.ChartData.Categories.Count; | |
// Adding new series | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 1, "Series 1"), chart.Type); | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 2, "Series 2"), chart.Type); | |
// Adding new categories | |
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 1, 0, "Caetegoty 1")); | |
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 2, 0, "Caetegoty 2")); | |
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 3, 0, "Caetegoty 3")); | |
// Take first chart series | |
IChartSeries series = chart.ChartData.Series[0]; | |
// Now populating series data | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, 20)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 50)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 30)); | |
// Setting automatic fill color for series | |
series.Format.Fill.FillType = FillType.NotDefined; | |
// Take second chart series | |
series = chart.ChartData.Series[1]; | |
// Now populating series data | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 2, 30)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 2, 10)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 2, 60)); | |
// Setting fill color for series | |
series.Format.Fill.FillType = FillType.Solid; | |
series.Format.Fill.SolidFillColor.Color = Color.Gray; | |
// Save presentation with chart | |
presentation.Save(dataDir + "AutomaticColor_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run() | |
{ | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir+"test.pptx")) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.BoxAndWhisker, 50, 50, 500, 400); | |
chart.ChartData.Categories.Clear(); | |
chart.ChartData.Series.Clear(); | |
IChartDataWorkbook wb = chart.ChartData.ChartDataWorkbook; | |
wb.Clear(0); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "A1", "Category 1")); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "A2", "Category 1")); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "A3", "Category 1")); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "A4", "Category 1")); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "A5", "Category 1")); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "A6", "Category 1")); | |
IChartSeries series = chart.ChartData.Series.Add(ChartType.BoxAndWhisker); | |
series.QuartileMethod = QuartileMethodType.Exclusive; | |
series.ShowMeanLine = true; | |
series.ShowMeanMarkers = true; | |
series.ShowInnerPoints = true; | |
series.ShowOutlierPoints = true; | |
series.DataPoints.AddDataPointForBoxAndWhiskerSeries(wb.GetCell(0, "B1", 15)); | |
series.DataPoints.AddDataPointForBoxAndWhiskerSeries(wb.GetCell(0, "B2", 41)); | |
series.DataPoints.AddDataPointForBoxAndWhiskerSeries(wb.GetCell(0, "B3", 16)); | |
series.DataPoints.AddDataPointForBoxAndWhiskerSeries(wb.GetCell(0, "B4", 10)); | |
series.DataPoints.AddDataPointForBoxAndWhiskerSeries(wb.GetCell(0, "B5", 23)); | |
series.DataPoints.AddDataPointForBoxAndWhiskerSeries(wb.GetCell(0, "B6", 16)); | |
pres.Save("BoxAndWhisker.pptx", SaveFormat.Pptx); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation presentation = new Presentation(dataDir + "ExistingChart.pptx")) | |
{ | |
IChart chart = presentation.Slides[0].Shapes[0] as IChart; | |
chart.Axes.HorizontalAxis.CategoryAxisType = CategoryAxisType.Date; | |
chart.Axes.HorizontalAxis.IsAutomaticMajorUnit = false; | |
chart.Axes.HorizontalAxis.MajorUnit = 1; | |
chart.Axes.HorizontalAxis.MajorUnitScale = TimeUnitType.Months; | |
presentation.Save(dataDir + "ChangeChartCategoryAxis_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation()) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 50, 50, 600, 400); | |
IChartDataPoint point = chart.ChartData.Series[0].DataPoints[0]; | |
point.Format.Fill.FillType = FillType.Solid; | |
point.Format.Fill.SolidFillColor.Color = Color.Blue; | |
pres.Save(dataDir + "output.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiating presentation// Instantiating presentation | |
Presentation pres = new Presentation(); | |
// Accessing the first slide | |
ISlide slide = pres.Slides[0]; | |
// Adding the sample chart | |
IChart chart = slide.Shapes.AddChart(ChartType.LineWithMarkers, 50, 50, 500, 400); | |
// Setting Chart Titile | |
chart.HasTitle = true; | |
chart.ChartTitle.AddTextFrameForOverriding(""); | |
IPortion chartTitle = chart.ChartTitle.TextFrameForOverriding.Paragraphs[0].Portions[0]; | |
chartTitle.Text = "Sample Chart"; | |
chartTitle.PortionFormat.FillFormat.FillType = FillType.Solid; | |
chartTitle.PortionFormat.FillFormat.SolidFillColor.Color = Color.Gray; | |
chartTitle.PortionFormat.FontHeight = 20; | |
chartTitle.PortionFormat.FontBold = NullableBool.True; | |
chartTitle.PortionFormat.FontItalic = NullableBool.True; | |
// Setting Major grid lines format for value axis | |
chart.Axes.VerticalAxis.MajorGridLinesFormat.Line.FillFormat.FillType = FillType.Solid; | |
chart.Axes.VerticalAxis.MajorGridLinesFormat.Line.FillFormat.SolidFillColor.Color = Color.Blue; | |
chart.Axes.VerticalAxis.MajorGridLinesFormat.Line.Width = 5; | |
chart.Axes.VerticalAxis.MajorGridLinesFormat.Line.DashStyle = LineDashStyle.DashDot; | |
// Setting Minor grid lines format for value axis | |
chart.Axes.VerticalAxis.MinorGridLinesFormat.Line.FillFormat.FillType = FillType.Solid; | |
chart.Axes.VerticalAxis.MinorGridLinesFormat.Line.FillFormat.SolidFillColor.Color = Color.Red; | |
chart.Axes.VerticalAxis.MinorGridLinesFormat.Line.Width = 3; | |
// Setting value axis number format | |
chart.Axes.VerticalAxis.IsNumberFormatLinkedToSource = false; | |
chart.Axes.VerticalAxis.DisplayUnit = DisplayUnitType.Thousands; | |
chart.Axes.VerticalAxis.NumberFormat = "0.0%"; | |
// Setting chart maximum, minimum values | |
chart.Axes.VerticalAxis.IsAutomaticMajorUnit = false; | |
chart.Axes.VerticalAxis.IsAutomaticMaxValue = false; | |
chart.Axes.VerticalAxis.IsAutomaticMinorUnit = false; | |
chart.Axes.VerticalAxis.IsAutomaticMinValue = false; | |
chart.Axes.VerticalAxis.MaxValue = 15f; | |
chart.Axes.VerticalAxis.MinValue = -2f; | |
chart.Axes.VerticalAxis.MinorUnit = 0.5f; | |
chart.Axes.VerticalAxis.MajorUnit = 2.0f; | |
// Setting Value Axis Text Properties | |
IChartPortionFormat txtVal = chart.Axes.VerticalAxis.TextFormat.PortionFormat; | |
txtVal.FontBold = NullableBool.True; | |
txtVal.FontHeight = 16; | |
txtVal.FontItalic = NullableBool.True; | |
txtVal.FillFormat.FillType = FillType.Solid; ; | |
txtVal.FillFormat.SolidFillColor.Color = Color.DarkGreen; | |
txtVal.LatinFont = new FontData("Times New Roman"); | |
// Setting value axis title | |
chart.Axes.VerticalAxis.HasTitle = true; | |
chart.Axes.VerticalAxis.Title.AddTextFrameForOverriding(""); | |
IPortion valtitle = chart.Axes.VerticalAxis.Title.TextFrameForOverriding.Paragraphs[0].Portions[0]; | |
valtitle.Text = "Primary Axis"; | |
valtitle.PortionFormat.FillFormat.FillType = FillType.Solid; | |
valtitle.PortionFormat.FillFormat.SolidFillColor.Color = Color.Gray; | |
valtitle.PortionFormat.FontHeight = 20; | |
valtitle.PortionFormat.FontBold = NullableBool.True; | |
valtitle.PortionFormat.FontItalic = NullableBool.True; | |
// Setting value axis line format : Now Obselete | |
// chart.Axes.VerticalAxis.aVerticalAxis.l.AxisLine.Width = 10; | |
// chart.Axes.VerticalAxis.AxisLine.FillFormat.FillType = FillType.Solid; | |
// Chart.Axes.VerticalAxis.AxisLine.FillFormat.SolidFillColor.Color = Color.Red; | |
// Setting Major grid lines format for Category axis | |
chart.Axes.HorizontalAxis.MajorGridLinesFormat.Line.FillFormat.FillType = FillType.Solid; | |
chart.Axes.HorizontalAxis.MajorGridLinesFormat.Line.FillFormat.SolidFillColor.Color = Color.Green; | |
chart.Axes.HorizontalAxis.MajorGridLinesFormat.Line.Width = 5; | |
// Setting Minor grid lines format for Category axis | |
chart.Axes.HorizontalAxis.MinorGridLinesFormat.Line.FillFormat.FillType = FillType.Solid; | |
chart.Axes.HorizontalAxis.MinorGridLinesFormat.Line.FillFormat.SolidFillColor.Color = Color.Yellow; | |
chart.Axes.HorizontalAxis.MinorGridLinesFormat.Line.Width = 3; | |
// Setting Category Axis Text Properties | |
IChartPortionFormat txtCat = chart.Axes.HorizontalAxis.TextFormat.PortionFormat; | |
txtCat.FontBold = NullableBool.True; | |
txtCat.FontHeight = 16; | |
txtCat.FontItalic = NullableBool.True; | |
txtCat.FillFormat.FillType = FillType.Solid; ; | |
txtCat.FillFormat.SolidFillColor.Color = Color.Blue; | |
txtCat.LatinFont = new FontData("Arial"); | |
// Setting Category Titile | |
chart.Axes.HorizontalAxis.HasTitle = true; | |
chart.Axes.HorizontalAxis.Title.AddTextFrameForOverriding(""); | |
IPortion catTitle = chart.Axes.HorizontalAxis.Title.TextFrameForOverriding.Paragraphs[0].Portions[0]; | |
catTitle.Text = "Sample Category"; | |
catTitle.PortionFormat.FillFormat.FillType = FillType.Solid; | |
catTitle.PortionFormat.FillFormat.SolidFillColor.Color = Color.Gray; | |
catTitle.PortionFormat.FontHeight = 20; | |
catTitle.PortionFormat.FontBold = NullableBool.True; | |
catTitle.PortionFormat.FontItalic = NullableBool.True; | |
// Setting category axis lable position | |
chart.Axes.HorizontalAxis.TickLabelPosition = TickLabelPositionType.Low; | |
// Setting category axis lable rotation angle | |
chart.Axes.HorizontalAxis.TickLabelRotationAngle = 45; | |
// Setting Legends Text Properties | |
IChartPortionFormat txtleg = chart.Legend.TextFormat.PortionFormat; | |
txtleg.FontBold = NullableBool.True; | |
txtleg.FontHeight = 16; | |
txtleg.FontItalic = NullableBool.True; | |
txtleg.FillFormat.FillType = FillType.Solid; ; | |
txtleg.FillFormat.SolidFillColor.Color = Color.DarkRed; | |
// Set show chart legends without overlapping chart | |
chart.Legend.Overlay = true; | |
// Ploting first series on secondary value axis | |
// Chart.ChartData.Series[0].PlotOnSecondAxis = true; | |
// Setting chart back wall color | |
chart.BackWall.Thickness = 1; | |
chart.BackWall.Format.Fill.FillType = FillType.Solid; | |
chart.BackWall.Format.Fill.SolidFillColor.Color = Color.Orange; | |
chart.Floor.Format.Fill.FillType = FillType.Solid; | |
chart.Floor.Format.Fill.SolidFillColor.Color = Color.Red; | |
// Setting Plot area color | |
chart.PlotArea.Format.Fill.FillType = FillType.Solid; | |
chart.PlotArea.Format.Fill.SolidFillColor.Color = Color.LightCyan; | |
// Save Presentation | |
pres.Save(dataDir + "FormattedChart_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string dataDir = RunExamples.GetDataDir_Charts(); | |
Presentation pres = new Presentation(dataDir+"Test.pptx"); | |
ISlide slide = pres.Slides[0]; | |
//Creating the default chart | |
IChart chart = slide.Shapes.AddChart(ChartType.LineWithMarkers, 0, 0, 400, 400); | |
//Getting the default chart data worksheet index | |
int defaultWorksheetIndex = 0; | |
//Getting the chart data worksheet | |
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook; | |
//Delete demo series | |
chart.ChartData.Series.Clear(); | |
//Add new series | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 1, 1, "Series 1"), chart.Type); | |
//Set the picture | |
System.Drawing.Image img = (System.Drawing.Image)new Bitmap(dataDir + "aspose-logo.jpg"); | |
IPPImage imgx1 = pres.Images.AddImage(img); | |
//Set the picture | |
System.Drawing.Image img2 = (System.Drawing.Image)new Bitmap(dataDir + "Tulips.jpg"); | |
IPPImage imgx2 = pres.Images.AddImage(img2); | |
//Take first chart series | |
IChartSeries series = chart.ChartData.Series[0]; | |
//Add new point (1:3) there. | |
IChartDataPoint point = series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, (double)4.5)); | |
point.Marker.Format.Fill.FillType = FillType.Picture; | |
point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx1; | |
point = series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, (double)2.5)); | |
point.Marker.Format.Fill.FillType = FillType.Picture; | |
point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx2; | |
point = series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, (double)3.5)); | |
point.Marker.Format.Fill.FillType = FillType.Picture; | |
point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx1; | |
point = series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 4, 1, (double)4.5)); | |
point.Marker.Format.Fill.FillType = FillType.Picture; | |
point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx2; | |
//Changing the chart series marker | |
series.Marker.Size = 15; | |
pres.Save(dataDir+"AsposeScatterChart.pptx", SaveFormat.Pptx); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Creating empty presentation | |
Presentation pres = new Presentation(); | |
// Creating a clustered column chart | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 20, 20, 500, 400); | |
// Adding ponential trend line for chart series 1 | |
ITrendline tredLinep = chart.ChartData.Series[0].TrendLines.Add(TrendlineType.Exponential); | |
tredLinep.DisplayEquation = false; | |
tredLinep.DisplayRSquaredValue = false; | |
// Adding Linear trend line for chart series 1 | |
ITrendline tredLineLin = chart.ChartData.Series[0].TrendLines.Add(TrendlineType.Linear); | |
tredLineLin.TrendlineType = TrendlineType.Linear; | |
tredLineLin.Format.Line.FillFormat.FillType = FillType.Solid; | |
tredLineLin.Format.Line.FillFormat.SolidFillColor.Color = Color.Red; | |
// Adding Logarithmic trend line for chart series 2 | |
ITrendline tredLineLog = chart.ChartData.Series[1].TrendLines.Add(TrendlineType.Logarithmic); | |
tredLineLog.TrendlineType = TrendlineType.Logarithmic; | |
tredLineLog.AddTextFrameForOverriding("New log trend line"); | |
// Adding MovingAverage trend line for chart series 2 | |
ITrendline tredLineMovAvg = chart.ChartData.Series[1].TrendLines.Add(TrendlineType.MovingAverage); | |
tredLineMovAvg.TrendlineType = TrendlineType.MovingAverage; | |
tredLineMovAvg.Period = 3; | |
tredLineMovAvg.TrendlineName = "New TrendLine Name"; | |
// Adding Polynomial trend line for chart series 3 | |
ITrendline tredLinePol = chart.ChartData.Series[2].TrendLines.Add(TrendlineType.Polynomial); | |
tredLinePol.TrendlineType = TrendlineType.Polynomial; | |
tredLinePol.Forward = 1; | |
tredLinePol.Order = 3; | |
// Adding Power trend line for chart series 3 | |
ITrendline tredLinePower = chart.ChartData.Series[1].TrendLines.Add(TrendlineType.Power); | |
tredLinePower.TrendlineType = TrendlineType.Power; | |
tredLinePower.Backward = 1; | |
// Saving presentation | |
pres.Save(dataDir + "ChartTrendLines_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir + "TestChart.pptx")) | |
{ | |
ISlide sl = pres.Slides[0]; | |
IChart chart = (IChart)sl.Shapes[0]; | |
foreach (IChartDataPoint dataPoint in chart.ChartData.Series[0].DataPoints) | |
{ | |
dataPoint.XValue.AsCell.Value = null; | |
dataPoint.YValue.AsCell.Value = null; | |
} | |
chart.ChartData.Series[0].DataPoints.Clear(); | |
pres.Save(dataDir + "ClearSpecificChartSeriesDataPointsData.pptx", SaveFormat.Pptx); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Instantiate Presentation class that represents PPTX file//Instantiate Presentation class that represents PPTX file | |
Presentation pres = new Presentation(); | |
//Access first slide | |
ISlide sld = pres.Slides[0]; | |
// Add chart with default data | |
IChart chart = sld.Shapes.AddChart(ChartType.ClusteredColumn, 0, 0, 500, 500); | |
//Setting chart Title | |
//chart.ChartTitle.TextFrameForOverriding.Text = "Sample Title"; | |
chart.ChartTitle.AddTextFrameForOverriding("Sample Title"); | |
chart.ChartTitle.TextFrameForOverriding.TextFrameFormat.CenterText = NullableBool.True; | |
chart.ChartTitle.Height = 20; | |
chart.HasTitle = true; | |
//Set first series to Show Values | |
chart.ChartData.Series[0].Labels.DefaultDataLabelFormat.ShowValue = true; | |
//Setting the index of chart data sheet | |
int defaultWorksheetIndex = 0; | |
//Getting the chart data worksheet | |
IChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory; | |
//Delete default generated series and categories | |
chart.ChartData.Series.Clear(); | |
chart.ChartData.Categories.Clear(); | |
int s = chart.ChartData.Series.Count; | |
s = chart.ChartData.Categories.Count; | |
//Adding new series | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 1, "Series 1"), chart.Type); | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 2, "Series 2"), chart.Type); | |
//Adding new categories | |
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 1, 0, "Caetegoty 1")); | |
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 2, 0, "Caetegoty 2")); | |
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 3, 0, "Caetegoty 3")); | |
//Take first chart series | |
IChartSeries series = chart.ChartData.Series[0]; | |
//Now populating series data | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, 20)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 50)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 30)); | |
//Setting fill color for series | |
series.Format.Fill.FillType = FillType.Solid; | |
series.Format.Fill.SolidFillColor.Color = Color.Red; | |
//Take second chart series | |
series = chart.ChartData.Series[1]; | |
//Now populating series data | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 2, 30)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 2, 10)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 2, 60)); | |
//Setting fill color for series | |
series.Format.Fill.FillType = FillType.Solid; | |
series.Format.Fill.SolidFillColor.Color = Color.Green; | |
//create custom labels for each of categories for new series | |
//first label will be show Category name | |
IDataLabel lbl = series.DataPoints[0].Label; | |
lbl.DataLabelFormat.ShowCategoryName = true; | |
lbl = series.DataPoints[1].Label; | |
lbl.DataLabelFormat.ShowSeriesName = true; | |
//Show value for third label | |
lbl = series.DataPoints[2].Label; | |
lbl.DataLabelFormat.ShowValue = true; | |
lbl.DataLabelFormat.ShowSeriesName = true; | |
lbl.DataLabelFormat.Separator = "/"; | |
//Save presentation with chart | |
pres.Save("AsposeChart.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Create empty presentation | |
using (Presentation pres = new Presentation()) | |
{ | |
//Accessing first slide | |
ISlide slide = pres.Slides[0]; | |
//Addding default chart | |
IChart ppChart = slide.Shapes.AddChart(ChartType.ClusteredColumn3D, 20F, 30F, 400F, 300F); | |
//Getting Chart data | |
IChartData chartData = ppChart.ChartData; | |
//Removing Extra default series | |
chartData.Series.RemoveAt(1); | |
chartData.Series.RemoveAt(1); | |
//Modifying chart categories names | |
chartData.Categories[0].AsCell.Value = "Bikes"; | |
chartData.Categories[1].AsCell.Value = "Accessories"; | |
chartData.Categories[2].AsCell.Value = "Repairs"; | |
chartData.Categories[3].AsCell.Value = "Clothing"; | |
//Setting the index of chart data sheet | |
int defaultWorksheetIndex = 0; | |
//Getting the chart data worksheet | |
IChartDataCellFactory fact = ppChart.ChartData.ChartDataCellFactory; | |
//Modifying chart series values for first category | |
chartData.Series[0].DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, 1000)); | |
chartData.Series[0].DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 2500)); | |
chartData.Series[0].DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 4000)); | |
chartData.Series[0].DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 4, 1, 3000)); | |
//Setting Chart title | |
ppChart.HasTitle = true; | |
ppChart.ChartTitle.AddTextFrameForOverriding("2007 Sales"); | |
IPortionFormat format = ppChart.ChartTitle.TextFrameForOverriding.Paragraphs[0].Portions[0].PortionFormat; | |
format.FontItalic = NullableBool.True; | |
format.FontHeight = 18; | |
format.FillFormat.FillType = FillType.Solid; | |
format.FillFormat.SolidFillColor.Color = Color.Black; | |
////Setting Axis values | |
ppChart.Axes.VerticalAxis.IsAutomaticMaxValue = false; | |
ppChart.Axes.VerticalAxis.IsAutomaticMinValue = false; | |
ppChart.Axes.VerticalAxis.IsAutomaticMajorUnit = false; | |
ppChart.Axes.VerticalAxis.IsAutomaticMinorUnit = false; | |
ppChart.Axes.VerticalAxis.MaxValue = 4000.0F; | |
ppChart.Axes.VerticalAxis.MinValue = 0.0F; | |
ppChart.Axes.VerticalAxis.MajorUnit = 2000.0F; | |
ppChart.Axes.VerticalAxis.MinorUnit = 1000.0F; | |
ppChart.Axes.VerticalAxis.TickLabelPosition = TickLabelPositionType.NextTo; | |
//Setting Chart rotation | |
ppChart.Rotation3D.RotationX = 15; | |
ppChart.Rotation3D.RotationY = 20; | |
//Saving Presentation | |
pres.Save("c:\\data\\AsposeSampleChart.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Instantiate PresentationEx class that represents PPTX file | |
using (PresentationEx pres = new PresentationEx()) | |
{ | |
//Access first slide | |
SlideEx sld = pres.Slides[0]; | |
// Add chart with default data | |
ChartEx chart = sld.Shapes.AddChart(ChartTypeEx.ClusteredColumn, 0, 0, 500, 500); | |
//Setting chart Title | |
chart.ChartTitle.Text.Text = "Sample Title"; | |
chart.ChartTitle.Text.CenterText = true; | |
chart.ChartTitle.Height = 20; | |
chart.HasTitle = true; | |
//Set first series to Show Values | |
chart.ChartData.Series[0].Labels.ShowValue = true; | |
//Setting the index of chart data sheet | |
int defaultWorksheetIndex = 0; | |
//Getting the chart data worksheet | |
ChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory; | |
//Delete default generated series and categories | |
chart.ChartData.Series.Clear(); | |
chart.ChartData.Categories.Clear(); | |
int s = chart.ChartData.Series.Count; | |
s = chart.ChartData.Categories.Count; | |
//Adding new series | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 1, "Series 1"), chart.Type); | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 2, "Series 2"), chart.Type); | |
//Adding new categories | |
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 1, 0, "Caetegoty 1")); | |
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 2, 0, "Caetegoty 2")); | |
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 3, 0, "Caetegoty 3")); | |
//Take first chart series | |
ChartSeriesEx series = chart.ChartData.Series[0]; | |
//Now populating series data | |
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 1, 1, 20)); | |
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 2, 1, 50)); | |
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 3, 1, 30)); | |
//Setting fill color for series | |
series.Format.Fill.FillType = FillTypeEx.Solid; | |
series.Format.Fill.SolidFillColor.Color = Color.Red; | |
//Take second chart series | |
series = chart.ChartData.Series[1]; | |
//Now populating series data | |
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 1, 2, 30)); | |
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 2, 2, 10)); | |
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 3, 2, 60)); | |
//Setting fill color for series | |
series.Format.Fill.FillType = FillTypeEx.Solid; | |
series.Format.Fill.SolidFillColor.Color = Color.Green; | |
//create custom labels for each of categories for new series | |
//first label will be show Category name | |
DataLabelEx lbl = new DataLabelEx(series); | |
lbl.ShowCategoryName = true; | |
lbl.Id = 0; | |
series.Labels.Add(lbl); | |
//Show series name for second label | |
lbl = new DataLabelEx(series); | |
lbl.ShowSeriesName = true; | |
lbl.Id = 1; | |
series.Labels.Add(lbl); | |
//Show value for third label | |
lbl = new DataLabelEx(series); | |
lbl.ShowValue = true; | |
lbl.ShowSeriesName = true; | |
lbl.Separator = "/"; | |
lbl.Id = 2; | |
series.Labels.Add(lbl); | |
//Show value and custom text | |
lbl = new DataLabelEx(series); | |
lbl.TextFrame.Text = "My text"; | |
lbl.Id = 3; | |
series.Labels.Add(lbl); | |
//Save presentation with chart | |
pres.Write(@"D:\AsposeChart.pptx"); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir + "presentation.pptx")) | |
{ | |
string externalWbPath = dataDir + "externalWorkbook1.xlsx"; | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Pie, 50, 50, 400, 600); | |
if (File.Exists(externalWbPath)) | |
File.Delete(externalWbPath); | |
using (FileStream fileStream = new FileStream(externalWbPath, FileMode.CreateNew)) | |
{ | |
byte[] worbookData = chart.ChartData.ReadWorkbookStream().ToArray(); | |
fileStream.Write(worbookData, 0, worbookData.Length); | |
} | |
chart.ChartData.SetExternalWorkbook(externalWbPath); | |
pres.Save(dataDir + "Presentation_with_externalWbPath.pptx", SaveFormat.Pptx); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Presentation pres = new Presentation(); | |
ISlide slide = pres.Slides[0]; | |
//Creating the default chart | |
IChart chart = slide.Shapes.AddChart(ChartType.ScatterWithSmoothLines, 0, 0, 400, 400); | |
//Getting the default chart data worksheet index | |
int defaultWorksheetIndex = 0; | |
//Accessing the chart data worksheet | |
IChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory; | |
//Delete demo series | |
chart.ChartData.Series.Clear(); | |
//Add new series | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 1, 1, "Series 1"), chart.Type); | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 1, 3, "Series 2"), chart.Type); | |
//Take first chart series | |
IChartSeries series = chart.ChartData.Series[0]; | |
//Add new point (1:3) there. | |
series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 1), fact.GetCell(defaultWorksheetIndex, 2, 2, 3)); | |
//Add new point (2:10) | |
series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 2), fact.GetCell(defaultWorksheetIndex, 3, 2, 10)); | |
//Edit the type of series | |
series.Type = ChartType.ScatterWithStraightLinesAndMarkers; | |
//Changing the chart series marker | |
series.Marker.Size = 10; | |
series.Marker.Symbol = MarkerStyleType.Star; | |
//Take second chart series | |
series = chart.ChartData.Series[1]; | |
//Add new point (5:2) there. | |
series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 2, 3, 5), fact.GetCell(defaultWorksheetIndex, 2, 4, 2)); | |
//Add new point (3:1) | |
series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 3, 3, 3), fact.GetCell(defaultWorksheetIndex, 3, 4, 1)); | |
//Add new point (2:2) | |
series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 4, 3, 2), fact.GetCell(defaultWorksheetIndex, 4, 4, 2)); | |
//Add new point (5:1) | |
series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 5, 3, 5), fact.GetCell(defaultWorksheetIndex, 5, 4, 1)); | |
//Changing the chart series marker | |
series.Marker.Size = 10; | |
series.Marker.Symbol = MarkerStyleType.Circle; | |
pres.Save("AsposeScatterChart.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (PresentationEx pres = new PresentationEx()) | |
{ | |
SlideEx slide = pres.Slides[0]; | |
//Creating the default chart | |
ChartEx chart = slide.Shapes.AddChart(ChartTypeEx.ScatterWithSmoothLines, 0, 0, 400, 400); | |
//Getting the default chart data worksheet index | |
int defaultWorksheetIndex = 0; | |
//Accessing the chart data worksheet | |
ChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory; | |
//Delete demo series | |
chart.ChartData.Series.Clear(); | |
//Add new series | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 1, 1, "Series 1"), chart.Type); | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 1, 3, "Series 2"), chart.Type); | |
//Take first chart series | |
ChartSeriesEx series = chart.ChartData.Series[0]; | |
//Add new point (1:3) there. | |
series.XValues.Add(fact.GetCell(defaultWorksheetIndex, 2, 1, 1)); | |
series.YValues.Add(fact.GetCell(defaultWorksheetIndex, 2, 2, 3)); | |
//Add new point (2:10) | |
series.XValues.Add(fact.GetCell(defaultWorksheetIndex, 3, 1, 2)); | |
series.YValues.Add(fact.GetCell(defaultWorksheetIndex, 3, 2, 10)); | |
//Edit the type of series | |
series.Type = ChartTypeEx.ScatterWithStraightLinesAndMarkers; | |
//Changing the chart series marker | |
series.MarkerSize = 10; | |
series.MarkerSymbol = MarkerStyleTypeEx.Star; | |
//Take second chart series | |
series = chart.ChartData.Series[1]; | |
//Add new point (5:2) there. | |
series.XValues.Add(fact.GetCell(defaultWorksheetIndex, 2, 3, 5)); | |
series.YValues.Add(fact.GetCell(defaultWorksheetIndex, 2, 4, 2)); | |
//Add new point (3:1) | |
series.XValues.Add(fact.GetCell(defaultWorksheetIndex, 3, 3, 3)); | |
series.YValues.Add(fact.GetCell(defaultWorksheetIndex, 3, 4, 1)); | |
//Add new point (2:2) | |
series.XValues.Add(fact.GetCell(defaultWorksheetIndex, 4, 3, 2)); | |
series.YValues.Add(fact.GetCell(defaultWorksheetIndex, 4, 4, 2)); | |
//Add new point (5:1) | |
series.XValues.Add(fact.GetCell(defaultWorksheetIndex, 5, 3, 5)); | |
series.YValues.Add(fact.GetCell(defaultWorksheetIndex, 5, 4, 1)); | |
//Changing the chart series marker | |
series.MarkerSize = 10; | |
series.MarkerSymbol = MarkerStyleTypeEx.Circle; | |
pres.Write("D:\\AsposeSeriesChart.pptx"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir + "pres.pptx")) | |
{ | |
ISlide slide = pres.Slides[1]; | |
IChart chart = (IChart)slide.Shapes[0]; | |
ChartDataSourceType sourceType = chart.ChartData.DataSourceType; | |
if (sourceType == ChartDataSourceType.ExternalWorkbook) | |
{ | |
string path = chart.ChartData.ExternalWorkbookPath; | |
} | |
// Saving presentation | |
pres.Save(dataDir + "Result.pptx", SaveFormat.Pptx); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation()) | |
{ | |
ISlide slide = pres.Slides[0]; | |
IChart chart = slide.Shapes.AddChart(ChartType.LineWithMarkers, 10, 10, 400, 400); | |
chart.ChartData.Series.Clear(); | |
chart.ChartData.Categories.Clear(); | |
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook; | |
chart.ChartData.Series.Add(fact.GetCell(0, 0, 1, "Series 1"), chart.Type); | |
IChartSeries series = chart.ChartData.Series[0]; | |
chart.ChartData.Categories.Add(fact.GetCell(0, 1, 0, "C1")); | |
series.DataPoints.AddDataPointForLineSeries(fact.GetCell(0, 1, 1, 24)); | |
chart.ChartData.Categories.Add(fact.GetCell(0, 2, 0, "C2")); | |
series.DataPoints.AddDataPointForLineSeries(fact.GetCell(0, 2, 1, 23)); | |
chart.ChartData.Categories.Add(fact.GetCell(0, 3, 0, "C3")); | |
series.DataPoints.AddDataPointForLineSeries(fact.GetCell(0, 3, 1, -10)); | |
chart.ChartData.Categories.Add(fact.GetCell(0, 4, 0, "C4")); | |
series.DataPoints.AddDataPointForLineSeries(fact.GetCell(0, 4, 1, null)); | |
chart.ChartData.Series.Add(fact.GetCell(0, 0, 2, "Series 2"), chart.Type); | |
//Take second chart series | |
IChartSeries series2 = chart.ChartData.Series[1]; | |
//Now populating series data | |
series2.DataPoints.AddDataPointForLineSeries(fact.GetCell(0, 1, 2, 30)); | |
series2.DataPoints.AddDataPointForLineSeries(fact.GetCell(0, 2, 2, 10)); | |
series2.DataPoints.AddDataPointForLineSeries(fact.GetCell(0, 3, 2, 60)); | |
series2.DataPoints.AddDataPointForLineSeries(fact.GetCell(0, 4, 2, 40)); | |
chart.HasLegend = true; | |
chart.Legend.Overlay = false; | |
pres.Save(dataDir + "DefaultMarkersInChart.pptx", SaveFormat.Pptx); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation presentation = new Presentation()) | |
{ | |
IChart chart = presentation.Slides[0].Shapes.AddChart(ChartType.Pie, 50, 50, 500, 400); | |
chart.ChartData.Series[0].Labels.DefaultDataLabelFormat.ShowValue = true; | |
chart.ChartData.Series[0].Labels.DefaultDataLabelFormat.ShowLabelAsDataCallout = true; | |
chart.ChartData.Series[0].Labels[2].DataLabelFormat.ShowLabelAsDataCallout = false; | |
presentation.Save(dataDir + "DisplayChartLabels_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(); | |
ISlide slide = presentation.Slides[0]; | |
IChart chart = slide.Shapes.AddChart(ChartType.StackedColumn, 20, 20, 400, 400); | |
IChartSeries series = chart.ChartData.Series[0]; | |
IChartCategory cat; | |
double[] total_for_Cat = new double[chart.ChartData.Categories.Count]; | |
for (int k = 0; k < chart.ChartData.Categories.Count; k++) | |
{ | |
cat = chart.ChartData.Categories[k]; | |
for (int i = 0; i < chart.ChartData.Series.Count; i++) | |
{ | |
total_for_Cat[k] = total_for_Cat[k] + Convert.ToDouble(chart.ChartData.Series[i].DataPoints[k].Value.Data); | |
} | |
} | |
double dataPontPercent = 0f; | |
for (int x = 0; x < chart.ChartData.Series.Count; x++) | |
{ | |
series = chart.ChartData.Series[x]; | |
series.Labels.DefaultDataLabelFormat.ShowLegendKey = false; | |
for (int j = 0; j < series.DataPoints.Count; j++) | |
{ | |
IDataLabel lbl = series.DataPoints[j].Label; | |
dataPontPercent = (Convert.ToDouble(series.DataPoints[j].Value.Data) / total_for_Cat[j]) * 100; | |
IPortion port = new Portion(); | |
port.Text = String.Format("{0:F2} %", dataPontPercent); | |
port.PortionFormat.FontHeight = 8f; | |
lbl.TextFrameForOverriding.Text = ""; | |
IParagraph para = lbl.TextFrameForOverriding.Paragraphs[0]; | |
para.Portions.Add(port); | |
lbl.DataLabelFormat.ShowSeriesName = false; | |
lbl.DataLabelFormat.ShowPercentage = false; | |
lbl.DataLabelFormat.ShowLegendKey = false; | |
lbl.DataLabelFormat.ShowCategoryName = false; | |
lbl.DataLabelFormat.ShowBubbleSize = false; | |
} | |
} | |
// Save presentation with chart | |
presentation.Save(dataDir + "DisplayPercentageAsLabels_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(); | |
IChart chart = presentation.Slides[0].Shapes.AddChart(ChartType.Doughnut, 50, 50, 400, 400); | |
chart.ChartData.SeriesGroups[0].DoughnutHoleSize = 90; | |
// Write presentation to disk | |
presentation.Save(dataDir + "DoughnutHoleSize_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir + "presentation.pptx")) | |
{ | |
IChart chart = pres.Slides[0].Shapes[0] as IChart; | |
ChartData chartData = (ChartData)chart.ChartData; | |
chartData.Series[0].DataPoints[0].Value.AsCell.Value = 100; | |
pres.Save(dataDir + "presentation_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void AddExcelChartInPresentation(Presentation pres, ISlide sld, Stream wbStream, Bitmap imgChart) | |
{ | |
float oleWidth = pres.SlideSize.Size.Width; | |
float oleHeight = pres.SlideSize.Size.Height; | |
int x = 0; | |
byte[] chartOleData = new byte[wbStream.Length]; | |
wbStream.Position = 0; | |
wbStream.Read(chartOleData, 0, chartOleData.Length); | |
IOleObjectFrame oof = null; | |
oof = sld.Shapes.AddOleObjectFrame(x, 0, oleWidth, oleHeight, "Excel.Sheet.8", chartOleData); | |
oof.SubstitutePictureFormat.Picture.Image = pres.Images.AddImage((System.Drawing.Image)imgChart); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int AddExcelChartInWorkbook(Aspose.Cells.Workbook wb, int chartRows, int chartCols) | |
{ | |
//Array of cell names | |
string[] cellsName = new string[] | |
{ | |
"A1", "A2", "A3", "A4", | |
"B1", "B2", "B3", "B4", | |
"C1", "C2", "C3", "C4", | |
"D1", "D2", "D3", "D4", | |
"E1", "E2", "E3", "E4" | |
}; | |
//Array of cell data | |
int[] cellsValue = new int[] | |
{ | |
67,86,68,91, | |
44,64,89,48, | |
46,97,78,60, | |
43,29,69,26, | |
24,40,38,25 | |
}; | |
//Add a new worksheet to populate cells with data | |
int dataSheetIdx = wb.Worksheets.Add(); | |
Aspose.Cells.Worksheet dataSheet = wb.Worksheets[dataSheetIdx]; | |
string sheetName = "DataSheet"; | |
dataSheet.Name = sheetName; | |
//Populate DataSheet with data | |
for (int i = 0; i < cellsName.Length; i++) | |
{ | |
string cellName = cellsName[i]; | |
int cellValue = cellsValue[i]; | |
dataSheet.Cells[cellName].PutValue(cellValue); | |
} | |
//Add a chart sheet | |
int chartSheetIdx = wb.Worksheets.Add(Aspose.Cells.SheetType.Chart); | |
Aspose.Cells.Worksheet chartSheet = wb.Worksheets[chartSheetIdx]; | |
chartSheet.Name = "ChartSheet"; | |
//Add a chart in ChartSheet with data series from DataSheet | |
int chartIdx = chartSheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 0, chartRows, 0, chartCols); | |
Aspose.Cells.Charts.Chart chart = chartSheet.Charts[chartIdx]; | |
chart.NSeries.Add(sheetName + "!A1:E1", false); | |
chart.NSeries.Add(sheetName + "!A2:E2", false); | |
chart.NSeries.Add(sheetName + "!A3:E3", false); | |
chart.NSeries.Add(sheetName + "!A4:E4", false); | |
//Set ChartSheet an active sheet | |
wb.Worksheets.ActiveSheetIndex = chartSheetIdx; | |
return chartSheetIdx; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Step - 1: Create an excel chart using Aspose.Cells | |
//-------------------------------------------------- | |
//Create a workbook | |
Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(); | |
//Add an excel chart | |
int chartRows = 55; | |
int chartCols = 25; | |
int chartSheetIndex = AddExcelChartInWorkbook(wb, chartRows, chartCols); | |
//Step - 2: Set the OLE size of the chart. using Aspose.Cells | |
//----------------------------------------------------------- | |
wb.Worksheets.SetOleSize(0, chartRows, 0, chartCols); | |
//Step - 3: Get the image of the chart with Aspose.Cells | |
//----------------------------------------------------------- | |
Bitmap imgChart = wb.Worksheets[chartSheetIndex].Charts[0].ToImage(); | |
//Save the workbook to stream | |
MemoryStream wbStream = wb.SaveToStream(); | |
//Step - 4 AND 5 | |
//----------------------------------------------------------- | |
//Step - 4: Embed the chart as an OLE object inside .ppt presentation using Aspose.Slides | |
//----------------------------------------------------------- | |
//Step - 5: Replace the object changed image with the image obtained in step 3 to cater Object Changed Issue | |
//----------------------------------------------------------- | |
//Create a presentation | |
Presentation pres = new Presentation(); | |
ISlide sld = pres.Slides[0]; | |
//Add the workbook on slide | |
AddExcelChartInPresentation(pres, sld, wbStream, imgChart); | |
//Step - 6: Write the output presentation on disk | |
//----------------------------------------------------------- | |
pres.Save("OutputChart.pptx", Aspose.Slides.Export.SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Instantiate Presentation class that represents PPTX file// Instantiate Presentation class that represents PPTX file | |
Presentation pres = new Presentation(dataDir + "ExistingChart.pptx"); | |
// Access first slideMarker | |
ISlide sld = pres.Slides[0]; | |
// Add chart with default data | |
IChart chart = (IChart)sld.Shapes[0]; | |
// Setting the index of chart data sheet | |
int defaultWorksheetIndex = 0; | |
// Getting the chart data worksheet | |
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook; | |
// Changing chart Category Name | |
fact.GetCell(defaultWorksheetIndex, 1, 0, "Modified Category 1"); | |
fact.GetCell(defaultWorksheetIndex, 2, 0, "Modified Category 2"); | |
// Take first chart series | |
IChartSeries series = chart.ChartData.Series[0]; | |
// Now updating series data | |
fact.GetCell(defaultWorksheetIndex, 0, 1, "New_Series1");// Modifying series name | |
series.DataPoints[0].Value.Data = 90; | |
series.DataPoints[1].Value.Data = 123; | |
series.DataPoints[2].Value.Data = 44; | |
// Take Second chart series | |
series = chart.ChartData.Series[1]; | |
// Now updating series data | |
fact.GetCell(defaultWorksheetIndex, 0, 2, "New_Series2");// Modifying series name | |
series.DataPoints[0].Value.Data = 23; | |
series.DataPoints[1].Value.Data = 67; | |
series.DataPoints[2].Value.Data = 99; | |
// Now, Adding a new series | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 3, "Series 3"), chart.Type); | |
// Take 3rd chart series | |
series = chart.ChartData.Series[2]; | |
// Now populating series data | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 3, 20)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 3, 50)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 3, 30)); | |
chart.Type = ChartType.ClusteredCylinder; | |
// Save presentation with chart | |
pres.Save(dataDir + "AsposeChartModified_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir+"test.pptx")) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(Aspose.Slides.Charts.ChartType.ClusteredColumn, 50, 50, 600, 400); | |
chart.Legend.TextFormat.PortionFormat.FontHeight = 20; | |
chart.Axes.VerticalAxis.IsAutomaticMinValue = false; | |
chart.Axes.VerticalAxis.MinValue = -5; | |
chart.Axes.VerticalAxis.IsAutomaticMaxValue = false; | |
chart.Axes.VerticalAxis.MaxValue = 10; | |
pres.Save(dataDir+"output.pptx", SaveFormat.Pptx); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation()) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 100, 100, 500, 400); | |
chart.TextFormat.PortionFormat.FontHeight = 20; | |
chart.ChartData.Series[0].Labels.DefaultDataLabelFormat.ShowValue = true; | |
pres.Save(dataDir + "FontPropertiesForChart.pptx", SaveFormat.Pptx); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir+"test.pptx")) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 50, 50, 600, 400); | |
IChartTextFormat tf = chart.Legend.Entries[1].TextFormat; | |
tf.PortionFormat.FontBold = NullableBool.True; | |
tf.PortionFormat.FontHeight = 20; | |
tf.PortionFormat.FontItalic = NullableBool.True; | |
tf.PortionFormat.FillFormat.FillType = FillType.Solid; ; | |
tf.PortionFormat.FillFormat.SolidFillColor.Color = Color.Blue; | |
pres.Save(dataDir+"output.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run() | |
{ | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir+"test.pptx")) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Funnel, 50, 50, 500, 400); | |
chart.ChartData.Categories.Clear(); | |
chart.ChartData.Series.Clear(); | |
IChartDataWorkbook wb = chart.ChartData.ChartDataWorkbook; | |
wb.Clear(0); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "A1", "Category 1")); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "A2", "Category 2")); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "A3", "Category 3")); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "A4", "Category 4")); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "A5", "Category 5")); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "A6", "Category 6")); | |
IChartSeries series = chart.ChartData.Series.Add(ChartType.Funnel); | |
series.DataPoints.AddDataPointForFunnelSeries(wb.GetCell(0, "B1", 50)); | |
series.DataPoints.AddDataPointForFunnelSeries(wb.GetCell(0, "B2", 100)); | |
series.DataPoints.AddDataPointForFunnelSeries(wb.GetCell(0, "B3", 200)); | |
series.DataPoints.AddDataPointForFunnelSeries(wb.GetCell(0, "B4", 300)); | |
series.DataPoints.AddDataPointForFunnelSeries(wb.GetCell(0, "B5", 400)); | |
series.DataPoints.AddDataPointForFunnelSeries(wb.GetCell(0, "B6", 500)); | |
pres.Save(dataDir+"Funnel.pptx", SaveFormat.Pptx); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation()) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 50, 50, 500, 400); | |
foreach (IChartSeries series in chart.ChartData.Series) | |
{ | |
series.Labels.DefaultDataLabelFormat.Position = LegendDataLabelPosition.OutsideEnd; | |
series.Labels.DefaultDataLabelFormat.ShowValue = true; | |
} | |
chart.ValidateChartLayout(); | |
foreach (IChartSeries series in chart.ChartData.Series) | |
{ | |
foreach (IChartDataPoint point in series.DataPoints) | |
{ | |
if (point.Value.ToDouble() > 4) | |
{ | |
float x = point.Label.ActualX; | |
float y = point.Label.ActualY; | |
float w = point.Label.ActualWidth; | |
float h = point.Label.ActualHeight; | |
IAutoShape shape = chart.UserShapes.Shapes.AddAutoShape(ShapeType.Ellipse, x, y, w, h); | |
shape.FillFormat.FillType = FillType.Solid; | |
shape.FillFormat.SolidFillColor.Color = Color.FromArgb(100, 0, 255, 0); | |
} | |
} | |
} | |
pres.Save(dataDir + "GetActualPositionOFChartDatalabel", SaveFormat.Pptx); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir+"test.pptx")) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 50, 50, 600, 400); | |
Image img = chart.GetThumbnail(); | |
img.Save(dataDir+"image.png", ImageFormat.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation()) | |
{ | |
Chart chart = (Chart)pres.Slides[0].Shapes.AddChart(ChartType.Area, 100, 100, 500, 350); | |
chart.ValidateChartLayout(); | |
double maxValue = chart.Axes.VerticalAxis.ActualMaxValue; | |
double minValue = chart.Axes.VerticalAxis.ActualMinValue; | |
double majorUnit = chart.Axes.HorizontalAxis.ActualMajorUnit; | |
double minorUnit = chart.Axes.HorizontalAxis.ActualMinorUnit; | |
// Saving presentation | |
pres.Save(dataDir + "ErrorBars_out.pptx", SaveFormat.Pptx); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir+"test.Pptx")) | |
{ | |
Chart chart = (Chart)pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 100, 100, 500, 350); | |
chart.ValidateChartLayout(); | |
double x = chart.PlotArea.ActualX; | |
double y = chart.PlotArea.ActualY; | |
double w = chart.PlotArea.ActualWidth; | |
double h = chart.PlotArea.ActualHeight; | |
// Save presentation with chart | |
pres.Save(dataDir + "Chart_out.pptx", SaveFormat.Pptx); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation()) | |
{ | |
ISlide slide = pres.Slides[0]; | |
IChart chart = slide.Shapes.AddChart(ChartType.LineWithMarkers, 140, 118, 320, 370); | |
//Hiding chart Title | |
chart.HasTitle = false; | |
///Hiding Values axis | |
chart.Axes.VerticalAxis.IsVisible = false; | |
//Category Axis visibility | |
chart.Axes.HorizontalAxis.IsVisible = false; | |
//Hiding Legend | |
chart.HasLegend = false; | |
//Hiding MajorGridLines | |
chart.Axes.HorizontalAxis.MajorGridLinesFormat.Line.FillFormat.FillType = FillType.NoFill; | |
for (int i = 0; i < chart.ChartData.Series.Count; i++) | |
{ | |
chart.ChartData.Series.RemoveAt(i); | |
} | |
IChartSeries series = chart.ChartData.Series[0]; | |
series.Marker.Symbol = MarkerStyleType.Circle; | |
series.Labels.DefaultDataLabelFormat.ShowValue = true; | |
series.Labels.DefaultDataLabelFormat.Position = LegendDataLabelPosition.Top; | |
series.Marker.Size = 15; | |
//Setting series line color | |
series.Format.Line.FillFormat.FillType = FillType.Solid; | |
series.Format.Line.FillFormat.SolidFillColor.Color = Color.Purple; | |
series.Format.Line.DashStyle = LineDashStyle.Solid; | |
pres.Save(dataDir + "HideInformationFromChart.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run() | |
{ | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir+"test.pptx")) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Histogram, 50, 50, 500, 400); | |
chart.ChartData.Categories.Clear(); | |
chart.ChartData.Series.Clear(); | |
IChartDataWorkbook wb = chart.ChartData.ChartDataWorkbook; | |
wb.Clear(0); | |
IChartSeries series = chart.ChartData.Series.Add(ChartType.Histogram); | |
series.DataPoints.AddDataPointForHistogramSeries(wb.GetCell(0, "A1", 15)); | |
series.DataPoints.AddDataPointForHistogramSeries(wb.GetCell(0, "A2", -41)); | |
series.DataPoints.AddDataPointForHistogramSeries(wb.GetCell(0, "A3", 16)); | |
series.DataPoints.AddDataPointForHistogramSeries(wb.GetCell(0, "A4", 10)); | |
series.DataPoints.AddDataPointForHistogramSeries(wb.GetCell(0, "A5", -23)); | |
series.DataPoints.AddDataPointForHistogramSeries(wb.GetCell(0, "A6", 16)); | |
chart.Axes.HorizontalAxis.AggregationType = AxisAggregationType.Automatic; | |
pres.Save(dataDir+"Histogram.pptx", SaveFormat.Pptx); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Creating empty presentation | |
using (Presentation pres = new Presentation()) | |
{ | |
Chart chart = (Chart)pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 100, 100, 500, 350); | |
chart.ValidateChartLayout(); | |
double x = chart.PlotArea.ActualX; | |
double y = chart.PlotArea.ActualY; | |
double w = chart.PlotArea.ActualWidth; | |
double h = chart.PlotArea.ActualHeight; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation()) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 50, 50, 600, 400, true); | |
IChartSeriesCollection series = chart.ChartData.Series; | |
chart.ChartData.Series.Clear(); | |
series.Add(chart.ChartData.ChartDataWorkbook.GetCell(0, "B1"), chart.Type); | |
series[0].DataPoints.AddDataPointForBarSeries(chart.ChartData.ChartDataWorkbook.GetCell(0, "B2", -5)); | |
series[0].DataPoints.AddDataPointForBarSeries(chart.ChartData.ChartDataWorkbook.GetCell(0, "B3", 3)); | |
series[0].DataPoints.AddDataPointForBarSeries(chart.ChartData.ChartDataWorkbook.GetCell(0, "B4", -2)); | |
series[0].DataPoints.AddDataPointForBarSeries(chart.ChartData.ChartDataWorkbook.GetCell(0, "B5", 1)); | |
series[0].InvertIfNegative = false; | |
series[0].DataPoints[2].InvertIfNegative = true; | |
pres.Save(dataDir+ "InvertIfNegativeForIndividualSeries.pptx", SaveFormat.Pptx); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(); | |
// Access first slide | |
ISlide slide = presentation.Slides[0]; | |
// Add chart with default data | |
IChart chart = slide.Shapes.AddChart(ChartType.StackedColumn3D, 0, 0, 500, 500); | |
// Setting the index of chart data sheet | |
int defaultWorksheetIndex = 0; | |
// Getting the chart data worksheet | |
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook; | |
// Add series | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 1, "Series 1"), chart.Type); | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 2, "Series 2"), chart.Type); | |
// Add Catrgories | |
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 1, 0, "Caetegoty 1")); | |
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 2, 0, "Caetegoty 2")); | |
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 3, 0, "Caetegoty 3")); | |
// Set Rotation3D properties | |
chart.Rotation3D.RightAngleAxes = true; | |
chart.Rotation3D.RotationX = 40; | |
chart.Rotation3D.RotationY = 270; | |
chart.Rotation3D.DepthPercents = 150; | |
// Take second chart series | |
IChartSeries series = chart.ChartData.Series[1]; | |
// Now populating series data | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, 20)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 50)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 30)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 2, 30)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 2, 10)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 2, 60)); | |
// Set OverLap value | |
series.ParentSeriesGroup.Overlap = 100; | |
// Write presentation to disk | |
presentation.Save(dataDir + "Rotation3D_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
Presentation pres = new Presentation(); | |
ISlide slide = pres.Slides[0]; | |
IChart ch = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 100, 100, 600, 450); | |
ch.ChartData.Series.Clear(); | |
ch.ChartData.Categories.Clear(); | |
IChartDataWorkbook fact = ch.ChartData.ChartDataWorkbook; | |
fact.Clear(0); | |
int defaultWorksheetIndex = 0; | |
IChartCategory category = ch.ChartData.Categories.Add(fact.GetCell(0, "c2", "A")); | |
category.GroupingLevels.SetGroupingItem(1, "Group1"); | |
category = ch.ChartData.Categories.Add(fact.GetCell(0, "c3", "B")); | |
category = ch.ChartData.Categories.Add(fact.GetCell(0, "c4", "C")); | |
category.GroupingLevels.SetGroupingItem(1, "Group2"); | |
category = ch.ChartData.Categories.Add(fact.GetCell(0, "c5", "D")); | |
category = ch.ChartData.Categories.Add(fact.GetCell(0, "c6", "E")); | |
category.GroupingLevels.SetGroupingItem(1, "Group3"); | |
category = ch.ChartData.Categories.Add(fact.GetCell(0, "c7", "F")); | |
category = ch.ChartData.Categories.Add(fact.GetCell(0, "c8", "G")); | |
category.GroupingLevels.SetGroupingItem(1, "Group4"); | |
category = ch.ChartData.Categories.Add(fact.GetCell(0, "c9", "H")); | |
// Adding Series | |
IChartSeries series = ch.ChartData.Series.Add(fact.GetCell(0, "D1", "Series 1"), | |
ChartType.ClusteredColumn); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, "D2", 10)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, "D3", 20)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, "D4", 30)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, "D5", 40)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, "D6", 50)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, "D7", 60)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, "D8", 70)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, "D9", 80)); | |
// Save presentation with chart | |
pres.Save(dataDir+"AsposeChart_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate Presentation class that represents PPTX file | |
Presentation pres = new Presentation(); | |
// Access first slide | |
ISlide sld = pres.Slides[0]; | |
// Add chart with default data | |
IChart chart = sld.Shapes.AddChart(ChartType.ClusteredColumn, 0, 0, 500, 500); | |
// Setting chart Title | |
// Chart.ChartTitle.TextFrameForOverriding.Text = "Sample Title"; | |
chart.ChartTitle.AddTextFrameForOverriding("Sample Title"); | |
chart.ChartTitle.TextFrameForOverriding.TextFrameFormat.CenterText = NullableBool.True; | |
chart.ChartTitle.Height = 20; | |
chart.HasTitle = true; | |
// Set first series to Show Values | |
chart.ChartData.Series[0].Labels.DefaultDataLabelFormat.ShowValue = true; | |
// Setting the index of chart data sheet | |
int defaultWorksheetIndex = 0; | |
// Getting the chart data worksheet | |
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook; | |
// Delete default generated series and categories | |
chart.ChartData.Series.Clear(); | |
chart.ChartData.Categories.Clear(); | |
int s = chart.ChartData.Series.Count; | |
s = chart.ChartData.Categories.Count; | |
// Adding new series | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 1, "Series 1"), chart.Type); | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 2, "Series 2"), chart.Type); | |
// Adding new categories | |
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 1, 0, "Caetegoty 1")); | |
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 2, 0, "Caetegoty 2")); | |
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 3, 0, "Caetegoty 3")); | |
// Take first chart series | |
IChartSeries series = chart.ChartData.Series[0]; | |
// Now populating series data | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, 20)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 50)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 30)); | |
// Setting fill color for series | |
series.Format.Fill.FillType = FillType.Solid; | |
series.Format.Fill.SolidFillColor.Color = Color.Red; | |
// Take second chart series | |
series = chart.ChartData.Series[1]; | |
// Now populating series data | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 2, 30)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 2, 10)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 2, 60)); | |
// Setting fill color for series | |
series.Format.Fill.FillType = FillType.Solid; | |
series.Format.Fill.SolidFillColor.Color = Color.Green; | |
// First label will be show Category name | |
IDataLabel lbl = series.DataPoints[0].Label; | |
lbl.DataLabelFormat.ShowCategoryName = true; | |
lbl = series.DataPoints[1].Label; | |
lbl.DataLabelFormat.ShowSeriesName = true; | |
// Show value for third label | |
lbl = series.DataPoints[2].Label; | |
lbl.DataLabelFormat.ShowValue = true; | |
lbl.DataLabelFormat.ShowSeriesName = true; | |
lbl.DataLabelFormat.Separator = "/"; | |
// Save presentation with chart | |
pres.Save(dataDir + "AsposeChart_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate the presentation// Instantiate the presentation | |
Presentation pres = new Presentation(); | |
// Access the first presentation slide | |
ISlide slide = pres.Slides[0]; | |
// Adding a defautlt clustered column chart | |
IChart chart = slide.Shapes.AddChart(ChartType.ClusteredColumn, 50, 50, 500, 400); | |
// Accessing the chart series collection | |
IChartSeriesCollection series = chart.ChartData.Series; | |
// Setting the preset number format | |
// Traverse through every chart series | |
foreach (ChartSeries ser in series) | |
{ | |
// Traverse through every data cell in series | |
foreach (IChartDataPoint cell in ser.DataPoints) | |
{ | |
// Setting the number format | |
cell.Value.AsCell.PresetNumberFormat = 10; //0.00% | |
} | |
} | |
// Saving presentation | |
pres.Save(dataDir + "PresetNumberFormat_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run() | |
{ | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir+"test.pptx")) | |
{ | |
ISmartArt smartArt = pres.Slides[0].Shapes.AddSmartArt(0, 0, 400, 400, SmartArtLayoutType.PictureOrganizationChart); | |
pres.Save(dataDir+"OrganizationChart.pptx", SaveFormat.Pptx); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Instantiate Presentation class that represents PPTX file | |
Presentation presentation = new Presentation(); | |
// Access first slide | |
ISlide slides = presentation.Slides[0]; | |
// Add chart with default data | |
IChart chart = slides.Shapes.AddChart(ChartType.Pie, 100, 100, 400, 400); | |
// Setting chart Title | |
chart.ChartTitle.AddTextFrameForOverriding("Sample Title"); | |
chart.ChartTitle.TextFrameForOverriding.TextFrameFormat.CenterText = NullableBool.True; | |
chart.ChartTitle.Height = 20; | |
chart.HasTitle = true; | |
// Set first series to Show Values | |
chart.ChartData.Series[0].Labels.DefaultDataLabelFormat.ShowValue = true; | |
// Setting the index of chart data sheet | |
int defaultWorksheetIndex = 0; | |
// Getting the chart data worksheet | |
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook; | |
// Delete default generated series and categories | |
chart.ChartData.Series.Clear(); | |
chart.ChartData.Categories.Clear(); | |
// Adding new categories | |
chart.ChartData.Categories.Add(fact.GetCell(0, 1, 0, "First Qtr")); | |
chart.ChartData.Categories.Add(fact.GetCell(0, 2, 0, "2nd Qtr")); | |
chart.ChartData.Categories.Add(fact.GetCell(0, 3, 0, "3rd Qtr")); | |
// Adding new series | |
IChartSeries series = chart.ChartData.Series.Add(fact.GetCell(0, 0, 1, "Series 1"), chart.Type); | |
// Now populating series data | |
series.DataPoints.AddDataPointForPieSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, 20)); | |
series.DataPoints.AddDataPointForPieSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 50)); | |
series.DataPoints.AddDataPointForPieSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 30)); | |
// Not working in new version | |
// Adding new points and setting sector color | |
// series.IsColorVaried = true; | |
chart.ChartData.SeriesGroups[0].IsColorVaried = true; | |
IChartDataPoint point = series.DataPoints[0]; | |
point.Format.Fill.FillType = FillType.Solid; | |
point.Format.Fill.SolidFillColor.Color = Color.Cyan; | |
// Setting Sector border | |
point.Format.Line.FillFormat.FillType = FillType.Solid; | |
point.Format.Line.FillFormat.SolidFillColor.Color = Color.Gray; | |
point.Format.Line.Width = 3.0; | |
point.Format.Line.Style = LineStyle.ThinThick; | |
point.Format.Line.DashStyle = LineDashStyle.DashDot; | |
IChartDataPoint point1 = series.DataPoints[1]; | |
point1.Format.Fill.FillType = FillType.Solid; | |
point1.Format.Fill.SolidFillColor.Color = Color.Brown; | |
// Setting Sector border | |
point1.Format.Line.FillFormat.FillType = FillType.Solid; | |
point1.Format.Line.FillFormat.SolidFillColor.Color = Color.Blue; | |
point1.Format.Line.Width = 3.0; | |
point1.Format.Line.Style = LineStyle.Single; | |
point1.Format.Line.DashStyle = LineDashStyle.LargeDashDot; | |
IChartDataPoint point2 = series.DataPoints[2]; | |
point2.Format.Fill.FillType = FillType.Solid; | |
point2.Format.Fill.SolidFillColor.Color = Color.Coral; | |
// Setting Sector border | |
point2.Format.Line.FillFormat.FillType = FillType.Solid; | |
point2.Format.Line.FillFormat.SolidFillColor.Color = Color.Red; | |
point2.Format.Line.Width = 2.0; | |
point2.Format.Line.Style = LineStyle.ThinThin; | |
point2.Format.Line.DashStyle = LineDashStyle.LargeDashDotDot; | |
// Create custom labels for each of categories for new series | |
IDataLabel lbl1 = series.DataPoints[0].Label; | |
// lbl.ShowCategoryName = true; | |
lbl1.DataLabelFormat.ShowValue = true; | |
IDataLabel lbl2 = series.DataPoints[1].Label; | |
lbl2.DataLabelFormat.ShowValue = true; | |
lbl2.DataLabelFormat.ShowLegendKey = true; | |
lbl2.DataLabelFormat.ShowPercentage = true; | |
IDataLabel lbl3 = series.DataPoints[2].Label; | |
lbl3.DataLabelFormat.ShowSeriesName = true; | |
lbl3.DataLabelFormat.ShowPercentage = true; | |
// Showing Leader Lines for Chart | |
series.Labels.DefaultDataLabelFormat.ShowLeaderLines = true; | |
// Setting Rotation Angle for Pie Chart Sectors | |
chart.ChartData.SeriesGroups[0].FirstSliceAngle = 180; | |
// Save presentation with chart | |
presentation.Save(dataDir + "PieChart_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Our desired height | |
int desiredHeight = 288;//4 inch (4 * 72) | |
//Our desired width | |
int desiredWidth = 684;//9.5 inch (9.5 * 72) | |
//define chart size with window | |
chart.SizeWithWindow = true; | |
//set window width of the workbook in inches | |
wb.Worksheets.WindowWidthInch = desiredWidth / 72f; | |
//set window height of the workbook in inches | |
wb.Worksheets.WindowHeightInch = desiredHeight / 72f; | |
//Instantiate MemoryStream | |
MemoryStream ms = wb.SaveToStream(); | |
//Create an OLE Object Frame with embedded Excel | |
Aspose.Slides.OleObjectFrame objFrame = slide.Shapes.AddOleObjectFrame( | |
36, | |
72, | |
desiredWidth, | |
desiredHeight, "Excel.Sheet.8", ms.ToArray()); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Our desired height | |
int desiredHeight = 288;//4 inch (4 * 576) | |
//Our desired width | |
int desiredWidth = 684;//9.5 inch (9.5 * 576) | |
//define chart size without window | |
chart.SizeWithWindow = false; | |
//set chart width in pixels | |
chart.ChartObject.Width = (int)((desiredWidth / 72f) * 96f); | |
//set chart height in pixels | |
chart.ChartObject.Height = (int)((desiredHeight / 72f) * 96f); | |
//Instantiate MemoryStream | |
MemoryStream ms = wb.SaveToStream(); | |
//Create an OLE Object Frame with embedded Excel | |
Aspose.Slides.OleObjectFrame objFrame = slide.Shapes.AddOleObjectFrame( | |
36, | |
72, | |
desiredWidth, | |
desiredHeight, "Excel.Sheet.8", ms.ToArray()); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//define chart size with window | |
chart.SizeWithWindow = true; | |
//set window width of the workbook in inches (divided by 72 as PowerPoint uses | |
//72 pixels / inch) | |
wb.Worksheets.WindowWidthInch = slide.Shapes[2].Width / 72f; | |
//set window height of the workbook in inches | |
wb.Worksheets.WindowHeightInch = slide.Shapes[2].Height / 72f; | |
//Instantiate MemoryStream | |
MemoryStream ms = wb.SaveToStream(); | |
//Create an OLE Object Frame with embedded Excel | |
Aspose.Slides.OleObjectFrame objFrame = slide.Shapes.AddOleObjectFrame( | |
slide.Shapes[2].X, | |
slide.Shapes[2].Y, | |
slide.Shapes[2].Width, | |
slide.Shapes[2].Height, "Excel.Sheet.8", ms.ToArray()); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//define chart size without window | |
chart.SizeWithWindow = false; | |
//set chart width in pixels (Multiply by 96 as Excel uses 96 pixels per inch) | |
chart.ChartObject.Width = (int)((slide.Shapes[2].Width / 72f) * 96f); | |
//set chart height in pixels | |
chart.ChartObject.Height = (int)((slide.Shapes[2].Height / 72f) * 96f); | |
//Define chart print size | |
chart.PrintSize = PrintSizeType.Custom; | |
//Instantiate MemoryStream | |
MemoryStream ms = wb.SaveToStream(); | |
//Create an OLE Object Frame with embedded Excel | |
Aspose.Slides.OleObjectFrame objFrame = slide.Shapes.AddOleObjectFrame( | |
slide.Shapes[2].X, | |
slide.Shapes[2].Y, | |
slide.Shapes[2].Width, | |
slide.Shapes[2].Height, "Excel.Sheet.8", ms.ToArray()); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
Presentation pres = new Presentation(); | |
ISlide slide = pres.Slides[0]; | |
// Creating the default chart | |
IChart chart = slide.Shapes.AddChart(ChartType.ScatterWithSmoothLines, 0, 0, 400, 400); | |
// Getting the default chart data worksheet index | |
int defaultWorksheetIndex = 0; | |
// Getting the chart data worksheet | |
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook; | |
// Delete demo series | |
chart.ChartData.Series.Clear(); | |
// Add new series | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 1, 1, "Series 1"), chart.Type); | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 1, 3, "Series 2"), chart.Type); | |
// Take first chart series | |
IChartSeries series = chart.ChartData.Series[0]; | |
// Add new point (1:3) there. | |
series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 1), fact.GetCell(defaultWorksheetIndex, 2, 2, 3)); | |
// Add new point (2:10) | |
series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 2), fact.GetCell(defaultWorksheetIndex, 3, 2, 10)); | |
// Edit the type of series | |
series.Type = ChartType.ScatterWithStraightLinesAndMarkers; | |
// Changing the chart series marker | |
series.Marker.Size = 10; | |
series.Marker.Symbol = MarkerStyleType.Star; | |
// Take second chart series | |
series = chart.ChartData.Series[1]; | |
// Add new point (5:2) there. | |
series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 2, 3, 5), fact.GetCell(defaultWorksheetIndex, 2, 4, 2)); | |
// Add new point (3:1) | |
series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 3, 3, 3), fact.GetCell(defaultWorksheetIndex, 3, 4, 1)); | |
// Add new point (2:2) | |
series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 4, 3, 2), fact.GetCell(defaultWorksheetIndex, 4, 4, 2)); | |
// Add new point (5:1) | |
series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 5, 3, 5), fact.GetCell(defaultWorksheetIndex, 5, 4, 1)); | |
// Changing the chart series marker | |
series.Marker.Size = 10; | |
series.Marker.Symbol = MarkerStyleType.Circle; | |
pres.Save(dataDir + "AsposeChart_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(); | |
// Add chart on slide | |
IChart chart = presentation.Slides[0].Shapes.AddChart(ChartType.PieOfPie, 50, 50, 500, 400); | |
// Set different properties | |
chart.ChartData.Series[0].Labels.DefaultDataLabelFormat.ShowValue = true; | |
chart.ChartData.Series[0].ParentSeriesGroup.SecondPieSize = 149; | |
chart.ChartData.Series[0].ParentSeriesGroup.PieSplitBy = Aspose.Slides.Charts.PieSplitType.ByPercentage; | |
chart.ChartData.Series[0].ParentSeriesGroup.PieSplitPosition = 53; | |
// Write presentation to disk | |
presentation.Save(dataDir + "SecondPlotOptionsforCharts_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Creating a clustered column chart | |
IChart chart = presentation.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 100, 50, 600, 400); | |
// Setting series fill format to automatic | |
for (int i = 0; i < chart.ChartData.Series.Count; i++) | |
{ | |
chart.ChartData.Series[i].GetAutomaticSeriesColor(); | |
} | |
// Write the presentation file to disk | |
presentation.Save(dataDir + "AutoFillSeries_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
Presentation presentation = new Presentation(); | |
// Get reference of the slide | |
ISlide sld = presentation.Slides[0]; | |
// Adding a chart on slide | |
IChart ch = sld.Shapes.AddChart(ChartType.ClusteredColumn, 20, 20, 500, 300); | |
// Setting the position of label from axis | |
ch.Axes.HorizontalAxis.LabelOffset = 500; | |
// Write the presentation file to disk | |
presentation.Save(dataDir + "SetCategoryAxisLabelDistance_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Presentation pres = new Presentation(dataDir+"Test.pptx"); | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Pie, 50, 50, 500, 400); | |
chart.ChartData.ChartDataWorkbook.Clear(0); | |
Workbook workbook = null; | |
try | |
{ | |
workbook = new Aspose.Cells.Workbook(dataDir + "book1.xlsx"); | |
} | |
catch (Exception ex) | |
{ | |
Console.Write(ex); | |
} | |
MemoryStream mem = new MemoryStream(); | |
workbook.Save(mem, Aspose.Cells.SaveFormat.Xlsx); | |
chart.ChartData.WriteWorkbookStream(mem); | |
chart.ChartData.SetRange("Sheet1!$A$1:$B$9"); | |
IChartSeries series = chart.ChartData.Series[0]; | |
series.ParentSeriesGroup.IsColorVaried = true; | |
pres.Save(dataDir+"response2.pptx", Aspose.Slides.Export.SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Adding chart | |
IChart chart = presentation.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 50, 50, 600, 400, true); | |
IChartSeriesCollection series = chart.ChartData.Series; | |
if (series[0].Overlap == 0) | |
{ | |
// Setting series overlap | |
series[0].ParentSeriesGroup.Overlap = -30; | |
} | |
// Write the presentation file to disk | |
presentation.Save(dataDir + "SetChartSeriesOverlap_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(); | |
// Get reference of the slide | |
ISlide slide = presentation.Slides[0]; | |
// Add PercentsStackedColumn chart on a slide | |
IChart chart = slide.Shapes.AddChart(ChartType.PercentsStackedColumn, 20, 20, 500, 400); | |
// Set NumberFormatLinkedToSource to false | |
chart.Axes.VerticalAxis.IsNumberFormatLinkedToSource = false; | |
chart.Axes.VerticalAxis.NumberFormat = "0.00%"; | |
chart.ChartData.Series.Clear(); | |
int defaultWorksheetIndex = 0; | |
// Getting the chart data worksheet | |
IChartDataWorkbook workbook = chart.ChartData.ChartDataWorkbook; | |
// Add new series | |
IChartSeries series = chart.ChartData.Series.Add(workbook.GetCell(defaultWorksheetIndex, 0, 1, "Reds"), chart.Type); | |
series.DataPoints.AddDataPointForBarSeries(workbook.GetCell(defaultWorksheetIndex, 1, 1, 0.30)); | |
series.DataPoints.AddDataPointForBarSeries(workbook.GetCell(defaultWorksheetIndex, 2, 1, 0.50)); | |
series.DataPoints.AddDataPointForBarSeries(workbook.GetCell(defaultWorksheetIndex, 3, 1, 0.80)); | |
series.DataPoints.AddDataPointForBarSeries(workbook.GetCell(defaultWorksheetIndex, 4, 1, 0.65)); | |
// Setting the fill color of series | |
series.Format.Fill.FillType = FillType.Solid; | |
series.Format.Fill.SolidFillColor.Color = Color.Red; | |
// Setting LabelFormat properties | |
series.Labels.DefaultDataLabelFormat.ShowValue = true; | |
series.Labels.DefaultDataLabelFormat.IsNumberFormatLinkedToSource = false; | |
series.Labels.DefaultDataLabelFormat.NumberFormat = "0.0%"; | |
series.Labels.DefaultDataLabelFormat.TextFormat.PortionFormat.FontHeight = 10; | |
series.Labels.DefaultDataLabelFormat.TextFormat.PortionFormat.FillFormat.FillType = FillType.Solid; | |
series.Labels.DefaultDataLabelFormat.TextFormat.PortionFormat.FillFormat.SolidFillColor.Color = Color.White; | |
series.Labels.DefaultDataLabelFormat.ShowValue = true; | |
// Add new series | |
IChartSeries series2 = chart.ChartData.Series.Add(workbook.GetCell(defaultWorksheetIndex, 0, 2, "Blues"), chart.Type); | |
series2.DataPoints.AddDataPointForBarSeries(workbook.GetCell(defaultWorksheetIndex, 1, 2, 0.70)); | |
series2.DataPoints.AddDataPointForBarSeries(workbook.GetCell(defaultWorksheetIndex, 2, 2, 0.50)); | |
series2.DataPoints.AddDataPointForBarSeries(workbook.GetCell(defaultWorksheetIndex, 3, 2, 0.20)); | |
series2.DataPoints.AddDataPointForBarSeries(workbook.GetCell(defaultWorksheetIndex, 4, 2, 0.35)); | |
// Setting Fill type and color | |
series2.Format.Fill.FillType = FillType.Solid; | |
series2.Format.Fill.SolidFillColor.Color = Color.Blue; | |
series2.Labels.DefaultDataLabelFormat.ShowValue = true; | |
series2.Labels.DefaultDataLabelFormat.IsNumberFormatLinkedToSource = false; | |
series2.Labels.DefaultDataLabelFormat.NumberFormat = "0.0%"; | |
series2.Labels.DefaultDataLabelFormat.TextFormat.PortionFormat.FontHeight = 10; | |
series2.Labels.DefaultDataLabelFormat.TextFormat.PortionFormat.FillFormat.FillType = FillType.Solid; | |
series2.Labels.DefaultDataLabelFormat.TextFormat.PortionFormat.FillFormat.SolidFillColor.Color = Color.White; | |
// Write presentation to disk | |
presentation.Save(dataDir + "SetDataLabelsPercentageSign_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Instantiate Presentation class that represents PPTX file | |
Presentation presentation = new Presentation(dataDir + "ExistingChart.pptx"); | |
// Access first slideMarker and add chart with default data | |
ISlide slide = presentation.Slides[0]; | |
IChart chart = (IChart)slide.Shapes[0]; | |
chart.ChartData.SetRange("Sheet1!A1:B4"); | |
presentation.Save(dataDir + "SetDataRange_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation()) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Pie, 50, 50, 400, 600, false); | |
IChartData chartData = chart.ChartData; | |
chartData.SetExternalWorkbook(dataDir+ "externalWorkbook.xlsx"); | |
chartData.Series.Add(chartData.ChartDataWorkbook.GetCell(0, "B1"), ChartType.Pie); | |
chartData.Series[0].DataPoints.AddDataPointForPieSeries(chartData.ChartDataWorkbook.GetCell(0, "B2")); | |
chartData.Series[0].DataPoints.AddDataPointForPieSeries(chartData.ChartDataWorkbook.GetCell(0, "B3")); | |
chartData.Series[0].DataPoints.AddDataPointForPieSeries(chartData.ChartDataWorkbook.GetCell(0, "B4")); | |
chartData.Categories.Add(chartData.ChartDataWorkbook.GetCell(0, "A2")); | |
chartData.Categories.Add(chartData.ChartDataWorkbook.GetCell(0, "A3")); | |
chartData.Categories.Add(chartData.ChartDataWorkbook.GetCell(0, "A4")); | |
pres.Save(dataDir + "Presentation_with_externalWorkbook.pptx", SaveFormat.Pptx); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string externalWbPath = @"http://606178d2.ngrok.io/webgrind/styles/2.xlsx"; | |
LoadOptions opts = new LoadOptions(); | |
opts.ResourceLoadingCallback = new WorkbookLoadingHandler(); | |
using (Presentation pres = new Presentation(opts)) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Pie, 50, 50, 400, 600, false); | |
IChartData chartData = chart.ChartData; | |
(chartData as ChartData).SetExternalWorkbook(externalWbPath); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation()) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Pie, 50, 50, 400, 600, true); | |
IChartData chartData = chart.ChartData; | |
(chartData as ChartData).SetExternalWorkbook("http://path/doesnt/exists", false); | |
pres.Save(dataDir + "SetExternalWorkbookWithUpdateChartData.pptx", SaveFormat.Pptx); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Creating empty presentation | |
Presentation presentation = new Presentation(); | |
// Access first slide | |
ISlide slide = presentation.Slides[0]; | |
// Add chart with default data | |
IChart chart = slide.Shapes.AddChart(ChartType.StackedColumn, 0, 0, 500, 500); | |
// Setting the index of chart data sheet | |
int defaultWorksheetIndex = 0; | |
// Getting the chart data worksheet | |
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook; | |
// Add series | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 1, "Series 1"), chart.Type); | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 2, "Series 2"), chart.Type); | |
// Add Catrgories | |
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 1, 0, "Caetegoty 1")); | |
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 2, 0, "Caetegoty 2")); | |
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 3, 0, "Caetegoty 3")); | |
// Take second chart series | |
IChartSeries series = chart.ChartData.Series[1]; | |
// Now populating series data | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, 20)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 50)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 30)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 2, 30)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 2, 10)); | |
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 2, 60)); | |
// Set GapWidth value | |
series.ParentSeriesGroup.GapWidth = 50; | |
// Save presentation with chart | |
presentation.Save(dataDir + "GapWidth_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
Color inverColor = Color.Red; | |
using (Presentation pres = new Presentation()) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 100, 100, 400, 300); | |
IChartDataWorkbook workBook = chart.ChartData.ChartDataWorkbook; | |
chart.ChartData.Series.Clear(); | |
chart.ChartData.Categories.Clear(); | |
// Adding new series and categories | |
chart.ChartData.Series.Add(workBook.GetCell(0, 0, 1, "Series 1"), chart.Type); | |
chart.ChartData.Categories.Add(workBook.GetCell(0, 1, 0, "Category 1")); | |
chart.ChartData.Categories.Add(workBook.GetCell(0, 2, 0, "Category 2")); | |
chart.ChartData.Categories.Add(workBook.GetCell(0, 3, 0, "Category 3")); | |
// Take first chart series and populating series data. | |
IChartSeries series = chart.ChartData.Series[0]; | |
series.DataPoints.AddDataPointForBarSeries(workBook.GetCell(0, 1, 1, -20)); | |
series.DataPoints.AddDataPointForBarSeries(workBook.GetCell(0, 2, 1, 50)); | |
series.DataPoints.AddDataPointForBarSeries(workBook.GetCell(0, 3, 1, -30)); | |
var seriesColor = series.GetAutomaticSeriesColor(); | |
series.InvertIfNegative = true; | |
series.Format.Fill.FillType = FillType.Solid; | |
series.Format.Fill.SolidFillColor.Color = seriesColor; | |
series.InvertedSolidFillColor.Color = inverColor; | |
pres.Save(dataDir + "SetInvertFillColorChart_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation presentation = new Presentation()) | |
{ | |
ISlide slide = presentation.Slides[0]; | |
IChart chart = slide.Shapes.AddChart(ChartType.ClusteredColumn, 20, 100, 600, 400); | |
chart.PlotArea.AsILayoutable.X = 0.2f; | |
chart.PlotArea.AsILayoutable.Y = 0.2f; | |
chart.PlotArea.AsILayoutable.Width = 0.7f; | |
chart.PlotArea.AsILayoutable.Height = 0.7f; | |
chart.PlotArea.LayoutTargetType = LayoutTargetType.Inner; | |
presentation.Save(dataDir + "SetLayoutMode_outer.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(); | |
// Get reference of the slide | |
ISlide slide = presentation.Slides[0]; | |
// Add a clustered column chart on the slide | |
IChart chart = slide.Shapes.AddChart(ChartType.ClusteredColumn, 50, 50, 500, 500); | |
// Set Legend Properties | |
chart.Legend.X = 50 / chart.Width; | |
chart.Legend.Y = 50 / chart.Height; | |
chart.Legend.Width = 100 / chart.Width; | |
chart.Legend.Height = 100 / chart.Height; | |
// Write presentation to disk | |
presentation.Save(dataDir + "Legend_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(); | |
ISlide slide = presentation.Slides[0]; | |
// Creating the default chart | |
IChart chart = slide.Shapes.AddChart(ChartType.LineWithMarkers, 0, 0, 400, 400); | |
// Getting the default chart data worksheet index | |
int defaultWorksheetIndex = 0; | |
// Getting the chart data worksheet | |
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook; | |
// Delete demo series | |
chart.ChartData.Series.Clear(); | |
// Add new series | |
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 1, 1, "Series 1"), chart.Type); | |
// Set the picture | |
System.Drawing.Image image1 = (System.Drawing.Image)new Bitmap(dataDir + "aspose-logo.jpg"); | |
IPPImage imgx1 = presentation.Images.AddImage(image1); | |
// Set the picture | |
System.Drawing.Image image2 = (System.Drawing.Image)new Bitmap(dataDir + "Tulips.jpg"); | |
IPPImage imgx2 = presentation.Images.AddImage(image2); | |
// Take first chart series | |
IChartSeries series = chart.ChartData.Series[0]; | |
// Add new point (1:3) there. | |
IChartDataPoint point = series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, (double)4.5)); | |
point.Marker.Format.Fill.FillType = FillType.Picture; | |
point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx1; | |
point = series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, (double)2.5)); | |
point.Marker.Format.Fill.FillType = FillType.Picture; | |
point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx2; | |
point = series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, (double)3.5)); | |
point.Marker.Format.Fill.FillType = FillType.Picture; | |
point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx1; | |
point = series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 4, 1, (double)4.5)); | |
point.Marker.Format.Fill.FillType = FillType.Picture; | |
point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx2; | |
// Changing the chart series marker | |
series.Marker.Size = 15; | |
// Write presentation to disk | |
presentation.Save(dataDir + "MarkOptions_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Instantiate Presentation class that represents PPTX file | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Access first slide | |
ISlide slides = presentation.Slides[0]; | |
// Add chart with default data | |
IChart chart = slides.Shapes.AddChart(ChartType.Pie, 100, 100, 400, 400); | |
// Setting chart Title | |
chart.ChartTitle.AddTextFrameForOverriding("Sample Title"); | |
chart.ChartTitle.TextFrameForOverriding.TextFrameFormat.CenterText = NullableBool.True; | |
chart.ChartTitle.Height = 20; | |
chart.HasTitle = true; | |
// Set first series to Show Values | |
chart.ChartData.Series[0].Labels.DefaultDataLabelFormat.ShowValue = true; | |
// Setting the index of chart data sheet | |
int defaultWorksheetIndex = 0; | |
// Getting the chart data worksheet | |
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook; | |
// Delete default generated series and categories | |
chart.ChartData.Series.Clear(); | |
chart.ChartData.Categories.Clear(); | |
// Adding new categories | |
chart.ChartData.Categories.Add(fact.GetCell(0, 1, 0, "First Qtr")); | |
chart.ChartData.Categories.Add(fact.GetCell(0, 2, 0, "2nd Qtr")); | |
chart.ChartData.Categories.Add(fact.GetCell(0, 3, 0, "3rd Qtr")); | |
// Adding new series | |
IChartSeries series = chart.ChartData.Series.Add(fact.GetCell(0, 0, 1, "Series 1"), chart.Type); | |
// Now populating series data | |
series.DataPoints.AddDataPointForPieSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, 20)); | |
series.DataPoints.AddDataPointForPieSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 50)); | |
series.DataPoints.AddDataPointForPieSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 30)); | |
series.ParentSeriesGroup.IsColorVaried = true; | |
presentation.Save(dataDir + "Pie.pptx", Aspose.Slides.Export.SaveFormat.Pptx); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string dataDir = RunExamples.GetDataDir_Charts(); | |
Presentation pres = new Presentation(dataDir+"testc.pptx"); | |
ISlide slide = pres.Slides[0]; | |
IChart chart = slide.Shapes.AddChart(ChartType.Doughnut, 10, 10, 500, 500, false); | |
IChartDataWorkbook workBook = chart.ChartData.ChartDataWorkbook; | |
chart.ChartData.Series.Clear(); | |
chart.ChartData.Categories.Clear(); | |
chart.HasLegend = false; | |
int seriesIndex = 0; | |
while (seriesIndex < 15) | |
{ | |
IChartSeries series = chart.ChartData.Series.Add(workBook.GetCell(0, 0, seriesIndex + 1, "SERIES " + seriesIndex), chart.Type); | |
series.Explosion = 0; | |
series.ParentSeriesGroup.DoughnutHoleSize = (byte)20; | |
series.ParentSeriesGroup.FirstSliceAngle = 351; | |
seriesIndex++; | |
} | |
int categoryIndex = 0; | |
while (categoryIndex < 15) | |
{ | |
chart.ChartData.Categories.Add(workBook.GetCell(0, categoryIndex + 1, 0, "CATEGORY " + categoryIndex)); | |
int i = 0; | |
while (i < chart.ChartData.Series.Count) | |
{ | |
IChartSeries iCS = chart.ChartData.Series[i]; | |
IChartDataPoint dataPoint = iCS.DataPoints.AddDataPointForDoughnutSeries(workBook.GetCell(0, categoryIndex + 1, i + 1, 1)); | |
dataPoint.Format.Fill.FillType = FillType.Solid; | |
dataPoint.Format.Line.FillFormat.FillType = FillType.Solid; | |
dataPoint.Format.Line.FillFormat.SolidFillColor.Color = Color.White; | |
dataPoint.Format.Line.Width = 1; | |
dataPoint.Format.Line.Style = LineStyle.Single; | |
dataPoint.Format.Line.DashStyle = LineDashStyle.Solid; | |
if (i == chart.ChartData.Series.Count - 1) | |
{ | |
IDataLabel lbl = dataPoint.Label; | |
lbl.TextFormat.TextBlockFormat.AutofitType = TextAutofitType.Shape; | |
lbl.DataLabelFormat.TextFormat.PortionFormat.FontBold = NullableBool.True; | |
lbl.DataLabelFormat.TextFormat.PortionFormat.LatinFont = new FontData("DINPro-Bold"); | |
lbl.DataLabelFormat.TextFormat.PortionFormat.FontHeight = 12; | |
lbl.DataLabelFormat.TextFormat.PortionFormat.FillFormat.FillType = FillType.Solid; | |
lbl.DataLabelFormat.TextFormat.PortionFormat.FillFormat.SolidFillColor.Color = Color.LightGray; | |
lbl.DataLabelFormat.Format.Line.FillFormat.SolidFillColor.Color = Color.White; | |
lbl.DataLabelFormat.ShowValue = false; | |
lbl.DataLabelFormat.ShowCategoryName = true; | |
lbl.DataLabelFormat.ShowSeriesName = false; | |
//lbl.DataLabelFormat.ShowLabelAsDataCallout = true; | |
lbl.DataLabelFormat.ShowLeaderLines = true; | |
lbl.DataLabelFormat.ShowLabelAsDataCallout = false; | |
chart.ValidateChartLayout(); | |
lbl.AsILayoutable.X = (float)lbl.AsILayoutable.X + (float)0.5; | |
lbl.AsILayoutable.Y = (float)lbl.AsILayoutable.Y + (float)0.5; | |
} | |
i++; | |
} | |
categoryIndex++; | |
} | |
pres.Save("chart.pptx", Aspose.Slides.Export.SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation()) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Area, 50, 50, 450, 300); | |
IChartDataWorkbook wb = chart.ChartData.ChartDataWorkbook; | |
wb.Clear(0); | |
chart.ChartData.Categories.Clear(); | |
chart.ChartData.Series.Clear(); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "A2", new DateTime(2015, 1, 1).ToOADate())); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "A3", new DateTime(2016, 1, 1).ToOADate())); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "A4", new DateTime(2017, 1, 1).ToOADate())); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "A5", new DateTime(2018, 1, 1).ToOADate())); | |
IChartSeries series = chart.ChartData.Series.Add(ChartType.Line); | |
series.DataPoints.AddDataPointForLineSeries(wb.GetCell(0, "B2", 1)); | |
series.DataPoints.AddDataPointForLineSeries(wb.GetCell(0, "B3", 2)); | |
series.DataPoints.AddDataPointForLineSeries(wb.GetCell(0, "B4", 3)); | |
series.DataPoints.AddDataPointForLineSeries(wb.GetCell(0, "B5", 4)); | |
chart.Axes.HorizontalAxis.CategoryAxisType = CategoryAxisType.Date; | |
chart.Axes.HorizontalAxis.IsNumberFormatLinkedToSource = false; | |
chart.Axes.HorizontalAxis.NumberFormat = "yyyy"; | |
pres.Save(dataDir+"test.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir+"test.pptx")) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 50, 50, 600, 400); | |
chart.HasDataTable = true; | |
chart.ChartDataTable.TextFormat.PortionFormat.FontBold = NullableBool.True; | |
chart.ChartDataTable.TextFormat.PortionFormat.FontHeight = 20; | |
pres.Save(dataDir+"output.pptx", SaveFormat.Pptx); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation()) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 50, 50, 450, 300); | |
chart.Axes.HorizontalAxis.AxisBetweenCategories = true; | |
pres.Save(dataDir + "AsposeScatterChart.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation()) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 50, 50, 450, 300); | |
chart.Axes.VerticalAxis.HasTitle = true; | |
chart.Axes.VerticalAxis.Title.TextFormat.TextBlockFormat.RotationAngle = 90; | |
pres.Save(dataDir + "test.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir+"Test.pptx")) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 50, 50, 450, 300); | |
chart.Axes.VerticalAxis.DisplayUnit = DisplayUnitType.Millions; | |
pres.Save(dataDir + "Result.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run() | |
{ | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir+"test.pptx")) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Sunburst, 50, 50, 500, 400); | |
chart.ChartData.Categories.Clear(); | |
chart.ChartData.Series.Clear(); | |
IChartDataWorkbook wb = chart.ChartData.ChartDataWorkbook; | |
wb.Clear(0); | |
//branch 1 | |
IChartCategory leaf = chart.ChartData.Categories.Add(wb.GetCell(0, "C1", "Leaf1")); | |
leaf.GroupingLevels.SetGroupingItem(1, "Stem1"); | |
leaf.GroupingLevels.SetGroupingItem(2, "Branch1"); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "C2", "Leaf2")); | |
leaf = chart.ChartData.Categories.Add(wb.GetCell(0, "C3", "Leaf3")); | |
leaf.GroupingLevels.SetGroupingItem(1, "Stem2"); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "C4", "Leaf4")); | |
//branch 2 | |
leaf = chart.ChartData.Categories.Add(wb.GetCell(0, "C5", "Leaf5")); | |
leaf.GroupingLevels.SetGroupingItem(1, "Stem3"); | |
leaf.GroupingLevels.SetGroupingItem(2, "Branch2"); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "C6", "Leaf6")); | |
leaf = chart.ChartData.Categories.Add(wb.GetCell(0, "C7", "Leaf7")); | |
leaf.GroupingLevels.SetGroupingItem(1, "Stem4"); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "C8", "Leaf8")); | |
IChartSeries series = chart.ChartData.Series.Add(ChartType.Sunburst); | |
series.Labels.DefaultDataLabelFormat.ShowCategoryName = true; | |
series.DataPoints.AddDataPointForSunburstSeries(wb.GetCell(0, "D1", 4)); | |
series.DataPoints.AddDataPointForSunburstSeries(wb.GetCell(0, "D2", 5)); | |
series.DataPoints.AddDataPointForSunburstSeries(wb.GetCell(0, "D3", 3)); | |
series.DataPoints.AddDataPointForSunburstSeries(wb.GetCell(0, "D4", 6)); | |
series.DataPoints.AddDataPointForSunburstSeries(wb.GetCell(0, "D5", 9)); | |
series.DataPoints.AddDataPointForSunburstSeries(wb.GetCell(0, "D6", 9)); | |
series.DataPoints.AddDataPointForSunburstSeries(wb.GetCell(0, "D7", 4)); | |
series.DataPoints.AddDataPointForSunburstSeries(wb.GetCell(0, "D8", 3)); | |
pres.Save("Sunburst.pptx", SaveFormat.Pptx); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation()) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Bubble, 100, 100, 400, 300); | |
chart.ChartData.SeriesGroups[0].BubbleSizeScale = 150; | |
pres.Save(dataDir+"Result.pptx",Aspose.Slides.Export.SaveFormat.Pptx); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir+"test.pptx")) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Pie, 50, 50, 600, 400); | |
IChartDataPoint point = chart.ChartData.Series[0].DataPoints[1]; | |
point.Explosion = 30; | |
point.Format.Fill.FillType = FillType.Solid; | |
point.Format.Fill.SolidFillColor.Color = Color.Blue; | |
pres.Save(dataDir+"output.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation presentation = new Presentation()) | |
{ | |
ISlide slide = presentation.Slides[0]; | |
IChart chart = slide.Shapes.AddChart(ChartType.ClusteredColumn, 20, 100, 600, 400); | |
chart.LineFormat.FillFormat.FillType = FillType.Solid; | |
chart.LineFormat.Style = LineStyle.Single; | |
chart.HasRoundedCorners = true; | |
presentation.Save(dataDir + "out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation()) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Line, 50, 50, 450, 300); | |
chart.HasDataTable = true; | |
chart.ChartData.Series[0].NumberFormatOfValues = "#,##0.00"; | |
pres.Save(dataDir + "PrecisionOfDatalabels_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir+"Test.pptx")) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.OpenHighLowClose, 50, 50, 600, 400, false); | |
chart.ChartData.Series.Clear(); | |
chart.ChartData.Categories.Clear(); | |
IChartDataWorkbook wb = chart.ChartData.ChartDataWorkbook; | |
chart.ChartData.Categories.Add(wb.GetCell(0, 1, 0, "A")); | |
chart.ChartData.Categories.Add(wb.GetCell(0, 2, 0, "B")); | |
chart.ChartData.Categories.Add(wb.GetCell(0, 3, 0, "C")); | |
chart.ChartData.Series.Add(wb.GetCell(0, 0, 1, "Open"), chart.Type); | |
chart.ChartData.Series.Add(wb.GetCell(0, 0, 2, "High"), chart.Type); | |
chart.ChartData.Series.Add(wb.GetCell(0, 0, 3, "Low"), chart.Type); | |
chart.ChartData.Series.Add(wb.GetCell(0, 0, 4, "Close"), chart.Type); | |
IChartSeries series = chart.ChartData.Series[0]; | |
series.DataPoints.AddDataPointForStockSeries(wb.GetCell(0, 1, 1, 72)); | |
series.DataPoints.AddDataPointForStockSeries(wb.GetCell(0, 2, 1, 25)); | |
series.DataPoints.AddDataPointForStockSeries(wb.GetCell(0, 3, 1, 38)); | |
series = chart.ChartData.Series[1]; | |
series.DataPoints.AddDataPointForStockSeries(wb.GetCell(0, 1, 2, 172)); | |
series.DataPoints.AddDataPointForStockSeries(wb.GetCell(0, 2, 2, 57)); | |
series.DataPoints.AddDataPointForStockSeries(wb.GetCell(0, 3, 2, 57)); | |
series = chart.ChartData.Series[2]; | |
series.DataPoints.AddDataPointForStockSeries(wb.GetCell(0, 1, 3, 12)); | |
series.DataPoints.AddDataPointForStockSeries(wb.GetCell(0, 2, 3, 12)); | |
series.DataPoints.AddDataPointForStockSeries(wb.GetCell(0, 3, 3, 13)); | |
series = chart.ChartData.Series[3]; | |
series.DataPoints.AddDataPointForStockSeries(wb.GetCell(0, 1, 4, 25)); | |
series.DataPoints.AddDataPointForStockSeries(wb.GetCell(0, 2, 4, 38)); | |
series.DataPoints.AddDataPointForStockSeries(wb.GetCell(0, 3, 4, 50)); | |
chart.ChartData.SeriesGroups[0].UpDownBars.HasUpDownBars = true; | |
chart.ChartData.SeriesGroups[0].HiLowLinesFormat.Line.FillFormat.FillType = FillType.Solid; | |
foreach (IChartSeries ser in chart.ChartData.Series) | |
{ | |
ser.Format.Line.FillFormat.FillType = FillType.NoFill; | |
} | |
pres.Save(dataDir+"output.pptx", SaveFormat.Pptx); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir+"Test.pptx")) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 100, 100, 400, 300); | |
chart.ChartData.SwitchRowColumn(); | |
pres.Save(dataDir, SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation()) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Bubble, 50, 50, 600, 400, true); | |
chart.ChartData.SeriesGroups[0].BubbleSizeRepresentation = BubbleSizeRepresentationType.Width; | |
pres.Save(dataDir+ "Presentation_BubbleSizeRepresentation.pptx", SaveFormat.Pptx); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
// Creating empty presentation | |
using (Presentation pres = new Presentation()) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 100, 100, 400, 300); | |
//Switching rows and columns | |
chart.ChartData.SwitchRowColumn(); | |
// Saving presentation | |
pres.Save(dataDir + "SwitchChartRowColumns_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run() | |
{ | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir+"test.pptx")) | |
{ | |
IChart chart = pres.Slides[0].Shapes.AddChart(Aspose.Slides.Charts.ChartType.Treemap, 50, 50, 500, 400); | |
chart.ChartData.Categories.Clear(); | |
chart.ChartData.Series.Clear(); | |
IChartDataWorkbook wb = chart.ChartData.ChartDataWorkbook; | |
wb.Clear(0); | |
//branch 1 | |
IChartCategory leaf = chart.ChartData.Categories.Add(wb.GetCell(0, "C1", "Leaf1")); | |
leaf.GroupingLevels.SetGroupingItem(1, "Stem1"); | |
leaf.GroupingLevels.SetGroupingItem(2, "Branch1"); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "C2", "Leaf2")); | |
leaf = chart.ChartData.Categories.Add(wb.GetCell(0, "C3", "Leaf3")); | |
leaf.GroupingLevels.SetGroupingItem(1, "Stem2"); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "C4", "Leaf4")); | |
//branch 2 | |
leaf = chart.ChartData.Categories.Add(wb.GetCell(0, "C5", "Leaf5")); | |
leaf.GroupingLevels.SetGroupingItem(1, "Stem3"); | |
leaf.GroupingLevels.SetGroupingItem(2, "Branch2"); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "C6", "Leaf6")); | |
leaf = chart.ChartData.Categories.Add(wb.GetCell(0, "C7", "Leaf7")); | |
leaf.GroupingLevels.SetGroupingItem(1, "Stem4"); | |
chart.ChartData.Categories.Add(wb.GetCell(0, "C8", "Leaf8")); | |
IChartSeries series = chart.ChartData.Series.Add(Aspose.Slides.Charts.ChartType.Treemap); | |
series.Labels.DefaultDataLabelFormat.ShowCategoryName = true; | |
series.DataPoints.AddDataPointForTreemapSeries(wb.GetCell(0, "D1", 4)); | |
series.DataPoints.AddDataPointForTreemapSeries(wb.GetCell(0, "D2", 5)); | |
series.DataPoints.AddDataPointForTreemapSeries(wb.GetCell(0, "D3", 3)); | |
series.DataPoints.AddDataPointForTreemapSeries(wb.GetCell(0, "D4", 6)); | |
series.DataPoints.AddDataPointForTreemapSeries(wb.GetCell(0, "D5", 9)); | |
series.DataPoints.AddDataPointForTreemapSeries(wb.GetCell(0, "D6", 9)); | |
series.DataPoints.AddDataPointForTreemapSeries(wb.GetCell(0, "D7", 4)); | |
series.DataPoints.AddDataPointForTreemapSeries(wb.GetCell(0, "D8", 3)); | |
series.ParentLabelLayout = ParentLabelLayoutType.Overlapping; | |
pres.Save("Treemap.pptx", SaveFormat.Pptx); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
string lbl0 = "Label 0 cell value"; | |
string lbl1 = "Label 1 cell value"; | |
string lbl2 = "Label 2 cell value"; | |
// Instantiate Presentation class that represents a presentation file | |
using (Presentation pres = new Presentation(dataDir + "chart2.pptx")) | |
{ | |
ISlide slide = pres.Slides[0]; | |
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Bubble, 50, 50, 600, 400, true); | |
IChartSeriesCollection series = chart.ChartData.Series; | |
series[0].Labels.DefaultDataLabelFormat.ShowLabelValueFromCell = true; | |
IChartDataWorkbook wb = chart.ChartData.ChartDataWorkbook; | |
series[0].Labels[0].ValueFromCell = wb.GetCell(0, "A10", lbl0); | |
series[0].Labels[1].ValueFromCell = wb.GetCell(0, "A11", lbl1); | |
series[0].Labels[2].ValueFromCell = wb.GetCell(0, "A12", lbl2); | |
pres.Save(dataDir + "resultchart.pptx", Aspose.Slides.Export.SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir+"test.pptx")) | |
{ | |
Chart chart = (Chart)pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 100, 100, 500, 350); | |
chart.ValidateChartLayout(); | |
double x = chart.PlotArea.ActualX; | |
double y = chart.PlotArea.ActualY; | |
double w = chart.PlotArea.ActualWidth; | |
double h = chart.PlotArea.ActualHeight; | |
// Saving presentation | |
pres.Save(dataDir + "Result.pptx", SaveFormat.Pptx); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation presentation = new Presentation(dataDir + "NotesFile.pptx")) | |
{ | |
// Saving the presentation to TIFF notes | |
presentation.Save(dataDir + "Notes_In_Tiff_out.tiff", SaveFormat.Tiff); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run() | |
{ | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
using (Presentation presentation = new Presentation(dataDir + "Individual-Slide.pptx")) | |
{ | |
HtmlOptions htmlOptions = new HtmlOptions(); | |
htmlOptions.HtmlFormatter = HtmlFormatter.CreateCustomFormatter(new CustomFormattingController()); | |
INotesCommentsLayoutingOptions notesOptions = htmlOptions.NotesCommentsLayouting; | |
notesOptions.NotesPosition = NotesPositions.BottomFull; | |
// Saving File | |
for (int i = 0; i < presentation.Slides.Count; i++) | |
presentation.Save(dataDir + "Individual Slide" + (i + 1) + "_out.html", new[] { i + 1 }, SaveFormat.Html, htmlOptions); | |
} | |
} | |
public class CustomFormattingController : IHtmlFormattingController | |
{ | |
void IHtmlFormattingController.WriteDocumentStart(IHtmlGenerator generator, IPresentation presentation) | |
{} | |
void IHtmlFormattingController.WriteDocumentEnd(IHtmlGenerator generator, IPresentation presentation) | |
{} | |
void IHtmlFormattingController.WriteSlideStart(IHtmlGenerator generator, ISlide slide) | |
{ | |
generator.AddHtml(string.Format(SlideHeader, generator.SlideIndex + 1)); | |
} | |
void IHtmlFormattingController.WriteSlideEnd(IHtmlGenerator generator, ISlide slide) | |
{ | |
generator.AddHtml(SlideFooter); | |
} | |
void IHtmlFormattingController.WriteShapeStart(IHtmlGenerator generator, IShape shape) | |
{} | |
void IHtmlFormattingController.WriteShapeEnd(IHtmlGenerator generator, IShape shape) | |
{} | |
private const string SlideHeader = "<div class=\"slide\" name=\"slide\" id=\"slide{0}\">"; | |
private const string SlideFooter = "</div>"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string dataDir = RunExamples.GetDataDir_Conversion(); | |
using (Presentation pres = new Presentation(dataDir+"presentation.pptx")) | |
{ | |
// exclude default presentation fonts | |
string[] fontNameExcludeList = { "Calibri", "Arial" }; | |
Paragraph para = new Paragraph(); | |
ITextFrame txt; | |
EmbedAllFontsHtmlController embedFontsController = new EmbedAllFontsHtmlController(fontNameExcludeList); | |
LinkAllFontsHtmlController linkcont = new LinkAllFontsHtmlController(fontNameExcludeList, @"C:\Windows\Fonts\"); | |
HtmlOptions htmlOptionsEmbed = new HtmlOptions | |
{ | |
// HtmlFormatter = HtmlFormatter.CreateCustomFormatter(embedFontsController) | |
HtmlFormatter = HtmlFormatter.CreateCustomFormatter(linkcont) | |
}; | |
pres.Save("pres.html", SaveFormat.Html, htmlOptionsEmbed); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
using (Presentation pres = new Presentation("input.pptx")) | |
{ | |
// exclude default presentation fonts | |
string[] fontNameExcludeList = { "Calibri", "Arial" }; | |
EmbedAllFontsHtmlController embedFontsController = new EmbedAllFontsHtmlController(fontNameExcludeList); | |
HtmlOptions htmlOptionsEmbed = new HtmlOptions | |
{ | |
HtmlFormatter = HtmlFormatter.CreateCustomFormatter(embedFontsController) | |
}; | |
pres.Save("input-PFDinDisplayPro-Regular-installed.html", SaveFormat.Html, htmlOptionsEmbed); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation pres = new Presentation(dataDir + "Convert_Tiff_Default.pptx")) | |
{ | |
// Saving the presentation to TIFF document | |
pres.Save(dataDir + "Tiff_out.tiff", SaveFormat.Tiff); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation presentation = new Presentation(dataDir + "NotesFile.pptx")) | |
{ | |
PdfOptions pdfOptions = new PdfOptions(); | |
INotesCommentsLayoutingOptions options = pdfOptions.NotesCommentsLayouting; | |
options.NotesPosition = NotesPositions.BottomFull; | |
// Saving the presentation to PDF notes | |
presentation.Save(dataDir + "Pdf_Notes_out.pdf", SaveFormat.Pdf, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation presentation = new Presentation(dataDir + "DemoFile.pptx")) | |
{ | |
// Instantiate the PdfOptions class | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Setting PDF password | |
pdfOptions.Password = "password"; | |
// Save the presentation to password protected PDF | |
presentation.Save(dataDir + "PasswordProtectedPDF_out.pdf", SaveFormat.Pdf, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation presentation = new Presentation(dataDir + "Convert_HTML.pptx")) | |
{ | |
ResponsiveHtmlController controller = new ResponsiveHtmlController(); | |
HtmlOptions htmlOptions = new HtmlOptions { HtmlFormatter = HtmlFormatter.CreateCustomFormatter(controller) }; | |
// Saving the presentation to HTML | |
presentation.Save(dataDir + "ConvertPresentationToResponsiveHTML_out.html", SaveFormat.Html, htmlOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a presentation file | |
Presentation presentation = new Presentation(dataDir + "SelectedSlides.pptx"); | |
Presentation auxPresentation = new Presentation(); | |
ISlide slide = presentation.Slides[0]; | |
auxPresentation.Slides.InsertClone(0, slide); | |
// Setting Slide Type and Size | |
//auxPresentation.SlideSize.SetSize(presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height,SlideSizeScaleType.EnsureFit); | |
auxPresentation.SlideSize.SetSize(612F, 792F,SlideSizeScaleType.EnsureFit); | |
PdfOptions pdfOptions = new PdfOptions(); | |
INotesCommentsLayoutingOptions options = pdfOptions.NotesCommentsLayouting; | |
options.NotesPosition = NotesPositions.BottomFull; | |
auxPresentation.Save(dataDir + "PDFnotes_out.pdf", SaveFormat.Pdf, pdfOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation presentation = new Presentation(dataDir + "SelectedSlides.pptx")) | |
{ | |
// Setting array of slides positions | |
int[] slides = { 1, 3 }; | |
// Save the presentation to PDF | |
presentation.Save(dataDir + "RequiredSelectedSlides_out.pdf", slides, SaveFormat.Pdf); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a presentation file | |
Presentation presentation = new Presentation(dataDir + "ConvertToPDF.pptx"); | |
// Save the presentation to PDF with default options | |
presentation.Save(dataDir + "output_out.pdf", SaveFormat.Pdf); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation presentation = new Presentation(dataDir + "Convert_HTML.pptx")) | |
{ | |
HtmlOptions htmlOpt = new HtmlOptions(); | |
htmlOpt.HtmlFormatter = HtmlFormatter.CreateDocumentFormatter("", false); | |
INotesCommentsLayoutingOptions notesOptions = htmlOpt.NotesCommentsLayouting; | |
notesOptions.NotesPosition = NotesPositions.BottomFull; | |
// Saving the presentation to HTML | |
presentation.Save(dataDir + "ConvertWholePresentationToHTML_out.html", SaveFormat.Html, htmlOpt); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
const string htmlDocumentFileName = "presentationWithVideo.html"; | |
using (Presentation pres = new Presentation("presentationWith.pptx")) | |
{ | |
VideoPlayerHtmlController controller = new VideoPlayerHtmlController( | |
"", htmlDocumentFileName, "http://www.example.com/"); | |
HtmlOptions htmlOptions = new HtmlOptions(controller); | |
SVGOptions svgOptions = new SVGOptions(controller); | |
htmlOptions.HtmlFormatter = HtmlFormatter.CreateCustomFormatter(controller); | |
htmlOptions.SlideImageFormat = SlideImageFormat.Svg(svgOptions); | |
pres.Save(htmlDocumentFileName, SaveFormat.Html, htmlOptions); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a Presentation file | |
using (Presentation pres = new Presentation(dataDir + "Convert_Tiff_Custom.pptx")) | |
{ | |
// Instantiate the TiffOptions class | |
TiffOptions opts = new TiffOptions(); | |
// Setting compression type | |
opts.CompressionType = TiffCompressionTypes.Default; | |
INotesCommentsLayoutingOptions notesOptions = opts.NotesCommentsLayouting; | |
notesOptions.NotesPosition = NotesPositions.BottomFull; | |
// Compression Types | |
// Default - Specifies the default compression scheme (LZW). | |
// None - Specifies no compression. | |
// CCITT3 | |
// CCITT4 | |
// LZW | |
// RLE | |
// Depth depends on the compression type and cannot be set manually. | |
// Resolution unit is always equal to “2” (dots per inch) | |
// Setting image DPI | |
opts.DpiX = 200; | |
opts.DpiY = 100; | |
// Set Image Size | |
opts.ImageSize = new Size(1728, 1078); | |
// Save the presentation to TIFF with specified image size | |
pres.Save(dataDir + "TiffWithCustomSize_out.tiff", SaveFormat.Tiff, opts); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation pres = new Presentation(dataDir + "ConvertWithNoteToTiff.pptx")) | |
{ | |
TiffOptions opts = new TiffOptions(); | |
INotesCommentsLayoutingOptions notesOptions = opts.NotesCommentsLayouting; | |
notesOptions.NotesPosition = NotesPositions.BottomFull; | |
// Saving the presentation to TIFF notes | |
pres.Save(dataDir + "TestNotes_out.tiff", SaveFormat.Tiff, opts); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation pres = new Presentation(dataDir + "Convert_XPS.pptx")) | |
{ | |
// Saving the presentation to XPS document | |
pres.Save(dataDir + "XPS_Output_Without_XPSOption_out.xps", SaveFormat.Xps); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation pres = new Presentation(dataDir + "Convert_XPS_Options.pptx")) | |
{ | |
// Instantiate the TiffOptions class | |
XpsOptions opts = new XpsOptions(); | |
// Save MetaFiles as PNG | |
opts.SaveMetafilesAsPng = true; | |
// Save the presentation to XPS document | |
pres.Save(dataDir + "XPS_With_Options_out.xps", SaveFormat.Xps, opts); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation presentation = new Presentation(dataDir + "HelloWorld.pptx")) | |
{ | |
SwfOptions swfOptions = new SwfOptions(); | |
swfOptions.ViewerIncluded = false; | |
INotesCommentsLayoutingOptions notesOptions = swfOptions.NotesCommentsLayouting; | |
notesOptions.NotesPosition = NotesPositions.BottomFull; | |
// Saving presentation and notes pages | |
presentation.Save(dataDir + "SaveAsSwf_out.swf", SaveFormat.Swf, swfOptions); | |
swfOptions.ViewerIncluded = true; | |
presentation.Save(dataDir + "SaveNotes_out.swf", SaveFormat.Swf, swfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
using (Presentation presentation = new Presentation(dataDir + "ConvertToPDF.pptx")) | |
{ | |
ISaveOptions saveOptions = new PdfOptions(); | |
saveOptions.ProgressCallback = new ExportProgressHandler(); | |
presentation.Save(dataDir + "ConvertToPDF.pdf", SaveFormat.Pdf, saveOptions); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExportProgressHandler : IProgressCallback | |
{ | |
public void Reporting(double progressValue) | |
{ | |
// Use progress percentage value here | |
int progress = Convert.ToInt32(progressValue); | |
Console.WriteLine(progress + "% file converted"); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide slide = presentation.Slides[0]; | |
// Add an autoshape of type line | |
slide.Shapes.AddAutoShape(ShapeType.Line, 50, 150, 300, 0); | |
presentation.Save(dataDir + "NewPresentation_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide slide = presentation.Slides[0]; | |
// Add an autoshape of type line | |
slide.Shapes.AddAutoShape(ShapeType.Line, 50, 150, 300, 0); | |
presentation.Save(dataDir + "NewPresentation_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomHeaderAndFontsController : EmbedAllFontsHtmlController | |
{ | |
// Custom header template | |
const string Header = @"<!DOCTYPE html>\n" + | |
"<html>\n" + | |
"<head>\n" + | |
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n" + | |
"<meta http-equiv=\"X-UA-Compatible\" content=\"IE=9\">\n" + | |
"<link rel=\"stylesheet\" type=\"text/css\" href=\"{0}\">\n" + | |
"</head>"; | |
private readonly string m_cssFileName; | |
public CustomHeaderAndFontsController(string cssFileName) | |
{ | |
m_cssFileName = cssFileName; | |
} | |
public override void WriteDocumentStart(IHtmlGenerator generator, IPresentation presentation) | |
{ | |
generator.AddHtml(string.Format(Header, m_cssFileName)); | |
WriteAllFonts(generator, presentation); | |
} | |
public override void WriteAllFonts(IHtmlGenerator generator, IPresentation presentation) | |
{ | |
generator.AddHtml("<!-- Embedded fonts -->"); | |
base.WriteAllFonts(generator, presentation); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation pres = new Presentation(dataDir + "ConvertToPDF.pptx")) | |
{ | |
// Instantiate the PdfOptions class | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set Jpeg Quality | |
pdfOptions.JpegQuality = 90; | |
// Define behavior for metafiles | |
pdfOptions.SaveMetafilesAsPng = true; | |
// Set Text Compression level | |
pdfOptions.TextCompression = PdfTextCompression.Flate; | |
// Define the PDF standard | |
pdfOptions.Compliance = PdfCompliance.Pdf15; | |
INotesCommentsLayoutingOptions options = pdfOptions.NotesCommentsLayouting; | |
options.NotesPosition = NotesPositions.BottomFull; | |
// Save the presentation to PDF with specified options | |
pres.Save(dataDir + "Custom_Option_Pdf_Conversion_out.pdf", SaveFormat.Pdf, pdfOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomSvgShapeFormattingController : ISvgShapeFormattingController | |
{ | |
private int m_shapeIndex; | |
public CustomSvgShapeFormattingController(int shapeStartIndex = 0) | |
{ | |
m_shapeIndex = shapeStartIndex; | |
} | |
public void FormatShape(ISvgShape svgShape, IShape shape) | |
{ | |
svgShape.Id = string.Format("shape-{0}", m_shapeIndex++); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Loading a presentation | |
using (Presentation pres = new Presentation(dataDir + "Media File.pptx")) | |
{ | |
string path = dataDir; | |
const string fileName = "ExportMediaFiles_out.html"; | |
const string baseUri = "http://www.example.com/"; | |
VideoPlayerHtmlController controller = new VideoPlayerHtmlController(path, fileName, baseUri); | |
// Setting HTML options | |
HtmlOptions htmlOptions = new HtmlOptions(controller); | |
SVGOptions svgOptions = new SVGOptions(controller); | |
htmlOptions.HtmlFormatter = HtmlFormatter.CreateCustomFormatter(controller); | |
htmlOptions.SlideImageFormat = SlideImageFormat.Svg(svgOptions); | |
// Saving the file | |
pres.Save(Path.Combine(path, fileName), SaveFormat.Html, htmlOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run() | |
{ | |
string outSvgFileName = "SingleShape.svg"; | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
using (Presentation pres = new Presentation(dataDir+ "TestExportShapeToSvg.pptx")) | |
{ | |
using (Stream stream = new FileStream(outSvgFileName, FileMode.Create, FileAccess.Write)) | |
{ | |
pres.Slides[0].Shapes[0].WriteAsSvg(stream); | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var pres = new Presentation(@"C:\data\input.pptx")) { | |
var htmlOptions = new HtmlOptions(new LinkController(@"C:\data\out\")); | |
htmlOptions.SlideImageFormat = SlideImageFormat.Svg(new SVGOptions()); | |
// This line is needed to remove the slide title display in HTML. | |
// Comment it out if your prefer slide title displayed. | |
htmlOptions.HtmlFormatter = HtmlFormatter.CreateDocumentFormatter(String.Empty, false); | |
Console.WriteLine("Starting export"); | |
pres.Save(@"C:\data\out\output.html", SaveFormat.Html, htmlOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LinkController : ILinkEmbedController | |
{ | |
static LinkController() | |
{ | |
s_templates.Add("image/jpeg", "image-{0}.jpg"); | |
s_templates.Add("image/png", "image-{0}.png"); | |
} | |
/// <summary> | |
/// Default parameterless constructor | |
/// </summary> | |
public LinkController() | |
{ | |
m_externalImages = new Dictionary<int, string>(); | |
} | |
/// <summary> | |
/// Creates a class instance and sets the path where generated resource files will be saved to. | |
/// </summary> | |
/// <param name="savePath">Path to the location where generated resource files will be stored.</param> | |
public LinkController(string savePath) | |
: this() | |
{ | |
SavePath = savePath; | |
} | |
/// <summary> | |
/// A ILinkEmbedController member | |
/// </summary> | |
public LinkEmbedDecision GetObjectStoringLocation(int id, byte[] entityData, string semanticName, | |
string contentType, | |
string recomendedExtension) | |
{ | |
// Here we make the decision about storing images externally. | |
// The id is unique identifier of each object during the whole export operation. | |
string template; | |
// The s_templates dictionary contains content types we are going to store externally and the corresponding file name template. | |
if (s_templates.TryGetValue(contentType, out template)) | |
{ | |
// Storing this resource to the export list | |
m_externalImages.Add(id, template); | |
return LinkEmbedDecision.Link; | |
} | |
// All other resources, if any, will be embedded | |
return LinkEmbedDecision.Embed; | |
} | |
/// <summary> | |
/// A ILinkEmbedController member | |
/// </summary> | |
public string GetUrl(int id, int referrer) | |
{ | |
// Here we construct the resource reference string to form the tag: <img src="%result%"> | |
// We need to check the dictionary to filter out unnecessary resources. | |
// Along with checking we extract the corresponding file name template. | |
string template; | |
if (m_externalImages.TryGetValue(id, out template)) | |
{ | |
// Assuming we are going to store resource files just near the HTML file. | |
// The image tag will look like <img src="image-1.png"> with the appropriate resource Id and extension. | |
var fileUrl = String.Format(template, id); | |
return fileUrl; | |
} | |
// null must be returned for the resources remaining embedded | |
return null; | |
} | |
/// <summary> | |
/// A ILinkEmbedController member | |
/// </summary> | |
public void SaveExternal(int id, byte[] entityData) | |
{ | |
// Here we actually save the resource files to disk. | |
// Once again, checking the dictionary. If the id is not found here it is a sign of an error in GetObjectStoringLocation or GetUrl methods. | |
if (m_externalImages.ContainsKey(id)) | |
{ | |
// Now we use the file name stored in the dictionary and combine it with a path as required. | |
// Constructing the file name using the stored template and the Id. | |
var fileName = String.Format(m_externalImages[id], id); | |
// Combining with the location directory | |
var filePath = Path.Combine(SavePath ?? String.Empty, fileName); | |
using (var fs = new FileStream(filePath, FileMode.Create)) | |
fs.Write(entityData, 0, entityData.Length); | |
} | |
else | |
throw new Exception("Something is wrong"); | |
} | |
/// <summary> | |
/// Gets or sets the path where generated resource files will be saved to. | |
/// </summary> | |
public string SavePath { get; set; } | |
/// <summary> | |
/// A dictionary to store associations between resource ids and corresponding file names. | |
/// </summary> | |
private readonly Dictionary<int, string> m_externalImages; | |
/// <summary> | |
/// A dictionary to store associations between content types of resources we are going to store externally | |
/// and corresponding file name templates. | |
/// </summary> | |
private static readonly Dictionary<string, string> s_templates = new Dictionary<string, string>(); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
Presentation presentation = new Presentation(dataDir+"SomePresentation.pptx"); | |
HtmlOptions saveOptions = new HtmlOptions(); | |
saveOptions.SvgResponsiveLayout = true; | |
presentation.Save(dataDir+"SomePresentation-out.html", SaveFormat.Html, saveOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string dataDir = RunExamples.GetDataDir_Conversion(); | |
using (Presentation pres = new Presentation(dataDir+ "presentation.pptx")) | |
{ | |
using (FileStream stream = new FileStream(dataDir + "pptxFileName.svg", FileMode.OpenOrCreate)) | |
{ | |
SVGOptions svgOptions = new SVGOptions | |
{ | |
ShapeFormattingController = new CustomSvgShapeFormattingController() | |
}; | |
pres.Slides[0].WriteAsSvg(stream, svgOptions); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LinkAllFontsHtmlController : EmbedAllFontsHtmlController | |
{ | |
private readonly string m_basePath; | |
public LinkAllFontsHtmlController(string[] fontNameExcludeList, string basePath) | |
: base(fontNameExcludeList) | |
{ | |
m_basePath = basePath; | |
} | |
public override void WriteFont( | |
IHtmlGenerator generator, | |
IFontData originalFont, | |
IFontData substitutedFont, | |
string fontStyle, | |
string fontWeight, | |
byte[] fontData) | |
{ | |
string fontName = substitutedFont == null ? originalFont.FontName : substitutedFont.FontName; | |
string path = string.Format("{0}.woff", fontName); // some path sanitaze may be needed | |
File.WriteAllBytes(Path.Combine(m_basePath, path), fontData); | |
generator.AddHtml("<style>"); | |
generator.AddHtml("@font-face { "); | |
generator.AddHtml(string.Format("font-family: '{0}'; ", fontName)); | |
generator.AddHtml(string.Format("src: url('{0}')", path)); | |
generator.AddHtml(" }"); | |
generator.AddHtml("</style>"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
string srcFileName = dataDir + "AccessOpenDoc.odp"; | |
string destFileName = dataDir + "AccessOpenDoc.pptx"; | |
//Instantiate a Presentation object that represents a presentation file | |
using (Presentation pres = new Presentation(srcFileName)) | |
{ | |
//Saving the PPTX presentation to PPTX format | |
pres.Save(destFileName, SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a PPTX file | |
Presentation pres = new Presentation(dataDir + "PPTtoPPTX.ppt"); | |
// Saving the PPTX presentation to PPTX format | |
pres.Save(dataDir + "PPTtoPPTX_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a Presentation file | |
using (Presentation presentation = new Presentation(dataDir + "DemoFile.pptx")) | |
{ | |
TiffOptions options = new TiffOptions(); | |
options.PixelFormat = ImagePixelFormat.Format8bppIndexed; | |
INotesCommentsLayoutingOptions notesOptions = options.NotesCommentsLayouting; | |
notesOptions.NotesPosition = NotesPositions.BottomFull; | |
/* | |
ImagePixelFormat contains the following values (as could be seen from documentation): | |
Format1bppIndexed; // 1 bits per pixel, indexed. | |
Format4bppIndexed; // 4 bits per pixel, indexed. | |
Format8bppIndexed; // 8 bits per pixel, indexed. | |
Format24bppRgb; // 24 bits per pixel, RGB. | |
Format32bppArgb; // 32 bits per pixel, ARGB. | |
*/ | |
// Save the presentation to TIFF with specified image size | |
presentation.Save(dataDir + "Tiff_With_Custom_Image_Pixel_Format_out.tiff", SaveFormat.Tiff, options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation presentation = new Presentation(dataDir + "DemoFile.pptx")) | |
{ | |
// Saving the presentation to TIFF document | |
presentation.Save(dataDir + "Tiffoutput_out.tiff", SaveFormat.Tiff); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
using (Presentation pres = new Presentation(dataDir + "Presentation.pptx")) | |
{ | |
HtmlOptions opt = new HtmlOptions(); | |
INotesCommentsLayoutingOptions options = opt.NotesCommentsLayouting; | |
options.NotesPosition = NotesPositions.BottomFull; | |
// Saving notes pages | |
pres.Save(dataDir + "Output.html", SaveFormat.Html, opt); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
using (Presentation pres = new Presentation("pres.pptx")) | |
{ | |
CustomHeaderAndFontsController htmlController = new CustomHeaderAndFontsController("styles.css"); | |
HtmlOptions options = new HtmlOptions | |
{ | |
HtmlFormatter = HtmlFormatter.CreateCustomFormatter(htmlController), | |
}; | |
pres.Save("pres.html", SaveFormat.Html, options); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run() { | |
String path = @"D:\Aspose Data\"; | |
//Accessing the presentation | |
Presentation pres = new Presentation(path + "ExtractImages.pptx"); | |
Aspose.Slides.IPPImage img = null; | |
Aspose.Slides.IPPImage Backimg = null; | |
int slideIndex = 0; | |
String ImageType = ""; | |
bool ifImageFound = false; | |
for (int i = 0; i < pres.Slides.Count; i++) | |
{ | |
slideIndex++; | |
//Accessing the first slide | |
ISlide sl = pres.Slides[i]; | |
System.Drawing.Imaging.ImageFormat Format = System.Drawing.Imaging.ImageFormat.Jpeg; | |
//Accessing the first slide Slide sl = pres.getSlideByPosition(i); | |
if (sl.Background.FillFormat.FillType == FillType.Picture) | |
{ | |
//Getting the back picture | |
Backimg = sl.Background.FillFormat.PictureFillFormat.Picture.Image; | |
//Setting the desired picture format | |
ImageType = Backimg.ContentType; | |
ImageType = ImageType.Remove(0, ImageType.IndexOf("/") + 1); | |
Format = GetImageFormat(ImageType); | |
String ImagePath = path + "BackImage_"; | |
Backimg.SystemImage.Save(ImagePath + "Slide_" + slideIndex.ToString() + "." + ImageType, Format); | |
} | |
else | |
{ | |
if (sl.LayoutSlide.Background.FillFormat.FillType == FillType.Picture) | |
{ | |
//Getting the back picture | |
Backimg = sl.LayoutSlide.Background.FillFormat.PictureFillFormat.Picture.Image; | |
//Setting the desired picture format | |
ImageType = Backimg.ContentType; | |
ImageType = ImageType.Remove(0, ImageType.IndexOf("/") + 1); | |
Format = GetImageFormat(ImageType); | |
String ImagePath = path + "BackImage_Slide_" + i; | |
Backimg.SystemImage.Save(ImagePath + "LayoutSlide_" + slideIndex.ToString() + "." + ImageType, Format); | |
} | |
} | |
for (int j = 0; j < sl.Shapes.Count; j++) | |
{ | |
// Accessing the shape with picture | |
IShape sh = sl.Shapes[j]; | |
if (sh is AutoShape) | |
{ | |
AutoShape ashp = (AutoShape)sh; | |
if (ashp.FillFormat.FillType == FillType.Picture) | |
{ | |
img = ashp.FillFormat.PictureFillFormat.Picture.Image; | |
ImageType = img.ContentType; | |
ImageType = ImageType.Remove(0, ImageType.IndexOf("/") + 1); | |
ifImageFound = true; | |
} | |
} | |
else if (sh is PictureFrame) | |
{ | |
IPictureFrame pf = (IPictureFrame)sh; | |
if (pf.FillFormat.FillType == FillType.Picture) | |
{ | |
img = pf.PictureFormat.Picture.Image; | |
ImageType = img.ContentType; | |
ImageType = ImageType.Remove(0, ImageType.IndexOf("/") + 1); | |
ifImageFound = true; | |
} | |
} | |
//Setting the desired picture format | |
if (ifImageFound) | |
{ | |
Format = GetImageFormat(ImageType); | |
String ImagePath = path + "Slides\\Image_"; | |
img.SystemImage.Save(ImagePath + "Slide_" + slideIndex.ToString() + "_Shape_" + j.ToString() + "." + ImageType, Format); | |
} | |
ifImageFound = false; | |
} | |
} | |
} | |
public static System.Drawing.Imaging.ImageFormat GetImageFormat(String ImageType) | |
{ | |
System.Drawing.Imaging.ImageFormat Format = System.Drawing.Imaging.ImageFormat.Jpeg; | |
switch (ImageType) | |
{ | |
case "jpeg": | |
Format = System.Drawing.Imaging.ImageFormat.Jpeg; | |
break; | |
case "emf": | |
Format = System.Drawing.Imaging.ImageFormat.Emf; | |
break; | |
case "bmp": | |
Format = System.Drawing.Imaging.ImageFormat.Bmp; | |
break; | |
case "png": | |
Format = System.Drawing.Imaging.ImageFormat.Png; | |
break; | |
case "wmf": | |
Format = System.Drawing.Imaging.ImageFormat.Wmf; | |
break; | |
case "gif": | |
Format = System.Drawing.Imaging.ImageFormat.Gif; | |
break; | |
} | |
return Format; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Instantiate the presentation | |
Presentation presentation = new Presentation("presentation.pptx"); | |
//the first way | |
byte[] data = File.ReadAllBytes("image0.jpeg"); | |
IPPImage oldImage = presentation.Images[0]; | |
oldImage.ReplaceImage(data); | |
//the second way | |
Image newImage = Image.FromFile("image1.png"); | |
oldImage = presentation.Images[1]; | |
oldImage.ReplaceImage(newImage); | |
//the third way | |
oldImage = presentation.Images[2]; | |
oldImage.ReplaceImage(presentation.Images[3]); | |
//Save the presentation | |
presentation.Save("c:\\Presentations\\TestSmart.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationOpening(); | |
IPresentationInfo info = PresentationFactory.Instance.GetPresentationInfo(dataDir + "HelloWorld.pptx"); | |
switch (info.LoadFormat) | |
{ | |
case LoadFormat.Pptx: | |
{ | |
break; | |
} | |
case LoadFormat.Unknown: | |
{ | |
break; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationOpening(); | |
using (Presentation presentation = new Presentation(dataDir + "Shapes.pptx")) | |
{ | |
IAutoShape shape = (IAutoShape)presentation.Slides[0].Shapes[0]; | |
var textFrame = (ITextFrame)shape.TextFrame; | |
foreach (var paragraph in textFrame.Paragraphs) | |
{ | |
foreach (Portion portion in paragraph.Portions) | |
{ | |
PointF point = portion.GetCoordinates(); | |
Console.Write(Environment.NewLine + "Corrdinates X =" + point.X + " Corrdinates Y =" + point.Y); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationOpening(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation presentation = new Presentation(dataDir + "Shapes.pptx")) | |
{ | |
IAutoShape shape = (IAutoShape)presentation.Slides[0].Shapes[0]; | |
var textFrame = (ITextFrame)shape.TextFrame; | |
RectangleF rect = ((Paragraph)textFrame.Paragraphs[0]).GetRect(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationOpening(); | |
bool isOldFormat = PresentationFactory.Instance.GetPresentationInfo(dataDir+"presentation.ppt").LoadFormat == LoadFormat.Ppt95; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ImageLoadingHandler : IResourceLoadingCallback | |
{ | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationOpening(); | |
public ResourceLoadingAction ResourceLoading(IResourceLoadingArgs args) | |
{ | |
if (args.OriginalUri.EndsWith(".jpg")) | |
{ | |
try // load substitute image | |
{ | |
byte[] imageBytes = File.ReadAllBytes(Path.Combine(dataDir, "aspose-logo.jpg")); | |
args.SetData(imageBytes); | |
return ResourceLoadingAction.UserProvided; | |
} | |
catch (Exception) | |
{ | |
return ResourceLoadingAction.Skip; | |
} | |
} | |
else if (args.OriginalUri.EndsWith(".png")) | |
{ | |
// set substitute url | |
args.Uri = "http://www.google.com/images/logos/ps_logo2.png"; | |
return ResourceLoadingAction.Default; | |
} | |
// skip all other images | |
return ResourceLoadingAction.Skip; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationOpening(); | |
LoadOptions opts = new LoadOptions(); | |
opts.ResourceLoadingCallback = new ImageLoadingHandler(); | |
Presentation presentation = new Presentation(dataDir + "presentation.pptx", opts); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationOpening(); | |
// creating instance of load options to set the presentation access password | |
LoadOptions loadOptions = new LoadOptions(); | |
// Setting the access password | |
loadOptions.Password = "pass"; | |
// Opening the presentation file by passing the file path and load options to the constructor of Presentation class | |
Presentation pres = new Presentation(dataDir + "OpenPasswordPresentation.pptx", loadOptions); | |
// Printing the total number of slides present in the presentation | |
System.Console.WriteLine(pres.Slides.Count.ToString()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationOpening(); | |
// Opening the presentation file by passing the file path to the constructor of Presentation class | |
Presentation pres = new Presentation(dataDir + "OpenPresentation.pptx"); | |
// Printing the total number of slides present in the presentation | |
System.Console.WriteLine(pres.Slides.Count.ToString()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationOpening(); | |
const string pathToVeryLargePresentationFile = "veryLargePresentation.pptx"; | |
LoadOptions loadOptions = new LoadOptions | |
{ | |
BlobManagementOptions = | |
{ | |
// let's choose the KeepLocked behavior - the "veryLargePresentation.pptx" will be locked for | |
// the Presentation's instance lifetime, but we don't need to load it into memory or copy into | |
// thetemporary file | |
PresentationLockingBehavior = PresentationLockingBehavior.KeepLocked, | |
} | |
}; | |
using (Presentation pres = new Presentation(pathToVeryLargePresentationFile, loadOptions)) | |
{ | |
// the huge presentation is loaded and ready to use, but the memory consumption is still low. | |
// make any changes to the presentation. | |
pres.Slides[0].Name = "Very large presentation"; | |
// presentation will be saved to the other file, the memory consumptions still low during saving. | |
pres.Save("veryLargePresentation-copy.pptx", SaveFormat.Pptx); | |
// can't do that! IO exception will be thrown, because the file is locked while pres objects will | |
// not be disposed | |
File.Delete(pathToVeryLargePresentationFile); | |
} | |
// it's ok to do it here, the source file is not locked by pres object | |
File.Delete(pathToVeryLargePresentationFile); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationOpening(); | |
LoadFormat format = PresentationFactory.Instance.GetPresentationInfo(dataDir + "HelloWorld.pptx").LoadFormat; | |
// It will return "LoadFormat.Unknown" if the file is other than presentation formats |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationProperties(); | |
// Instantiate the Presentation class that represents the presentation | |
Presentation pres = new Presentation(dataDir + "AccessBuiltin Properties.pptx"); | |
// Create a reference to IDocumentProperties object associated with Presentation | |
IDocumentProperties documentProperties = pres.DocumentProperties; | |
// Display the builtin properties | |
System.Console.WriteLine("Category : " + documentProperties.Category); | |
System.Console.WriteLine("Current Status : " + documentProperties.ContentStatus); | |
System.Console.WriteLine("Creation Date : " + documentProperties.CreatedTime); | |
System.Console.WriteLine("Author : " + documentProperties.Author); | |
System.Console.WriteLine("Description : " + documentProperties.Comments); | |
System.Console.WriteLine("KeyWords : " + documentProperties.Keywords); | |
System.Console.WriteLine("Last Modified By : " + documentProperties.LastSavedBy); | |
System.Console.WriteLine("Supervisor : " + documentProperties.Manager); | |
System.Console.WriteLine("Modified Date : " + documentProperties.LastSavedTime); | |
System.Console.WriteLine("Presentation Format : " + documentProperties.PresentationFormat); | |
System.Console.WriteLine("Last Print Date : " + documentProperties.LastPrinted); | |
System.Console.WriteLine("Is Shared between producers : " + documentProperties.SharedDoc); | |
System.Console.WriteLine("Subject : " + documentProperties.Subject); | |
System.Console.WriteLine("Title : " + documentProperties.Title); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationProperties(); | |
using (Presentation pres = new Presentation(dataDir + "pres.pptx")) | |
{ | |
foreach (ILayoutSlide layoutSlide in pres.LayoutSlides) | |
{ | |
IFillFormat[] fillFormats = layoutSlide.Shapes.Select(shape => shape.FillFormat).ToArray(); | |
ILineFormat[] lineFormats = layoutSlide.Shapes.Select(shape => shape.LineFormat).ToArray(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationProperties(); | |
// Instanciate the Presentation class that represents the PPTX | |
Presentation presentation = new Presentation(dataDir + "AccessModifyingProperties.pptx"); | |
// Create a reference to DocumentProperties object associated with Prsentation | |
IDocumentProperties documentProperties = presentation.DocumentProperties; | |
// Access and modify custom properties | |
for (int i = 0; i < documentProperties.CountOfCustomProperties; i++) | |
{ | |
// Display names and values of custom properties | |
System.Console.WriteLine("Custom Property Name : " + documentProperties.GetCustomPropertyName(i)); | |
System.Console.WriteLine("Custom Property Value : " + documentProperties[documentProperties.GetCustomPropertyName(i)]); | |
// Modify values of custom properties | |
documentProperties[documentProperties.GetCustomPropertyName(i)] = "New Value " + (i + 1); | |
} | |
// Save your presentation to a file | |
presentation.Save(dataDir + "CustomDemoModified_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationProperties(); | |
// Open the ODP file | |
Presentation pres = new Presentation(dataDir + "AccessOpenDoc.odp"); | |
// Saving the ODP presentation to PPTX format | |
pres.Save(dataDir + "AccessOpenDoc_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationProperties(); | |
// Accessing the Document Properties of a Password Protected Presentation without Password | |
// creating instance of load options to set the presentation access password | |
LoadOptions loadOptions = new LoadOptions(); | |
// Setting the access password to null | |
loadOptions.Password = null; | |
// Setting the access to document properties | |
loadOptions.OnlyLoadDocumentProperties = true; | |
// Opening the presentation file by passing the file path and load options to the constructor of Presentation class | |
Presentation pres = new Presentation(dataDir + "AccessProperties.pptx", loadOptions); | |
// Getting Document Properties | |
IDocumentProperties docProps = pres.DocumentProperties; | |
System.Console.WriteLine("Name of Application : " + docProps.NameOfApplication); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
const string pathToVeryLargeVideo = "veryLargeVideo.avi"; | |
// create a new presentation which will contain this video | |
using (Presentation pres = new Presentation()) | |
{ | |
using (FileStream fileStream = new FileStream(pathToVeryLargeVideo, FileMode.Open)) | |
{ | |
// let's add the video to the presentation - we choose KeepLocked behavior, because we not | |
// have an intent to access the "veryLargeVideo.avi" file. | |
IVideo video = pres.Videos.AddVideo(fileStream, LoadingStreamBehavior.KeepLocked); | |
pres.Slides[0].Shapes.AddVideoFrame(0, 0, 480, 270, video); | |
// save the presentation. Despite that the output presentation will be very large, the memory | |
// consumption will be low the whole lifetime of the pres object | |
pres.Save("presentationWithLargeVideo.pptx", SaveFormat.Pptx); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationProperties(); | |
// Instantiate the Presentation class | |
Presentation presentation = new Presentation(); | |
// Getting Document Properties | |
IDocumentProperties documentProperties = presentation.DocumentProperties; | |
// Adding Custom properties | |
documentProperties["New Custom"] = 12; | |
documentProperties["My Name"] = "Mudassir"; | |
documentProperties["Custom"] = 124; | |
// Getting property name at particular index | |
String getPropertyName = documentProperties.GetCustomPropertyName(2); | |
// Removing selected property | |
documentProperties.RemoveCustomProperty(getPropertyName); | |
// Saving presentation | |
presentation.Save(dataDir + "CustomDocumentProperties_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationProperties(); | |
Presentation p = new Presentation(); | |
ISlide s = p.Slides[0]; | |
// byte[] buffer=new byte(); | |
String imagePath=@"C:\Aspose Data\emf files\"; | |
byte[] data = GetCompressedData(imagePath + "2.emz"); | |
if (s != null) | |
{ | |
if (s.Shapes != null) | |
{ | |
IPPImage imgx = p.Images.AddImage(data); | |
var m = s.Shapes.AddPictureFrame(ShapeType.Rectangle, 0, 0, p.SlideSize.Size.Width, p.SlideSize.Size.Height , imgx); | |
p.Save("C:\\Asopse Data\\Saved.pptx", SaveFormat.Pptx); | |
} | |
} | |
} | |
//private byte[] GetCompressedData(string fileNameZip, byte[] buffer) | |
private static byte[] GetCompressedData(string fileNameZip) | |
{ | |
byte[] bufferZip = null; | |
/* byte[] buffer = null; | |
FileStream f1 = new FileStream(fileName, FileMode.Open); | |
byte[] buffer=f1. | |
using (FileStream f = new FileStream(fileNameZip, FileMode.Create)) | |
{ | |
buffer = new byte[f.Length]; | |
using (var gz = new GZipStream(f, CompressionMode.Compress, false)) | |
{ | |
gz.Write(buffer, 0, buffer.Length); | |
} | |
} | |
*/ | |
using (FileStream f = new FileStream(fileNameZip, FileMode.Open)) | |
{ | |
bufferZip = new byte[f.Length]; | |
f.Read(bufferZip, 0, (int)f.Length); | |
} | |
return bufferZip; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationProperties(); | |
IPresentationInfo info = | |
PresentationFactory.Instance.GetPresentationInfo(Path.Combine(RootFolder, "props.pptx")); | |
IDocumentProperties props = info.ReadDocumentProperties(); | |
string app = props.NameOfApplication; | |
string ver = props.AppVersion; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Conversion(); | |
const string hugePresentationWithAudiosAndVideosFile = @"c:\bin\aspose\Tasks\020, 38595\orig\Large Video File Test1.pptx"; | |
LoadOptions loadOptions = new LoadOptions | |
{ | |
BlobManagementOptions = | |
{ | |
// lock the source file and don't load it into memory | |
PresentationLockingBehavior = PresentationLockingBehavior.KeepLocked, | |
} | |
}; | |
// create the Presentation's instance, lock the "hugePresentationWithAudiosAndVideos.pptx" file. | |
using (Presentation pres = new Presentation(hugePresentationWithAudiosAndVideosFile, loadOptions)) | |
{ | |
// let's save each video to a file. to prevent memory usage we need a buffer which will be used | |
// to exchange tha data from the presentation's video stream to a stream for newly created video file. | |
byte[] buffer = new byte[8 * 1024]; | |
// iterate through the videos | |
for (var index = 0; index < pres.Videos.Count; index++) | |
{ | |
IVideo video = pres.Videos[index]; | |
// open the presentation video stream. Please note that we intentionally avoid accessing properties | |
// like video.BinaryData - this property returns a byte array containing full video, and that means | |
// this bytes will be loaded into memory. We will use video.GetStream, which will return Stream and | |
// that allows us to not load the whole video into memory. | |
using (Stream presVideoStream = video.GetStream()) | |
{ | |
using (FileStream outputFileStream = File.OpenWrite($"video{index}.avi")) | |
{ | |
int bytesRead; | |
while ((bytesRead = presVideoStream.Read(buffer, 0, buffer.Length)) > 0) | |
{ | |
outputFileStream.Write(buffer, 0, bytesRead); | |
} | |
} | |
} | |
// memory consumption will stay low no matter what size the videos or presentation is. | |
} | |
// do the same for audios if needed. | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationProperties(); | |
using (Presentation pres = new Presentation(dataDir+"withFlash.pptm")) | |
{ | |
IControlCollection controls = pres.Slides[0].Controls; | |
Control flashControl = null; | |
foreach (IControl control in controls) | |
{ | |
if (control.Name == "ShockwaveFlash1") | |
{ | |
flashControl = (Control)control; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationProperties(); | |
using (var p = new Presentation()) | |
{ | |
var svgContent = File.ReadAllText(svgPath); | |
var emfImage = p.Images.AddFromSvg(svgContent); | |
p.Slides[0].Shapes.AddPictureFrame(ShapeType.Rectangle, 0, 0, emfImage.Width, emfImage.Height, emfImage); | |
p.Save(outPptxPath, SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationProperties(); | |
// Instantiate the Presentation class that represents the Presentation | |
Presentation presentation = new Presentation(dataDir + "ModifyBuiltinProperties.pptx"); | |
// Create a reference to IDocumentProperties object associated with Presentation | |
IDocumentProperties documentProperties = presentation.DocumentProperties; | |
// Set the builtin properties | |
documentProperties.Author = "Aspose.Slides for .NET"; | |
documentProperties.Title = "Modifying Presentation Properties"; | |
documentProperties.Subject = "Aspose Subject"; | |
documentProperties.Comments = "Aspose Description"; | |
documentProperties.Manager = "Aspose Manager"; | |
// Save your presentation to a file | |
presentation.Save(dataDir + "DocumentProperties_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run() | |
{ | |
string dataDir = RunExamples.GetDataDir_PresentationProperties(); | |
Action<IInterruptionToken> action = (IInterruptionToken token) => | |
{ | |
LoadOptions options = new LoadOptions { InterruptionToken = token }; | |
using (Presentation presentation = new Presentation(dataDir + "pres.pptx", options)) | |
{ | |
presentation.Save(dataDir + "pres.ppt", SaveFormat.Ppt); | |
} | |
}; | |
InterruptionTokenSource tokenSource = new InterruptionTokenSource(); | |
Run(action, tokenSource.Token); // run action in a separate thread | |
Thread.Sleep(10000); // timeout | |
tokenSource.Interrupt(); // stop conversion | |
} | |
private static void Run(Action<IInterruptionToken> action, IInterruptionToken token) | |
{ | |
Task.Run(() => { action(token); }); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationProperties(); | |
// read the info of presentation | |
IPresentationInfo info = PresentationFactory.Instance.GetPresentationInfo(dataDir + "ModifyBuiltinProperties1.pptx"); | |
// obtain the current properties | |
IDocumentProperties props = info.ReadDocumentProperties(); | |
// set the new values of Author and Title fields | |
props.Author = "New Author"; | |
props.Title = "New Title"; | |
// update the presentation with a new values | |
info.UpdateDocumentProperties(props); | |
info.WriteBindedPresentation(dataDir + "ModifyBuiltinProperties1.pptx"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run() | |
{ | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationProperties(); | |
DocumentProperties template = new DocumentProperties(); | |
template.Author = "Template Author"; | |
template.Title = "Template Title"; | |
template.Category = "Template Category"; | |
template.Keywords = "Keyword1, Keyword2, Keyword3"; | |
template.Company = "Our Company"; | |
template.Comments = "Created from template"; | |
template.ContentType = "Template Content"; | |
template.Subject = "Template Subject"; | |
UpdateByTemplate(dataDir + "doc1.pptx", template); | |
UpdateByTemplate(dataDir + "doc2.odp", template); | |
UpdateByTemplate(dataDir + "doc3.ppt", template); | |
} | |
private static void UpdateByTemplate(string path, IDocumentProperties template) | |
{ | |
IPresentationInfo toUpdate = PresentationFactory.Instance.GetPresentationInfo(path); | |
toUpdate.UpdateDocumentProperties(template); | |
toUpdate.WriteBindedPresentation(path); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run() | |
{ | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationProperties(); | |
DocumentProperties template; | |
IPresentationInfo info = PresentationFactory.Instance.GetPresentationInfo(dataDir + "template.pptx"); | |
template = (DocumentProperties)info.ReadDocumentProperties(); | |
template.Author = "Template Author"; | |
template.Title = "Template Title"; | |
template.Category = "Template Category"; | |
template.Keywords = "Keyword1, Keyword2, Keyword3"; | |
template.Company = "Our Company"; | |
template.Comments = "Created from template"; | |
template.ContentType = "Template Content"; | |
template.Subject = "Template Subject"; | |
UpdateByTemplate(dataDir + "doc1.pptx", template); | |
UpdateByTemplate(dataDir + "doc2.odp", template); | |
UpdateByTemplate(dataDir + "doc3.ppt", template); | |
} | |
private static void UpdateByTemplate(string path, IDocumentProperties template) | |
{ | |
IPresentationInfo toUpdate = PresentationFactory.Instance.GetPresentationInfo(path); | |
toUpdate.UpdateDocumentProperties(template); | |
toUpdate.WriteBindedPresentation(path); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationSaving(); | |
string pathToLargeImage = dataDir + "large_image.jpg"; | |
// create a new presentation which will contain this image | |
using (Presentation pres = new Presentation()) | |
{ | |
using (FileStream fileStream = new FileStream(pathToLargeImage, FileMode.Open)) | |
{ | |
// let's add the image to the presentation - we choose KeepLocked behavior, because we not | |
// have an intent to access the "largeImage.png" file. | |
IPPImage img = pres.Images.AddImage(fileStream, LoadingStreamBehavior.KeepLocked); | |
pres.Slides[0].Shapes.AddPictureFrame(ShapeType.Rectangle, 0, 0, 300, 200, img); | |
// save the presentation. Despite that the output presentation will be | |
// large, the memory consumption will be low the whole lifetime of the pres object | |
pres.Save(dataDir + "presentationWithLargeImage.pptx", SaveFormat.Pptx); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationSaving(); | |
string svgPath = dataDir + "sample.svg"; | |
string outPptxPath = dataDir + "presentation.pptx"; | |
using (var p = new Presentation()) | |
{ | |
string svgContent = File.ReadAllText(svgPath); | |
ISvgImage svgImage = new SvgImage(svgContent); | |
IPPImage ppImage = p.Images.AddImage(svgImage); | |
p.Slides[0].Shapes.AddPictureFrame(ShapeType.Rectangle, 0, 0, ppImage.Width, ppImage.Height, ppImage); | |
p.Save(outPptxPath, SaveFormat.Pptx); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationSaving(); | |
string outPptxPath = dataDir + "presentation_external.pptx"; | |
using (var p = new Presentation()) | |
{ | |
string svgContent = File.ReadAllText(new Uri(new Uri(dataDir), "image1.svg").AbsolutePath); | |
ISvgImage svgImage = new SvgImage(svgContent, new ExternalResourceResolver(), dataDir); | |
IPPImage ppImage = p.Images.AddImage(svgImage); | |
p.Slides[0].Shapes.AddPictureFrame(ShapeType.Rectangle, 0, 0, ppImage.Width, ppImage.Height, ppImage); | |
p.Save(outPptxPath, SaveFormat.Pptx); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationSaving(); | |
//Instatiate Presentation class that represents a PPTX file | |
Presentation pTemplate = new Presentation(dataDir + "RectPicFrame.pptx");//Instatiate Presentation class that represents a PPTX file | |
//ISlide object for accessing the slides in the presentation | |
ISlide slide = pTemplate.Slides[0]; | |
//IShape object for holding temporary shapes | |
IShape shape; | |
//Traversing through all the slides in the presentation | |
for (int slideCount = 0; slideCount < pTemplate.Slides.Count; slideCount++) | |
{ | |
slide = pTemplate.Slides[slideCount]; | |
//Travesing through all the shapes in the slides | |
for (int count = 0; count < slide.Shapes.Count; count++) | |
{ | |
shape = slide.Shapes[count]; | |
//if shape is autoshape | |
if (shape is IAutoShape) | |
{ | |
//Type casting to Auto shape and getting auto shape lock | |
IAutoShape Ashp = shape as IAutoShape; | |
IAutoShapeLock AutoShapeLock = Ashp.ShapeLock; | |
//Applying shapes locks | |
AutoShapeLock.PositionLocked = true; | |
AutoShapeLock.SelectLocked = true; | |
AutoShapeLock.SizeLocked = true; | |
} | |
//if shape is group shape | |
else if (shape is IGroupShape) | |
{ | |
//Type casting to group shape and getting group shape lock | |
IGroupShape Group = shape as IGroupShape; | |
IGroupShapeLock groupShapeLock = Group.ShapeLock; | |
//Applying shapes locks | |
groupShapeLock.GroupingLocked = true; | |
groupShapeLock.PositionLocked = true; | |
groupShapeLock.SelectLocked = true; | |
groupShapeLock.SizeLocked = true; | |
} | |
//if shape is a connector | |
else if (shape is IConnector) | |
{ | |
//Type casting to connector shape and getting connector shape lock | |
IConnector Conn = shape as IConnector; | |
IConnectorLock ConnLock = Conn.ShapeLock; | |
//Applying shapes locks | |
ConnLock.PositionMove = true; | |
ConnLock.SelectLocked = true; | |
ConnLock.SizeLocked = true; | |
} | |
//if shape is picture frame | |
else if (shape is IPictureFrame) | |
{ | |
//Type casting to pitcture frame shape and getting picture frame shape lock | |
IPictureFrame Pic = shape as IPictureFrame; | |
IPictureFrameLock PicLock = Pic.ShapeLock; | |
//Applying shapes locks | |
PicLock.PositionLocked = true; | |
PicLock.SelectLocked = true; | |
PicLock.SizeLocked = true; | |
} | |
} | |
} | |
//Saving the presentation file | |
pTemplate.Save(dataDir + "ProtectedSample.pptx", Aspose.Slides.Export.SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationSaving(); | |
using (Presentation pres = new Presentation(dataDir+ "image.pptx")) | |
{ | |
PictureFrame pFrame = pres.Slides[0].Shapes[0] as PictureFrame; | |
ISvgImage svgImage = pFrame.PictureFormat.Picture.Image.SvgImage; | |
if (svgImage != null) | |
{ | |
// Convert svg image into group of shapes | |
IGroupShape groupShape = pres.Slides[0].Shapes.AddGroupShape(svgImage, pFrame.Frame.X, pFrame.Frame.Y, | |
pFrame.Frame.Width, pFrame.Frame.Height); | |
// remove source svg image from presentation | |
pres.Slides[0].Shapes.Remove(pFrame); | |
} | |
pres.Save(dataDir + "image_group.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Instantiate Presentation | |
Presentation pres = new Presentation(); | |
// Get the first slide | |
ISlide sld = (ISlide)pres.Slides[0]; | |
// Add an AutoShape of Rectangle type | |
IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 75, 150, 50); | |
// Add ITextFrame to the Rectangle | |
ashp.AddTextFrame("Hello World"); | |
// Change the text color to Black (which is White by default) | |
ashp.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillType.Solid; | |
ashp.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Black; | |
// Change the line color of the rectangle to White | |
ashp.ShapeStyle.LineColor.Color = Color.White; | |
// Remove any fill formatting in the shape | |
ashp.FillFormat.FillType = FillType.NoFill; | |
// Save the presentation to disk | |
pres.Save("D:\\data\\HelloWorld.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Create a presentation | |
Presentation pres = new Presentation(); | |
//Add the title slide | |
ISlide slide = pres.Slides.AddEmptySlide(pres.LayoutSlides[0]); | |
//Set the title text | |
((IAutoShape)slide.Shapes[0]).TextFrame.Text = "Slide Title Heading"; | |
//Set the sub title text | |
((IAutoShape)slide.Shapes[1]).TextFrame.Text = "Slide Title Sub-Heading"; | |
//Write output to disk | |
pres.Save("c:\\data\\outAsposeSlides.pptx", SaveFormat.Ppt); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Instantiate a Presentation object that represents a PPT file | |
Presentation pres = new Presentation(); | |
//Create a License object | |
License license = new License(); | |
//Set the license of Aspose.Slides for .NET to avoid the evaluation limitations | |
license.SetLicense("Aspose.Slides.lic"); | |
//Adding an empty slide to the presentation and getting the reference of | |
//that empty slide | |
Slide slide = pres.AddEmptySlide(); | |
//Adding a rectangle (X=2400, Y=1800, Width=1000 & Height=500) to the slide | |
Aspose.Slides.Rectangle rect = slide.Shapes.AddRectangle(2400, 1800, 1000, 500); | |
//Hiding the lines of rectangle | |
rect.LineFormat.ShowLines = false; | |
//Adding a text frame to the rectangle with "Hello World" as a default text | |
rect.AddTextFrame("Hello World"); | |
//Removing the first slide of the presentation which is always added by | |
//Aspose.Slides for .NET by default while creating the presentation | |
pres.Slides.RemoveAt(0); | |
//Writing the presentation as a PPT file | |
pres.Write("C:\\hello.ppt"); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Open the desired presentation | |
Presentation pTemplate = new Presentation("ProtectedSample.pptx"); | |
//ISlide object for accessing the slides in the presentation | |
ISlide slide = pTemplate.Slides[0]; | |
//IShape object for holding temporary shapes | |
IShape shape; | |
//Traversing through all the slides in presentation | |
for (int slideCount = 0; slideCount < pTemplate.Slides.Count; slideCount++) | |
{ | |
slide = pTemplate.Slides[slideCount]; | |
//Travesing through all the shapes in the slides | |
for (int count = 0; count < slide.Shapes.Count; count++) | |
{ | |
shape = slide.Shapes[count]; | |
//if shape is autoshape | |
if (shape is IAutoShape) | |
{ | |
//Type casting to Auto shape and getting auto shape lock | |
IAutoShape Ashp = shape as AutoShape; | |
IAutoShapeLock AutoShapeLock = Ashp.ShapeLock; | |
//Applying shapes locks | |
AutoShapeLock.PositionLocked = false; | |
AutoShapeLock.SelectLocked = false; | |
AutoShapeLock.SizeLocked = false; | |
} | |
//if shape is group shape | |
else if (shape is IGroupShape) | |
{ | |
//Type casting to group shape and getting group shape lock | |
IGroupShape Group = shape as IGroupShape; | |
IGroupShapeLock groupShapeLock = Group.ShapeLock; | |
//Applying shapes locks | |
groupShapeLock.GroupingLocked = false; | |
groupShapeLock.PositionLocked = false; | |
groupShapeLock.SelectLocked = false; | |
groupShapeLock.SizeLocked = false; | |
} | |
//if shape is Connector shape | |
else if (shape is IConnector) | |
{ | |
//Type casting to connector shape and getting connector shape lock | |
IConnector Conn = shape as IConnector; | |
IConnectorLock ConnLock = Conn.ShapeLock; | |
//Applying shapes locks | |
ConnLock.PositionMove = false; | |
ConnLock.SelectLocked = false; | |
ConnLock.SizeLocked = false; | |
} | |
//if shape is picture frame | |
else if (shape is IPictureFrame) | |
{ | |
//Type casting to pitcture frame shape and getting picture frame shape lock | |
IPictureFrame Pic = shape as IPictureFrame; | |
IPictureFrameLock PicLock = Pic.ShapeLock; | |
//Applying shapes locks | |
PicLock.PositionLocked = false; | |
PicLock.SelectLocked = false; | |
PicLock.SizeLocked = false; | |
} | |
} | |
} | |
//Saving the presentation file | |
pTemplate.Save("RemoveProtectionSample.pptx", Aspose.Slides.Export.SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationSaving(); | |
// Opening the presentation file | |
Presentation presentation = new Presentation(dataDir + "RemoveWriteProtection.pptx"); | |
// Checking if presentation is write protected | |
if (presentation.ProtectionManager.IsWriteProtected) | |
// Removing Write protection | |
presentation.ProtectionManager.RemoveWriteProtection(); | |
// Saving presentation | |
presentation.Save(dataDir + "File_Without_WriteProtection_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationSaving(); | |
// Opening the presentation file | |
Presentation presentation = new Presentation(); | |
// Setting view type | |
presentation.ViewProperties.LastView = ViewType.SlideMasterView; | |
// Saving presentation | |
presentation.Save(dataDir + "SetViewType_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationSaving(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate a Presentation object that represents a PPT file | |
Presentation presentation = new Presentation(); | |
//....do some work here..... | |
// Setting Write protection Password | |
presentation.ProtectionManager.SetWriteProtection("test"); | |
// Save your presentation to a file | |
presentation.Save(dataDir + "WriteProtected_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationSaving(); | |
// Instantiate a Presentation object that represents a PPT file | |
Presentation presentation = new Presentation(); | |
//....do some work here..... | |
// Setting access to document properties in password protected mode | |
presentation.ProtectionManager.EncryptDocumentProperties = false; | |
// Setting Password | |
presentation.ProtectionManager.Encrypt("pass"); | |
// Save your presentation to a file | |
presentation.Save(dataDir + "Password Protected Presentation_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationSaving(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate a Presentation object that represents a PPT file | |
Presentation presentation= new Presentation(); | |
//...do some work here... | |
// Save your presentation to a file | |
presentation.Save(dataDir + "Saved_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationSaving(); | |
// Instantiate a Presentation object that represents a PPT file | |
using (Presentation presentation = new Presentation()) | |
{ | |
IAutoShape shape = presentation.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 200, 200, 200, 200); | |
// Add text to shape | |
shape.TextFrame.Text = "This demo shows how to Create PowerPoint file and save it to Stream."; | |
FileStream toStream = new FileStream(dataDir + "Save_As_Stream_out.pptx", FileMode.Create); | |
presentation.Save(toStream, Aspose.Slides.Export.SaveFormat.Pptx); | |
toStream.Close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide slide = presentation.Slides[0]; | |
// Add an autoshape of type line | |
slide.Shapes.AddAutoShape(ShapeType.Line, 50, 150, 300, 0); | |
// Save the presentation to Strict Open XML Format | |
presentation.Save(dataDir + "NewPresentation_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx, | |
new PptxOptions() { Conformance = Conformance.Iso29500_2008_Strict }); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PresentationSaving(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate a Presentation object that represents a PPT file | |
Presentation pres = new Presentation(); | |
//....do some work here..... | |
// Setting Password | |
pres.ProtectionManager.Encrypt("pass"); | |
// Save your presentation to a file | |
pres.Save(dataDir + "SaveWithPassword_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Rendering(); | |
// Load the presentation | |
Presentation presentation = new Presentation(dataDir + "Print.ppt"); | |
// Call the print method to print whole presentation to the default printer | |
presentation.Print(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Rendering(); | |
using (Presentation pres = new Presentation()) | |
{ | |
PrinterSettings printerSettings = new PrinterSettings(); | |
printerSettings.Copies = 2; | |
printerSettings.DefaultPageSettings.Landscape = true; | |
printerSettings.DefaultPageSettings.Margins.Left = 10; | |
//...etc | |
pres.Print(printerSettings); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Rendering(); | |
Presentation pres = new Presentation(dataDir+"presentation.pptx"); | |
Bitmap bmp = new Bitmap(740, 960); | |
NotesCommentsLayoutingOptions opts = new NotesCommentsLayoutingOptions(); | |
opts.CommentsAreaColor = Color.Red; | |
opts.CommentsAreaWidth = 200; | |
opts.CommentsPosition = CommentsPositions.Right; | |
opts.NotesPosition = NotesPositions.BottomTruncated; | |
using (Graphics graphics = Graphics.FromImage(bmp)) | |
{ | |
pres.Slides[0].RenderToGraphics(opts, graphics); | |
} | |
bmp.Save(dataDir+"OutPresBitmap.png", ImageFormat.Png); | |
System.Diagnostics.Process.Start(dataDir + "OutPresBitmap.png"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run() | |
{ | |
string dataDir = RunExamples.GetDataDir_Rendering(); | |
Presentation pres = new Presentation(dataDir+"input.pptx"); | |
pres.Save(dataDir+"emoji.pdf",Aspose.Slides.Export.SaveFormat.Pdf); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Rendering(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation presentation = new Presentation(dataDir + "HelloWorld.pptx")) | |
{ | |
// Get the slide number | |
int firstSlideNumber = presentation.FirstSlideNumber; | |
// Set the slide number | |
presentation.FirstSlideNumber=10; | |
presentation.Save(dataDir + "Set_Slide_Number_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Rendering(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Setting View Properties of Presentation | |
presentation.ViewProperties.SlideViewProperties.Scale = 100; // Zoom value in percentages for slide view | |
presentation.ViewProperties.NotesViewProperties.Scale = 100; // Zoom value in percentages for notes view | |
presentation.Save(dataDir + "Zoom_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Rendering(); | |
try | |
{ | |
// Load the presentation | |
Presentation presentation = new Presentation(dataDir + "Print.ppt"); | |
// Call the print method to print whole presentation to the desired printer | |
presentation.Print("Please set your printer name here"); | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine(ex.Message + "\nPlease set printer name as string parameter to the Presentation Print method"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Instantiate Presentation class that represents PPTX file | |
Presentation pres = new Presentation(dataDir + "AltText.pptx"); | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
for (int i = 0; i < sld.Shapes.Count; i++) | |
{ | |
// Accessing the shape collection of slides | |
IShape shape = sld.Shapes[i]; | |
if (shape is GroupShape) | |
{ | |
// Accessing the group shape. | |
IGroupShape grphShape = (IGroupShape)shape; | |
for (int j = 0; j < grphShape.Shapes.Count; j++) | |
{ | |
IShape shape2 = grphShape.Shapes[j]; | |
// Accessing the AltText property | |
Console.WriteLine(shape2.AlternativeText); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Load the PPTX to Presentation object | |
Presentation pres = new Presentation(dataDir + "AccessingOLEObjectFrame.pptx"); | |
// Access the first slide | |
ISlide sld = pres.Slides[0]; | |
// Cast the shape to OleObjectFrame | |
OleObjectFrame oof = (OleObjectFrame)sld.Shapes[0]; | |
// Read the OLE Object and write it to disk | |
if (oof != null) | |
{ | |
FileStream fstr = new FileStream(dataDir+ "excelFromOLE_out.xlsx", FileMode.Create, FileAccess.Write); | |
byte[] buf = oof.ObjectData; | |
fstr.Write(buf, 0, buf.Length); | |
fstr.Flush(); | |
fstr.Close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate PresentationEx class that represents the PPTX file | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Add an autoshape of type line | |
IAutoShape shp = sld.Shapes.AddAutoShape(ShapeType.Line, 50, 150, 300, 0); | |
// Apply some formatting on the line | |
shp.LineFormat.Style = LineStyle.ThickBetweenThin; | |
shp.LineFormat.Width = 10; | |
shp.LineFormat.DashStyle = LineDashStyle.DashDot; | |
shp.LineFormat.BeginArrowheadLength = LineArrowheadLength.Short; | |
shp.LineFormat.BeginArrowheadStyle = LineArrowheadStyle.Oval; | |
shp.LineFormat.EndArrowheadLength = LineArrowheadLength.Long; | |
shp.LineFormat.EndArrowheadStyle = LineArrowheadStyle.Triangle; | |
shp.LineFormat.FillFormat.FillType = FillType.Solid; | |
shp.LineFormat.FillFormat.SolidFillColor.Color = Color.Maroon; | |
//Write the PPTX to Disk | |
pres.Save(dataDir + "LineShape2_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate PresentationEx class that represents the PPTX file | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Add an autoshape of type line | |
IAutoShape shp = sld.Shapes.AddAutoShape(ShapeType.Line, 50, 150, 300, 0); | |
// Apply some formatting on the line | |
shp.LineFormat.Style = LineStyle.ThickBetweenThin; | |
shp.LineFormat.Width = 10; | |
shp.LineFormat.DashStyle = LineDashStyle.DashDot; | |
shp.LineFormat.BeginArrowheadLength = LineArrowheadLength.Short; | |
shp.LineFormat.BeginArrowheadStyle = LineArrowheadStyle.Oval; | |
shp.LineFormat.EndArrowheadLength = LineArrowheadLength.Long; | |
shp.LineFormat.EndArrowheadStyle = LineArrowheadStyle.Triangle; | |
shp.LineFormat.FillFormat.FillType = FillType.Solid; | |
shp.LineFormat.FillFormat.SolidFillColor.Color = Color.Maroon; | |
//Write the PPTX to Disk | |
pres.Save(dataDir + "LineShape2_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate Prseetation class that represents the PPTX | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Load the wav sound file to stram | |
FileStream fstr = new FileStream(dataDir+ "sampleaudio.wav", FileMode.Open, FileAccess.Read); | |
// Add Audio Frame | |
IAudioFrame af = sld.Shapes.AddAudioFrameEmbedded(50, 150, 100, 100, fstr); | |
// Set Play Mode and Volume of the Audio | |
af.PlayMode = AudioPlayModePreset.Auto; | |
af.Volume = AudioVolumeMode.Loud; | |
//Write the PPTX file to disk | |
pres.Save(dataDir + "AudioFrameEmbed_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate Prseetation class that represents the PPTX | |
Presentation pres = new Presentation(); | |
// Access the first slide | |
ISlide sld = pres.Slides[0]; | |
// Load an cel file to stream | |
FileStream fs = new FileStream(dataDir+ "book1.xlsx", FileMode.Open, FileAccess.Read); | |
MemoryStream mstream = new MemoryStream(); | |
byte[] buf = new byte[4096]; | |
while (true) | |
{ | |
int bytesRead = fs.Read(buf, 0, buf.Length); | |
if (bytesRead <= 0) | |
break; | |
mstream.Write(buf, 0, bytesRead); | |
} | |
// Add an Ole Object Frame shape | |
IOleObjectFrame oof = sld.Shapes.AddOleObjectFrame(0, 0, pres.SlideSize.Size.Width, pres.SlideSize.Size.Height, "Excel.Sheet.12", mstream.ToArray()); | |
//Write the PPTX to disk | |
pres.Save(dataDir + "OleEmbed_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Creating a picture object | |
Picture pic = new Picture(pres, "C:\\demo.jpg"); | |
//Adding the picture to presentation and getting the related picture Id | |
int picId = pres.Pictures.Add(pic); | |
//Assigning the picture Id of newly added picture to the Picture Id of | |
//OleObjectFrame where oof represents an OleObjectFrame | |
oof.PictureId = picId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate PresentationEx class that represents the PPTX file | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Add an autoshape of type line | |
sld.Shapes.AddAutoShape(ShapeType.Line, 50, 150, 300, 0); | |
//Write the PPTX to Disk | |
pres.Save(dataDir + "LineShape1_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Instantiate presentation object | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Load Image to be added in presentaiton image collection | |
Image img = new Bitmap(dataDir + "aspose-logo.jpg"); | |
IPPImage image = presentation.Images.AddImage(img); | |
// Add picture frame to slide | |
IPictureFrame pf = presentation.Slides[0].Shapes.AddPictureFrame(ShapeType.Rectangle, 50, 50, 100, 100, image); | |
// Setting relative scale width and height | |
pf.RelativeScaleHeight = 0.8f; | |
pf.RelativeScaleWidth = 1.35f; | |
// Save presentation | |
presentation.Save(dataDir + "Adding Picture Frame with Relative Scale_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate Prseetation class that represents the PPTX | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Instantiate the ImageEx class | |
System.Drawing.Image img = (System.Drawing.Image)new Bitmap(dataDir+ "aspose-logo.jpg"); | |
IPPImage imgx = pres.Images.AddImage(img); | |
// Add Picture Frame with height and width equivalent of Picture | |
sld.Shapes.AddPictureFrame(ShapeType.Rectangle, 50, 150, imgx.Width, imgx.Height, imgx); | |
//Write the PPTX file to disk | |
pres.Save(dataDir + "AddStretchOffsetForImageFill_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate PrseetationEx class that represents the PPTX | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Add Video Frame | |
IVideoFrame vf = sld.Shapes.AddVideoFrame(50, 150, 300, 150, dataDir+ "video1.avi"); | |
// Set Play Mode and Volume of the Video | |
vf.PlayMode = VideoPlayModePreset.Auto; | |
vf.Volume = AudioVolumeMode.Loud; | |
//Write the PPTX file to disk | |
pres.Save(dataDir + "VideoFrame_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run() | |
{ | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
using (Presentation pres = new Presentation()) | |
{ | |
AddVideoFromYouTube(pres, "Tj75Arhq5ho"); | |
pres.Save(dataDir + "AddVideoFrameFromWebSource_out.pptx", SaveFormat.Pptx); | |
} | |
} | |
private static void AddVideoFromYouTube(Presentation pres, string videoId) | |
{ | |
//add videoFrame | |
IVideoFrame videoFrame = pres.Slides[0].Shapes.AddVideoFrame(10, 10, 427, 240, "https://www.youtube.com/embed/" + videoId); | |
videoFrame.PlayMode = VideoPlayModePreset.Auto; | |
//load thumbnail | |
using (WebClient client = new WebClient()) | |
{ | |
string thumbnailUri = "http://img.youtube.com/vi/" + videoId + "/hqdefault.jpg"; | |
videoFrame.PictureFormat.Picture.Image = pres.Images.AddImage(client.DownloadData(thumbnailUri)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate PrseetationEx class that represents the PPTX | |
using (Presentation pres = new Presentation()) | |
{ | |
ISlide sld = pres.Slides[0]; | |
// Now create effect "PathFootball" for existing shape from scratch. | |
IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 150, 250, 25); | |
ashp.AddTextFrame("Animated TextBox"); | |
// Add PathFootBall animation effect | |
pres.Slides[0].Timeline.MainSequence.AddEffect(ashp, EffectType.PathFootball, | |
EffectSubtype.None, EffectTriggerType.AfterPrevious); | |
// Create some kind of "button". | |
IShape shapeTrigger = pres.Slides[0].Shapes.AddAutoShape(ShapeType.Bevel, 10, 10, 20, 20); | |
// Create sequence of effects for this button. | |
ISequence seqInter = pres.Slides[0].Timeline.InteractiveSequences.Add(shapeTrigger); | |
// Create custom user path. Our object will be moved only after "button" click. | |
IEffect fxUserPath = seqInter.AddEffect(ashp, EffectType.PathUser, EffectSubtype.None, EffectTriggerType.OnClick); | |
// Created path is empty so we should add commands for moving. | |
IMotionEffect motionBhv = ((IMotionEffect)fxUserPath.Behaviors[0]); | |
PointF[] pts = new PointF[1]; | |
pts[0] = new PointF(0.076f, 0.59f); | |
motionBhv.Path.Add(MotionCommandPathType.LineTo, pts, MotionPathPointsType.Auto, true); | |
pts[0] = new PointF(-0.076f, -0.59f); | |
motionBhv.Path.Add(MotionCommandPathType.LineTo, pts, MotionPathPointsType.Auto, false); | |
motionBhv.Path.Add(MotionCommandPathType.End, null, MotionPathPointsType.Auto, false); | |
//Write the presentation as PPTX to disk | |
pres.Save(dataDir + "AnimExample_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create an instance of Presentation class | |
Presentation pres = new Presentation(); | |
IShape autoShape = pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 30, 30, 200, 200); | |
autoShape.ThreeDFormat.Depth = 6; | |
autoShape.ThreeDFormat.Camera.SetRotation(40, 35, 20); | |
autoShape.ThreeDFormat.Camera.CameraType = CameraPresetType.IsometricLeftUp; | |
autoShape.ThreeDFormat.LightRig.LightType = LightRigPresetType.Balanced; | |
autoShape = pres.Slides[0].Shapes.AddAutoShape(ShapeType.Line, 30, 300, 200, 200); | |
autoShape.ThreeDFormat.Depth = 6; | |
autoShape.ThreeDFormat.Camera.SetRotation(0, 35, 20); | |
autoShape.ThreeDFormat.Camera.CameraType = CameraPresetType.IsometricLeftUp; | |
autoShape.ThreeDFormat.LightRig.LightType = LightRigPresetType.Balanced; | |
pres.Save(dataDir + "Rotation_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create an instance of Presentation class | |
Presentation pres = new Presentation(); | |
ISlide slide = pres.Slides[0]; | |
// Add a shape on slide | |
IAutoShape shape = slide.Shapes.AddAutoShape(ShapeType.Ellipse, 30, 30, 100, 100); | |
shape.FillFormat.FillType = FillType.Solid; | |
shape.FillFormat.SolidFillColor.Color = Color.Green; | |
ILineFillFormat format = shape.LineFormat.FillFormat; | |
format.FillType = FillType.Solid; | |
format.SolidFillColor.Color = Color.Orange; | |
shape.LineFormat.Width = 2.0; | |
// Set ThreeDFormat properties of shape | |
shape.ThreeDFormat.Depth = 4; | |
shape.ThreeDFormat.BevelTop.BevelType = BevelPresetType.Circle; | |
shape.ThreeDFormat.BevelTop.Height = 6; | |
shape.ThreeDFormat.BevelTop.Width = 6; | |
shape.ThreeDFormat.Camera.CameraType = CameraPresetType.OrthographicFront; | |
shape.ThreeDFormat.LightRig.LightType = LightRigPresetType.ThreePt; | |
shape.ThreeDFormat.LightRig.Direction = LightingDirection.Top; | |
// Write the presentation as a PPTX file | |
pres.Save(dataDir + "Bavel_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
Presentation pres = new Presentation(dataDir+ "ChangeOLEObjectData.pptx"); | |
ISlide slide = pres.Slides[0]; | |
OleObjectFrame ole = null; | |
// Traversing all shapes for Ole frame | |
foreach (IShape shape in slide.Shapes) | |
{ | |
if (shape is OleObjectFrame) | |
{ | |
ole = (OleObjectFrame)shape; | |
} | |
} | |
if (ole != null) | |
{ | |
// Reading object data in Workbook | |
Aspose.Cells.Workbook Wb; | |
using (System.IO.MemoryStream msln = new System.IO.MemoryStream(ole.ObjectData)) | |
{ | |
Wb = new Aspose.Cells.Workbook(msln); | |
using (System.IO.MemoryStream msout = new System.IO.MemoryStream()) | |
{ | |
// Modifying the workbook data | |
Wb.Worksheets[0].Cells[0, 4].PutValue("E"); | |
Wb.Worksheets[0].Cells[1, 4].PutValue(12); | |
Wb.Worksheets[0].Cells[2, 4].PutValue(14); | |
Wb.Worksheets[0].Cells[3, 4].PutValue(15); | |
Aspose.Cells.OoxmlSaveOptions so1 = new Aspose.Cells.OoxmlSaveOptions(Aspose.Cells.SaveFormat.Xlsx); | |
Wb.Save(msout, so1); | |
// Changing Ole frame object data | |
msout.Position = 0; | |
ole.ObjectData = msout.ToArray(); | |
} | |
} | |
} | |
pres.Save(dataDir + "OleEdit_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
Presentation presentation1 = new Presentation(dataDir + "HelloWorld.pptx"); | |
ISlide slide = presentation1.Slides[0]; | |
IAutoShape shp3 = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 200, 365, 400, 150); | |
shp3.FillFormat.FillType = FillType.NoFill; | |
shp3.AddTextFrame(" "); | |
ITextFrame txtFrame = shp3.TextFrame; | |
IParagraph para = txtFrame.Paragraphs[0]; | |
IPortion portion = para.Portions[0]; | |
portion.Text="Watermark Text Watermark Text Watermark Text"; | |
shp3 = slide.Shapes.AddAutoShape(ShapeType.Triangle, 200, 365, 400, 150); | |
slide.Shapes.Reorder(2, shp3); | |
presentation1.Save(dataDir + "Reshape_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Instantiate Presentation class | |
using (Presentation srcPres = new Presentation(dataDir + "Source Frame.pptx")) | |
{ | |
IShapeCollection sourceShapes = srcPres.Slides[0].Shapes; | |
ILayoutSlide blankLayout = srcPres.Masters[0].LayoutSlides.GetByType(SlideLayoutType.Blank); | |
ISlide destSlide = srcPres.Slides.AddEmptySlide(blankLayout); | |
IShapeCollection destShapes = destSlide.Shapes; | |
destShapes.AddClone(sourceShapes[1], 50, 150 + sourceShapes[0].Height); | |
destShapes.AddClone(sourceShapes[2]); | |
destShapes.InsertClone(0, sourceShapes[0], 50, 150); | |
// Write the PPTX file to disk | |
srcPres.Save(dataDir + "CloneShape_out.pptx", SaveFormat.Pptx); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run() | |
{ | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
Presentation pres = new Presentation(dataDir + "ConnectorLineAngle.pptx"); | |
Slide slide = (Slide)pres.Slides[0]; | |
Shape shape; | |
for (int i = 0; i < slide.Shapes.Count; i++) | |
{ | |
double dir = 0.0; | |
shape = (Shape)slide.Shapes[i]; | |
if (shape is AutoShape) | |
{ | |
AutoShape ashp = (AutoShape)shape; | |
if (ashp.ShapeType == ShapeType.Line) | |
{ | |
dir = getDirection(ashp.Width, ashp.Height, Convert.ToBoolean(ashp.Frame.FlipH), Convert.ToBoolean(ashp.Frame.FlipV)); | |
} | |
} | |
else if (shape is Connector) | |
{ | |
Connector ashp = (Connector)shape; | |
dir = getDirection(ashp.Width, ashp.Height, Convert.ToBoolean(ashp.Frame.FlipH), Convert.ToBoolean(ashp.Frame.FlipV)); | |
} | |
Console.WriteLine(dir); | |
} | |
} | |
public static double getDirection(float w, float h, bool flipH, bool flipV) | |
{ | |
float endLineX = w * (flipH ? -1 : 1); | |
float endLineY = h * (flipV ? -1 : 1); | |
float endYAxisX = 0; | |
float endYAxisY = h; | |
double angle = (Math.Atan2(endYAxisY, endYAxisX) - Math.Atan2(endLineY, endLineX)); | |
if (angle < 0) angle += 2 * Math.PI; | |
return angle * 180.0 / Math.PI; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Instantiate Presentation class that represents the PPTX file | |
using (Presentation input = new Presentation()) | |
{ | |
// Accessing shapes collection for selected slide | |
IShapeCollection shapes = input.Slides[0].Shapes; | |
// Add autoshape Ellipse | |
IAutoShape ellipse = shapes.AddAutoShape(ShapeType.Ellipse, 0, 100, 100, 100); | |
// Add autoshape Rectangle | |
IAutoShape rectangle = shapes.AddAutoShape(ShapeType.Rectangle, 100, 300, 100, 100); | |
// Adding connector shape to slide shape collection | |
IConnector connector = shapes.AddConnector(ShapeType.BentConnector2, 0, 0, 10, 10); | |
// Joining Shapes to connectors | |
connector.StartShapeConnectedTo = ellipse; | |
connector.EndShapeConnectedTo = rectangle; | |
// Call reroute to set the automatic shortest path between shapes | |
connector.Reroute(); | |
// Saving presenation | |
input.Save(dataDir + "Connecting shapes using connectors_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Instantiate Presentation class that represents the PPTX file | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Accessing shapes collection for selected slide | |
IShapeCollection shapes = presentation.Slides[0].Shapes; | |
// Adding connector shape to slide shape collection | |
IConnector connector = shapes.AddConnector(ShapeType.BentConnector3, 0, 0, 10, 10); | |
// Add autoshape Ellipse | |
IAutoShape ellipse = shapes.AddAutoShape(ShapeType.Ellipse, 0, 100, 100, 100); | |
// Add autoshape Rectangle | |
IAutoShape rectangle = shapes.AddAutoShape(ShapeType.Rectangle, 100, 200, 100, 100); | |
// Joining Shapes to connectors | |
connector.StartShapeConnectedTo = ellipse; | |
connector.EndShapeConnectedTo = rectangle; | |
// Setting the desired connection site index of Ellipse shape for connector to get connected | |
uint wantedIndex = 6; | |
// Checking if desired index is less than maximum site index count | |
if (ellipse.ConnectionSiteCount > wantedIndex) | |
{ | |
// Setting the desired connection site for connector on Ellipse | |
connector.StartShapeConnectionSiteIndex = wantedIndex; | |
} | |
// Save presentation | |
presentation.Save(dataDir + "Connecting_Shape_on_desired_connection_site_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Instantiate a Presentation class that represents the presentation file | |
using (Presentation presentation = new Presentation(dataDir + "HelloWorld.pptx")) | |
{ | |
// Create a Appearance bound shape image | |
using (Bitmap bitmap = presentation.Slides[0].Shapes[0].GetThumbnail(ShapeThumbnailBounds.Appearance, 1, 1)) | |
{ | |
// Save the image to disk in PNG format | |
bitmap.Save(dataDir + "Shape_thumbnail_Bound_Shape_out.png", ImageFormat.Png); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Instantiate Prseetation class | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Accessing the shape collection of slides | |
IShapeCollection slideShapes = sld.Shapes; | |
// Adding a group shape to the slide | |
IGroupShape groupShape = slideShapes.AddGroupShape(); | |
// Adding shapes inside added group shape | |
groupShape.Shapes.AddAutoShape(ShapeType.Rectangle, 300, 100, 100, 100); | |
groupShape.Shapes.AddAutoShape(ShapeType.Rectangle, 500, 100, 100, 100); | |
groupShape.Shapes.AddAutoShape(ShapeType.Rectangle, 300, 300, 100, 100); | |
groupShape.Shapes.AddAutoShape(ShapeType.Rectangle, 500, 300, 100, 100); | |
// Adding group shape frame | |
groupShape.Frame = new ShapeFrame(100, 300, 500, 40, NullableBool.False, NullableBool.False, 0); | |
// Write the PPTX file to disk | |
pres.Save(dataDir + "GroupShape_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Instantiate a Presentation class that represents the presentation file | |
using (Presentation p = new Presentation(dataDir + "HelloWorld.pptx")) | |
{ | |
// Create a full scale image | |
using (Bitmap bitmap = p.Slides[0].Shapes[0].GetThumbnail(ShapeThumbnailBounds.Shape, 1, 1)) | |
{ | |
// Save the image to disk in PNG format | |
bitmap.Save(dataDir + "Scaling Factor Thumbnail_out.png", ImageFormat.Png); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Instantiate a Presentation class that represents the presentation file | |
using (Presentation presentation = new Presentation(dataDir + "HelloWorld.pptx")) | |
{ | |
// Create a full scale image | |
using (Bitmap bitmap = presentation.Slides[0].Shapes[0].GetThumbnail()) | |
{ | |
// Save the image to disk in PNG format | |
bitmap.Save(dataDir + "Shape_thumbnail_out.png", ImageFormat.Png); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Instantiate Presentation class that represents the PPTX file | |
Presentation pres = new Presentation(); | |
// Add SmartArt | |
ISmartArt smart = pres.Slides[0].Shapes.AddSmartArt(10, 10, 400, 300, SmartArtLayoutType.BasicCycle); | |
// Obtain the reference of a node by using its Index | |
ISmartArtNode node = smart.Nodes[1]; | |
// Get thumbnail | |
Bitmap bmp = node.Shapes[0].GetThumbnail(); | |
// Save thumbnail | |
bmp.Save(dataDir + "SmartArt_ChildNote_Thumbnail_out.jpeg", ImageFormat.Jpeg); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
string videoDir = RunExamples.GetDataDir_Video(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate Presentation class that represents the PPTX | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Embedd vide inside presentation | |
IVideo vid = pres.Videos.AddVideo(new FileStream(videoDir + "Wildlife.mp4", FileMode.Open)); | |
// Add Video Frame | |
IVideoFrame vf = sld.Shapes.AddVideoFrame(50, 150, 300, 350, vid); | |
// Set video to Video Frame | |
vf.EmbeddedVideo = vid; | |
// Set Play Mode and Volume of the Video | |
vf.PlayMode = VideoPlayModePreset.Auto; | |
vf.Volume = AudioVolumeMode.Loud; | |
// Write the PPTX file to disk | |
pres.Save(dataDir + "VideoFrame_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The documents directory path. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
string pptxFileName = dataDir +"TestOlePresentation.pptx"; | |
using (Presentation pres = new Presentation(pptxFileName)) | |
{ | |
int objectnum = 0; | |
foreach (ISlide sld in pres.Slides) | |
{ | |
foreach (IShape shape in sld.Shapes) | |
{ | |
if (shape is OleObjectFrame) | |
{ | |
objectnum++; | |
OleObjectFrame oleFrame = shape as OleObjectFrame; | |
byte[] data = oleFrame.EmbeddedFileData; | |
string fileExtention = oleFrame.EmbeddedFileExtension; | |
string extractedPath = dataDir +"ExtractedObject_out" + objectnum + fileExtention; | |
using (FileStream fs = new FileStream(extractedPath, FileMode.Create)) | |
{ | |
fs.Write(data, 0, data.Length); | |
} | |
} | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate Prseetation class that represents the PPTX// Instantiate Prseetation class that represents the PPTX | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Add autoshape of ellipse type | |
IShape shp = sld.Shapes.AddAutoShape(ShapeType.Ellipse, 50, 150, 75, 150); | |
// Apply some gradiant formatting to ellipse shape | |
shp.FillFormat.FillType = FillType.Gradient; | |
shp.FillFormat.GradientFormat.GradientShape = GradientShape.Linear; | |
// Set the Gradient Direction | |
shp.FillFormat.GradientFormat.GradientDirection = GradientDirection.FromCorner2; | |
// Add two Gradiant Stops | |
shp.FillFormat.GradientFormat.GradientStops.Add((float)1.0, PresetColor.Purple); | |
shp.FillFormat.GradientFormat.GradientStops.Add((float)0, PresetColor.Red); | |
//Write the PPTX file to disk | |
pres.Save(dataDir + "EllipseShpGrad_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate Prseetation class that represents the PPTX | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Add autoshape of rectangle type | |
IShape shp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 150, 75, 150); | |
// Set the fill type to Pattern | |
shp.FillFormat.FillType = FillType.Pattern; | |
// Set the pattern style | |
shp.FillFormat.PatternFormat.PatternStyle = PatternStyle.Trellis; | |
// Set the pattern back and fore colors | |
shp.FillFormat.PatternFormat.BackColor.Color = Color.LightGray; | |
shp.FillFormat.PatternFormat.ForeColor.Color = Color.Yellow; | |
//Write the PPTX file to disk | |
pres.Save(dataDir + "RectShpPatt_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate PrseetationEx class that represents the PPTX | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Add autoshape of rectangle type | |
IShape shp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 150, 75, 150); | |
// Set the fill type to Picture | |
shp.FillFormat.FillType = FillType.Picture; | |
// Set the picture fill mode | |
shp.FillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Tile; | |
// Set the picture | |
System.Drawing.Image img = (System.Drawing.Image)new Bitmap(dataDir + "Tulips.jpg"); | |
IPPImage imgx = pres.Images.AddImage(img); | |
shp.FillFormat.PictureFillFormat.Picture.Image = imgx; | |
//Write the PPTX file to disk | |
pres.Save(dataDir + "RectShpPic_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(); | |
// Get the first slide | |
ISlide slide = presentation.Slides[0]; | |
// Add autoshape of rectangle type | |
IShape shape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 150, 75, 150); | |
// Set the fill type to Solid | |
shape.FillFormat.FillType = FillType.Solid; | |
// Set the color of the rectangle | |
shape.FillFormat.SolidFillColor.Color = Color.Yellow; | |
//Write the PPTX file to disk | |
presentation.Save(dataDir + "RectShpSolid_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run() | |
{ | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate a Presentation class that represents the presentation file | |
using (Presentation p = new Presentation(dataDir + "FindingShapeInSlide.pptx")) | |
{ | |
ISlide slide = p.Slides[0]; | |
// Alternative text of the shape to be found | |
IShape shape = FindShape(slide, "Shape1"); | |
if (shape != null) | |
{ | |
Console.WriteLine("Shape Name: " + shape.Name); | |
} | |
} | |
} | |
// Method implementation to find a shape in a slide using its alternative text | |
public static IShape FindShape(ISlide slide, string alttext) | |
{ | |
// Iterating through all shapes inside the slide | |
for (int i = 0; i < slide.Shapes.Count; i++) | |
{ | |
// If the alternative text of the slide matches with the required one then | |
// Return the shape | |
if (slide.Shapes[i].AlternativeText.CompareTo(alttext) == 0) | |
return slide.Shapes[i]; | |
} | |
return null; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate Prseetation class that represents the PPTX | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Add three autoshapes of rectangle type | |
IShape shp1 = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 100, 150, 75); | |
IShape shp2 = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 300, 100, 150, 75); | |
IShape shp3 = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 250, 150, 75); | |
// Set the fill color of the rectangle shape | |
shp1.FillFormat.FillType = FillType.Solid; | |
shp1.FillFormat.SolidFillColor.Color = Color.Black; | |
shp2.FillFormat.FillType = FillType.Solid; | |
shp2.FillFormat.SolidFillColor.Color = Color.Black; | |
shp3.FillFormat.FillType = FillType.Solid; | |
shp3.FillFormat.SolidFillColor.Color = Color.Black; | |
// Set the line width | |
shp1.LineFormat.Width = 15; | |
shp2.LineFormat.Width = 15; | |
shp3.LineFormat.Width = 15; | |
// Set the color of the line of rectangle | |
shp1.LineFormat.FillFormat.FillType = FillType.Solid; | |
shp1.LineFormat.FillFormat.SolidFillColor.Color = Color.Blue; | |
shp2.LineFormat.FillFormat.FillType = FillType.Solid; | |
shp2.LineFormat.FillFormat.SolidFillColor.Color = Color.Blue; | |
shp3.LineFormat.FillFormat.FillType = FillType.Solid; | |
shp3.LineFormat.FillFormat.SolidFillColor.Color = Color.Blue; | |
// Set the Join Style | |
shp1.LineFormat.JoinStyle = LineJoinStyle.Miter; | |
shp2.LineFormat.JoinStyle = LineJoinStyle.Bevel; | |
shp3.LineFormat.JoinStyle = LineJoinStyle.Round; | |
// Add text to each rectangle | |
((IAutoShape)shp1).TextFrame.Text = "This is Miter Join Style"; | |
((IAutoShape)shp2).TextFrame.Text = "This is Bevel Join Style"; | |
((IAutoShape)shp3).TextFrame.Text = "This is Round Join Style"; | |
//Write the PPTX file to disk | |
pres.Save(dataDir + "RectShpLnJoin_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate Prseetation class that represents the PPTX | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Add autoshape of rectangle type | |
IShape shp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 150, 150, 75); | |
// Set the fill color of the rectangle shape | |
shp.FillFormat.FillType = FillType.Solid; | |
shp.FillFormat.SolidFillColor.Color = Color.White; | |
// Apply some formatting on the line of the rectangle | |
shp.LineFormat.Style = LineStyle.ThickThin; | |
shp.LineFormat.Width = 7; | |
shp.LineFormat.DashStyle = LineDashStyle.Dash; | |
// Set the color of the line of rectangle | |
shp.LineFormat.FillFormat.FillType = FillType.Solid; | |
shp.LineFormat.FillFormat.SolidFillColor.Color = Color.Blue; | |
//Write the PPTX file to disk | |
pres.Save(dataDir + "RectShpLn_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate Prseetation class that represents the PPTX | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Add autoshape of ellipse type | |
IShape shp = sld.Shapes.AddAutoShape(ShapeType.Ellipse, 50, 150, 150, 50); | |
// Apply some formatting to ellipse shape | |
shp.FillFormat.FillType = FillType.Solid; | |
shp.FillFormat.SolidFillColor.Color = Color.Chocolate; | |
// Apply some formatting to the line of Ellipse | |
shp.LineFormat.FillFormat.FillType = FillType.Solid; | |
shp.LineFormat.FillFormat.SolidFillColor.Color = Color.Black; | |
shp.LineFormat.Width = 5; | |
//Write the PPTX file to disk | |
pres.Save(dataDir + "EllipseShp2_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate Prseetation class that represents the PPTX | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Add autoshape of rectangle type | |
IShape shp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 150, 150, 50); | |
// Apply some formatting to rectangle shape | |
shp.FillFormat.FillType = FillType.Solid; | |
shp.FillFormat.SolidFillColor.Color = Color.Chocolate; | |
// Apply some formatting to the line of rectangle | |
shp.LineFormat.FillFormat.FillType = FillType.Solid; | |
shp.LineFormat.FillFormat.SolidFillColor.Color = Color.Black; | |
shp.LineFormat.Width = 5; | |
//Write the PPTX file to disk | |
pres.Save(dataDir + "RectShp2_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
using (Presentation pres = new Presentation(dataDir + "Presentation1.pptx")) | |
{ | |
IThreeDFormatEffectiveData threeDEffectiveData = pres.Slides[0].Shapes[0].ThreeDFormat.GetEffective(); | |
Console.WriteLine("= Effective camera properties ="); | |
Console.WriteLine("Type: " + threeDEffectiveData.Camera.CameraType); | |
Console.WriteLine("Field of view: " + threeDEffectiveData.Camera.FieldOfViewAngle); | |
Console.WriteLine("Zoom: " + threeDEffectiveData.Camera.Zoom); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
using (Presentation pres = new Presentation(dataDir + "Presentation1.pptx")) | |
{ | |
IThreeDFormatEffectiveData threeDEffectiveData = pres.Slides[0].Shapes[0].ThreeDFormat.GetEffective(); | |
Console.WriteLine("= Effective light rig properties ="); | |
Console.WriteLine("Type: " + threeDEffectiveData.LightRig.LightType); | |
Console.WriteLine("Direction: " + threeDEffectiveData.LightRig.Direction); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
using (Presentation pres = new Presentation(dataDir + "Presentation1.pptx")) | |
{ | |
IThreeDFormatEffectiveData threeDEffectiveData = pres.Slides[0].Shapes[0].ThreeDFormat.GetEffective(); | |
Console.WriteLine("= Effective shape's top face relief properties ="); | |
Console.WriteLine("Type: " + threeDEffectiveData.BevelTop.BevelType); | |
Console.WriteLine("Width: " + threeDEffectiveData.BevelTop.Width); | |
Console.WriteLine("Height: " + threeDEffectiveData.BevelTop.Height); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Instantiate Presentation class that represents the PPTX | |
Presentation pres = new Presentation(); | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Add autoshape of rectangle type | |
IShape shp1 = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 40, 150, 50); | |
IShape shp2 = sld.Shapes.AddAutoShape(ShapeType.Moon, 160, 40, 150, 50); | |
String alttext = "User Defined"; | |
int iCount = sld.Shapes.Count; | |
for (int i = 0; i < iCount; i++) | |
{ | |
AutoShape ashp = (AutoShape)sld.Shapes[i]; | |
if (String.Compare(ashp.AlternativeText, alttext, StringComparison.Ordinal) == 0) | |
{ | |
ashp.Hidden = true; | |
} | |
} | |
// Save presentation to disk | |
pres.Save(dataDir + "Hiding_Shapes_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Workbook book = new Workbook(dataDir + "chart.xlsx"); | |
Worksheet sheet = book.Worksheets[0]; | |
Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions(); | |
options.HorizontalResolution = 200; | |
options.VerticalResolution = 200; | |
options.ImageFormat = System.Drawing.Imaging.ImageFormat.Emf; | |
//Save the workbook to stream | |
SheetRender sr = new SheetRender(sheet, options); | |
Presentation pres = new Presentation(); | |
pres.Slides.RemoveAt(0); | |
String EmfSheetName=""; | |
for (int j = 0; j < sr.PageCount; j++) | |
{ | |
EmfSheetName=dataDir + "test" + sheet.Name + " Page" + (j + 1) + ".out.emf"; | |
sr.ToImage(j, EmfSheetName); | |
var bytes = File.ReadAllBytes(EmfSheetName); | |
var emfImage = pres.Images.AddImage(bytes); | |
ISlide slide= pres.Slides.AddEmptySlide(pres.LayoutSlides.GetByType(SlideLayoutType.Blank)); | |
var m = slide.Shapes.AddPictureFrame(ShapeType.Rectangle, 0, 0, pres.SlideSize.Size.Width, pres.SlideSize.Size.Height, emfImage); | |
} | |
pres.Save(dataDir+"Saved.pptx", Aspose.Slides.Export.SaveFormat.Pptx); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run() | |
{ | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
using (Presentation presentation = new Presentation("Presentation.pptx")) | |
{ | |
// Getting unique shape identifier in slide scope | |
long officeInteropShapeId = presentation.Slides[0].Shapes[0].OfficeInteropShapeId; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate Presentation class that represents the PPTX | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Instantiate the ImageEx class | |
System.Drawing.Image img = (System.Drawing.Image)new Bitmap(dataDir+ "aspose-logo.jpg"); | |
IPPImage imgx = pres.Images.AddImage(img); | |
// Add Picture Frame with height and width equivalent of Picture | |
IPictureFrame pf = sld.Shapes.AddPictureFrame(ShapeType.Rectangle, 50, 150, imgx.Width, imgx.Height, imgx); | |
// Apply some formatting to PictureFrameEx | |
pf.LineFormat.FillFormat.FillType = FillType.Solid; | |
pf.LineFormat.FillFormat.SolidFillColor.Color = Color.Blue; | |
pf.LineFormat.Width = 20; | |
pf.Rotation = 45; | |
//Write the PPTX file to disk | |
pres.Save(dataDir + "RectPicFrameFormat_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create Presentation object | |
Presentation pres = new Presentation(); | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Add autoshape of rectangle type | |
IShape shp1 = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 40, 150, 50); | |
IShape shp2 = sld.Shapes.AddAutoShape(ShapeType.Moon, 160, 40, 150, 50); | |
String alttext = "User Defined"; | |
int iCount = sld.Shapes.Count; | |
for (int i = 0; i < iCount; i++) | |
{ | |
AutoShape ashp = (AutoShape)sld.Shapes[0]; | |
if (String.Compare(ashp.AlternativeText, alttext, StringComparison.Ordinal) == 0) | |
{ | |
sld.Shapes.Remove(ashp); | |
} | |
} | |
// Save presentation to disk | |
pres.Save(dataDir + "RemoveShape_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void AddOleFrame(Slide slide, Int32 startRow, Int32 endRow, Int32 startCol, Int32 endCol, | |
Int32 dataSheetIdx, Int32 x, Int32 y, Double OleWidth, Double OleHeight, | |
Presentation presentation, WorkbookDesigner workbookDesigner, | |
Boolean onePagePerSheet, Int32 outputWidth, Int32 outputHeight) | |
{ | |
String tempFileName = Path.GetTempFileName(); | |
if (startRow == 0) | |
{ | |
startRow++; | |
endRow++; | |
} | |
//Setting active sheet index of workbook | |
workbookDesigner.Workbook.Worksheets.ActiveSheetIndex = dataSheetIdx; | |
//Getting Workbook and selected worksheet | |
Workbook workbook = workbookDesigner.Workbook; | |
Worksheet work = workbook.Worksheets[dataSheetIdx]; | |
//Setting Ole Size according to selected rows and columns | |
Size SlideOleSize = SetOleAccordingToSelectedRowsCloumns(workbook, startRow, endRow, startCol, endCol, dataSheetIdx); | |
OleWidth = SlideOleSize.Width; | |
OleHeight = SlideOleSize.Height; | |
//Set Ole Size in Workbook | |
workbook.Worksheets.SetOleSize(startRow, endRow, startCol, endCol); | |
workbook.Worksheets[0].IsGridlinesVisible = false; | |
//Setting Image Options to take the worksheet Image | |
ImageOrPrintOptions imageOrPrintOptions = new ImageOrPrintOptions(); | |
imageOrPrintOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Bmp; | |
imageOrPrintOptions.OnePagePerSheet = onePagePerSheet; | |
SheetRender render = new SheetRender(workbookDesigner.Workbook.Worksheets[dataSheetIdx], imageOrPrintOptions); | |
String ext = ".bmp"; | |
render.ToImage(0, tempFileName + ext); | |
Image image = ScaleImage(Image.FromFile(tempFileName + ext), outputWidth, outputHeight); | |
String newTempFileName = tempFileName.Replace(".tmp", ".tmp1") + ext; | |
image.Save(newTempFileName, System.Drawing.Imaging.ImageFormat.Bmp); | |
//Adding Image to slide picture collection | |
Picture pic = new Picture(presentation, newTempFileName); | |
int picId = presentation.Pictures.Add(pic); | |
//Saving worbook to stream and copying in byte array | |
Stream mstream = workbook.SaveToStream(); | |
byte[] chartOleData = new byte[mstream.Length]; | |
mstream.Position = 0; | |
mstream.Read(chartOleData, 0, chartOleData.Length); | |
//Adding Ole Object frame | |
OleObjectFrame oleObjectFrame = slide.Shapes.AddOleObjectFrame(x, y, Convert.ToInt32(OleWidth),Convert.ToInt32(OleHeight), "Excel.Sheet.8", chartOleData); | |
//Setting ole frame Imnae and Alternative Text property | |
oleObjectFrame.PictureId = picId; | |
oleObjectFrame.AlternativeText = "image" + picId; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WorkbookDesigner workbookDesigner = new WorkbookDesigner(); | |
workbookDesigner.Workbook = new Workbook("AsposeTest.xls"); | |
Presentation presentation = new Presentation("AsposeTest.ppt"); | |
Slide slide = presentation.Slides[0]; | |
AddOleFrame(slide, 0, 15, 0, 3, 0, 300, 1100, 0, 0, presentation, workbookDesigner, true, 0, 0); | |
String fileName = "AsposeTest_Ole.ppt"; | |
presentation.Save(fileName, Aspose.Slides.Export.SaveFormat.Ppt); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static Image ScaleImage(Image image, Int32 outputWidth, Int32 outputHeight) | |
{ | |
if (outputWidth == 0 && outputHeight == 0) | |
{ | |
outputWidth = image.Width; | |
outputHeight = image.Height; | |
} | |
Bitmap outputImage = new Bitmap(outputWidth, outputHeight, image.PixelFormat); | |
outputImage.SetResolution(image.HorizontalResolution, image.VerticalResolution); | |
Graphics graphics = Graphics.FromImage(outputImage); | |
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; | |
System.Drawing.Rectangle srcDestRect = new System.Drawing.Rectangle(0, 0, outputWidth, outputHeight); | |
graphics.DrawImage(image, srcDestRect, srcDestRect, GraphicsUnit.Pixel); | |
graphics.Dispose(); | |
return outputImage; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static Size SetOleAccordingToSelectedRowsCloumns(Workbook workbook, Int32 startRow, Int32 endRow, Int32 startCol,Int32 endCol, Int32 dataSheetIdx) | |
{ | |
Worksheet work = workbook.Worksheets[dataSheetIdx]; | |
double actualHeight = 0, actualWidth = 0; | |
for (int i = startRow; i <= endRow; i++) | |
actualHeight += work.Cells.GetRowHeightInch(i); | |
for (int i = startCol; i <= endCol; i++) | |
actualWidth += work.Cells.GetColumnWidthInch(i); | |
//Setting new Row and Column Height | |
return new Size((int)(Math.Round(actualWidth, 2) * 576), (int)(Math.Round(actualHeight, 2) * 576)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Load a presentation | |
Presentation presentation = new Presentation(@"D:\TestResize.ppt"); | |
//Old slide size | |
float currentHeight = presentation.SlideSize.Size.Height; | |
float currentWidth = presentation.SlideSize.Size.Width; | |
//Changing slide size | |
presentation.SlideSize.Type = SlideSizeType.A4Paper; | |
//New slide size | |
float newHeight = presentation.SlideSize.Size.Height; | |
float newWidth = presentation.SlideSize.Size.Width; | |
float ratioHeight = newHeight / currentHeight; | |
float ratioWidth = newWidth / currentWidth; | |
foreach (ISlide slide in presentation.Slides) | |
{ | |
foreach (IShape shape in slide.Shapes) | |
{ | |
//Resize position | |
shape.Height = shape.Height * ratioHeight; | |
shape.Width = shape.Width * ratioWidth; | |
//Resize shape size if required | |
shape.Y = shape.Y * ratioHeight; | |
shape.X = shape.X * ratioWidth; | |
} | |
} | |
presentation.Save("Resize.pptx", SaveFormat.Pptx); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void AddOleFrame(Slide slide, Int32 startRow, Int32 endRow, Int32 startCol, Int32 endCol, | |
Int32 dataSheetIdx, Int32 x, Int32 y, Double OleWidth, Double OleHeight, | |
Presentation presentation, WorkbookDesigner workbookDesigner, | |
Boolean onePagePerSheet, Int32 outputWidth, Int32 outputHeight) | |
{ | |
String tempFileName = Path.GetTempFileName(); | |
if (startRow == 0) | |
{ | |
startRow++; | |
endRow++; | |
} | |
//Setting active sheet index of workbook | |
workbookDesigner.Workbook.Worksheets.ActiveSheetIndex = dataSheetIdx; | |
//Getting Workbook and selected worksheet | |
Workbook workbook = workbookDesigner.Workbook; | |
Worksheet work = workbook.Worksheets[dataSheetIdx]; | |
//Scaling rows height and coluumns width according to custom Ole size | |
double height = OleHeight / 576f; | |
double width = OleWidth / 576f; | |
SetOleAccordingToCustomHeighWidth(workbook, startRow, endRow, startCol, endCol, width, height, dataSheetIdx); | |
//Set Ole Size in Workbook | |
workbook.Worksheets.SetOleSize(startRow, endRow, startCol, endCol); | |
workbook.Worksheets[0].IsGridlinesVisible = false; | |
//Setting Image Options to take the worksheet Image | |
ImageOrPrintOptions imageOrPrintOptions = new ImageOrPrintOptions(); | |
imageOrPrintOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Bmp; | |
imageOrPrintOptions.OnePagePerSheet = onePagePerSheet; | |
SheetRender render = new SheetRender(workbookDesigner.Workbook.Worksheets[dataSheetIdx], imageOrPrintOptions); | |
String ext = ".bmp"; | |
render.ToImage(0, tempFileName + ext); | |
Image image = ScaleImage(Image.FromFile(tempFileName + ext), outputWidth, outputHeight); | |
String newTempFileName = tempFileName.Replace(".tmp", ".tmp1") + ext; | |
image.Save(newTempFileName, ImageFormat.Bmp); | |
//Adding Image to slide picture collection | |
Picture pic = new Picture(presentation, newTempFileName); | |
int picId = presentation.Pictures.Add(pic); | |
//Saving worbook to stream and copying in byte array | |
Stream mstream = workbook.SaveToStream(); | |
byte[] chartOleData = new byte[mstream.Length]; | |
mstream.Position = 0; | |
mstream.Read(chartOleData, 0, chartOleData.Length); | |
//Adding Ole Object frame | |
OleObjectFrame oleObjectFrame = slide.Shapes.AddOleObjectFrame(x, y, Convert.ToInt32(OleWidth), | |
Convert.ToInt32(OleHeight), "Excel.Sheet.8", chartOleData); | |
//Setting ole frame Imnae and Alternative Text property | |
oleObjectFrame.PictureId = picId; | |
oleObjectFrame.AlternativeText = "image" + picId; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WorkbookDesigner workbookDesigner = new WorkbookDesigner(); | |
workbookDesigner.Workbook = new Workbook("AsposeTest.xls"); | |
Presentation presentation = new Presentation("AsposeTest.ppt"); | |
Slide slide = presentation.Slides[0]; | |
AddOleFrame(slide, 0, 15, 0, 3, 0, 300, 1100, 0, 0, presentation, workbookDesigner, true, 0, 0); | |
String fileName = "AsposeTest_Ole.ppt"; | |
presentation.Save(fileName, Aspose.Slides.Export.SaveFormat.Ppt); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static Image ScaleImage(Image image, Int32 outputWidth, Int32 outputHeight) | |
{ | |
if (outputWidth == 0 && outputHeight == 0) | |
{ | |
outputWidth = image.Width; | |
outputHeight = image.Height; | |
} | |
Bitmap outputImage = new Bitmap(outputWidth, outputHeight, image.PixelFormat); | |
outputImage.SetResolution(image.HorizontalResolution, image.VerticalResolution); | |
Graphics graphics = Graphics.FromImage(outputImage); | |
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; | |
System.Drawing.Rectangle srcDestRect = new System.Drawing.Rectangle(0, 0, outputWidth, outputHeight); | |
graphics.DrawImage(image, srcDestRect, srcDestRect, GraphicsUnit.Pixel); | |
graphics.Dispose(); | |
return outputImage; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void SetOleAccordingToCustomHeighWidth(Workbook workbook, Int32 startRow, | |
Int32 endRow, Int32 startCol, Int32 endCol, double slideWidth, double slideHeight, Int32 dataSheetIdx) | |
{ | |
Worksheet work = workbook.Worksheets[dataSheetIdx]; | |
double actualHeight = 0, actualWidth = 0; | |
double newHeight = slideHeight; | |
double newWidth = slideWidth; | |
double tem = 0; | |
double newTem = 0; | |
for (int i = startRow; i <= endRow; i++) | |
actualHeight += work.Cells.GetRowHeightInch(i); | |
for (int i = startCol; i <= endCol; i++) | |
actualWidth += work.Cells.GetColumnWidthInch(i); | |
///Setting new Row and Column Height | |
for (int i = startRow; i <= endRow; i++) | |
{ | |
tem = work.Cells.GetRowHeightInch(i); | |
newTem = (tem / actualHeight) * newHeight; | |
work.Cells.SetRowHeightInch(i, newTem); | |
} | |
for (int i = startCol; i <= endCol; i++) | |
{ | |
tem = work.Cells.GetColumnWidthInch(i); | |
newTem = (tem / actualWidth) * newWidth; | |
work.Cells.SetColumnWidthInch(i, newTem); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate PrseetationEx class that represents the PPTX | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Add autoshape of rectangle type | |
IShape shp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 150, 75, 150); | |
// Rotate the shape to 90 degree | |
shp.Rotation = 90; | |
// Write the PPTX file to disk | |
pres.Save(dataDir + "RectShpRot_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Instantiate Presentation class that represents the PPTX | |
Presentation pres = new Presentation(); | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Add autoshape of rectangle type | |
IShape shp1 = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 40, 150, 50); | |
IShape shp2 = sld.Shapes.AddAutoShape(ShapeType.Moon, 160, 40, 150, 50); | |
shp2.FillFormat.FillType = FillType.Solid; | |
shp2.FillFormat.SolidFillColor.Color = Color.Gray; | |
for (int i = 0; i < sld.Shapes.Count; i++) | |
{ | |
var shape = sld.Shapes[i] as AutoShape; | |
if (shape != null) | |
{ | |
AutoShape ashp = shape; | |
ashp.AlternativeText = "User Defined"; | |
} | |
} | |
// Save presentation to disk | |
pres.Save(dataDir + "Set_AlternativeText_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (Presentation pres = new Presentation()) | |
{ | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Add known Ole objects | |
byte[] fileBytes = File.ReadAllBytes(dataDir + "test.zip"); | |
// Create Ole embedded file info | |
IOleEmbeddedDataInfo dataInfo = new OleEmbeddedDataInfo(fileBytes, "zip"); | |
// Create OLE object | |
IOleObjectFrame oleFrame = pres.Slides[0].Shapes.AddOleObjectFrame(150, 20, 50, 50, dataInfo); | |
oleFrame.IsObjectIcon = true; | |
pres.Save(dataDir + "SetFileTypeForAnEmbeddingObject.pptx", SaveFormat.Pptx); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate Prseetation class that represents the PPTX | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Add autoshape of ellipse type | |
sld.Shapes.AddAutoShape(ShapeType.Ellipse, 50, 150, 150, 50); | |
//Write the PPTX file to disk | |
pres.Save(dataDir + "EllipseShp1_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate Prseetation class that represents the PPTX | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Add autoshape of rectangle type | |
sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 150, 150, 50); | |
//Write the PPTX file to disk | |
pres.Save(dataDir+ "RectShp1_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate Prseetation class that represents the PPTX | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide slide = pres.Slides[0]; | |
// Instantiate the ImageEx class | |
System.Drawing.Image img = (System.Drawing.Image)new Bitmap(dataDir + "aspose-logo.jpg"); | |
IPPImage imgEx = pres.Images.AddImage(img); | |
// Add an AutoShape of Rectangle type | |
IAutoShape aShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 300, 300); | |
// Set shape's fill type | |
aShape.FillFormat.FillType = FillType.Picture; | |
// Set shape's picture fill mode | |
aShape.FillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Stretch; | |
// Set image to fill the shape | |
aShape.FillFormat.PictureFillFormat.Picture.Image = imgEx; | |
// Specify image offsets from the corresponding edge of the shape's bounding box | |
aShape.FillFormat.PictureFillFormat.StretchOffsetLeft = 25; | |
aShape.FillFormat.PictureFillFormat.StretchOffsetRight = 25; | |
aShape.FillFormat.PictureFillFormat.StretchOffsetTop = -20; | |
aShape.FillFormat.PictureFillFormat.StretchOffsetBottom = -10; | |
//Write the PPTX file to disk | |
pres.Save(dataDir + "StretchOffsetLeftForPictureFrame_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Shapes(); | |
string oleSourceFile = dataDir +"ExcelObject.xlsx"; | |
string oleIconFile = dataDir + "Image.png"; | |
using (Presentation pres = new Presentation()) | |
{ | |
IPPImage image = null; | |
ISlide slide = pres.Slides[0]; | |
// Add Ole objects | |
byte[] allbytes = File.ReadAllBytes(oleSourceFile); | |
IOleObjectFrame oof = slide.Shapes.AddOleObjectFrame(20, 20, 50, 50, "Excel.Sheet.12", allbytes); | |
oof.IsObjectIcon = true; | |
// Add image object | |
byte[] imgBuf = File.ReadAllBytes(oleIconFile); | |
using (MemoryStream ms = new MemoryStream(imgBuf)) | |
{ | |
image = pres.Images.AddImage(new Bitmap(ms)); | |
} | |
oof.SubstitutePictureFormat.Picture.Image = image; | |
// Set caption to OLE icon | |
oof.SubstitutePictureTitle = "Caption example"; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Auto_Open() | |
{ | |
Shape oShape; | |
Slide oSlide; | |
object oGraph; | |
// Loop through each slide in the presentation. | |
foreach (var oSlide in ActivePresentation.Slides) | |
{ | |
// Loop through all the shapes on the current slide. | |
foreach (var oShape in oSlide.Shapes) | |
{ | |
// Check whether the shape is an OLE object. | |
if (oShape.Type == msoEmbeddedOLEObject) | |
{ | |
// Found an OLE object; obtain object reference, and then update. | |
oObject = oShape.OLEFormat.Object; | |
oObject.Application.Update(); | |
// Now, quit out of the OLE server program. This frees | |
// memory, and prevents any problems. Also, set oObject equal | |
// to Nothing to release the object. | |
oObject.Application.Quit(); | |
oObject = null; | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Creating empty presentation | |
Presentation pres = new Presentation(); | |
//Accessing the First slide | |
ISlide slide = pres.Slides[0]; | |
//Adding the picture object to pictures collection of the presentation | |
System.Drawing.Image pic = (System.Drawing.Image)new Bitmap("C:\\Data\\aspose.jpg"); | |
IPPImage imgx = pres.Images.AddImage(pic); | |
//Add Picture Frame with height and width equivalent of Picture | |
IPictureFrame PicFrame = slide.Shapes.AddPictureFrame(ShapeType.Rectangle, 50, 150, imgx.Width, imgx.Height, imgx); | |
//Applying animation on picture frame | |
//PicFrame.AnimationSettings.EntryEffect = ShapeEntryEffect.BoxIn; | |
//Saving Presentation | |
pres.Save("c:\\data\\AsposeAnim.ppt", SaveFormat.Ppt); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Setting the animation order | |
ellipseAnimation.AnimationOrder = 1; | |
rectangleAnimation.AnimationOrder = 2; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Transitions(); | |
//Instantiate a presentation | |
Presentation pptPresentation = new Presentation(); | |
//Get first slide | |
Slide slideOne = pptPresentation.GetSlideByPosition(1); | |
//Add a rectangle shape | |
Rectangle rectangleShape = slideOne.Shapes.AddRectangle(50, 50, 500, 250); | |
//Add a Text Frame | |
rectangleShape.AddTextFrame("Animated Text"); | |
//Set shape to fit according to text | |
rectangleShape.TextFrame.FitShapeToText = true; | |
//Fill rectangle with some color | |
rectangleShape.FillFormat.Type = FillType.Solid; | |
rectangleShape.FillFormat.ForeColor = System.Drawing.Color.Firebrick; | |
//Add an ellipse shape | |
Ellipse ellipseShape = slideOne.Shapes.AddEllipse(2500, 50, 500, 250); | |
//Set reference to AnimationSettings object associated with rectangle | |
AnimationSettings rectangleAnimation = rectangleShape.AnimationSettings; | |
//Set reference to AnimationSettings object associated with ellipse | |
AnimationSettings ellipseAnimation = ellipseShape.AnimationSettings; | |
//Apply animation effects on rectangle | |
rectangleAnimation.EntryEffect = ShapeEntryEffect.ZoomOutSlightly; | |
rectangleAnimation.AfterEffect = ShapeAfterEffect.Dim; | |
//Apply animation effects on ellipse | |
ellipseAnimation.EntryEffect = ShapeEntryEffect.DiamondOut; | |
ellipseAnimation.AfterEffect = ShapeAfterEffect.HideOnClick; | |
//Write presentation to the disk | |
pptPresentation.Write(dataDir+"animatedPres.ppt"); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Background(); | |
// Instantiate the Presentation class that represents the presentation file | |
Presentation pres = new Presentation(dataDir + "SamplePresentation.pptx"); | |
IBackgroundEffectiveData effBackground = pres.Slides[0].CreateBackgroundEffective(); | |
if (effBackground.FillFormat.FillType == FillType.Solid) | |
Console.WriteLine("Fill color: " + effBackground.FillFormat.SolidFillColor); | |
else | |
Console.WriteLine("Fill type: " + effBackground.FillFormat.FillType); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Background(); | |
// Instantiate the Presentation class that represents the presentation file | |
using (Presentation pres = new Presentation(dataDir + "SetBackgroundToGradient.pptx")) | |
{ | |
// Apply Gradiant effect to the Background | |
pres.Slides[0].Background.Type = BackgroundType.OwnBackground; | |
pres.Slides[0].Background.FillFormat.FillType = FillType.Gradient; | |
pres.Slides[0].Background.FillFormat.GradientFormat.TileFlip = TileFlip.FlipBoth; | |
//Write the presentation to disk | |
pres.Save(dataDir + "ContentBG_Grad_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Background(); | |
// Instantiate the Presentation class that represents the presentation file | |
using (Presentation pres = new Presentation(dataDir + "SetImageAsBackground.pptx")) | |
{ | |
// Set the background with Image | |
pres.Slides[0].Background.Type = BackgroundType.OwnBackground; | |
pres.Slides[0].Background.FillFormat.FillType = FillType.Picture; | |
pres.Slides[0].Background.FillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Stretch; | |
// Set the picture | |
System.Drawing.Image img = (System.Drawing.Image)new Bitmap(dataDir + "Tulips.jpg"); | |
// Add image to presentation's images collection | |
IPPImage imgx = pres.Images.AddImage(img); | |
pres.Slides[0].Background.FillFormat.PictureFillFormat.Picture.Image = imgx; | |
// Write the presentation to disk | |
pres.Save(dataDir + "ContentBG_Img_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Background(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate the Presentation class that represents the presentation file | |
using (Presentation pres = new Presentation()) | |
{ | |
// Set the background color of the Master ISlide to Forest Green | |
pres.Masters[0].Background.Type = BackgroundType.OwnBackground; | |
pres.Masters[0].Background.FillFormat.FillType = FillType.Solid; | |
pres.Masters[0].Background.FillFormat.SolidFillColor.Color = Color.ForestGreen; | |
// Write the presentation to disk | |
pres.Save(dataDir + "SetSlideBackgroundMaster_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Background(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate the Presentation class that represents the presentation file | |
using (Presentation pres = new Presentation()) | |
{ | |
// Set the background color of the first ISlide to Blue | |
pres.Slides[0].Background.Type = BackgroundType.OwnBackground; | |
pres.Slides[0].Background.FillFormat.FillType = FillType.Solid; | |
pres.Slides[0].Background.FillFormat.SolidFillColor.Color = Color.Blue; | |
pres.Save(dataDir + "ContentBG_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Comments(); | |
// Instantiate Presentation class | |
using (Presentation presentation = new Presentation(dataDir + "Comments1.pptx")) | |
{ | |
foreach (var commentAuthor in presentation.CommentAuthors) | |
{ | |
var author = (CommentAuthor) commentAuthor; | |
foreach (var comment1 in author.Comments) | |
{ | |
var comment = (Comment) comment1; | |
Console.WriteLine("ISlide :" + comment.Slide.SlideNumber + " has comment: " + comment.Text + " with Author: " + comment.Author.Name + " posted on time :" + comment.CreatedTime + "\n"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Comments(); | |
using (Presentation pres = new Presentation()) | |
{ | |
// Add comment | |
ICommentAuthor author1 = pres.CommentAuthors.AddAuthor("Author_1", "A.A."); | |
IComment comment1 = author1.Comments.AddComment("comment1", pres.Slides[0], new PointF(10, 10), DateTime.Now); | |
// Add reply for comment1 | |
ICommentAuthor author2 = pres.CommentAuthors.AddAuthor("Autror_2", "B.B."); | |
IComment reply1 = author2.Comments.AddComment("reply 1 for comment 1", pres.Slides[0], new PointF(10, 10), DateTime.Now); | |
reply1.ParentComment = comment1; | |
// Add reply for comment1 | |
IComment reply2 = author2.Comments.AddComment("reply 2 for comment 1", pres.Slides[0], new PointF(10, 10), DateTime.Now); | |
reply2.ParentComment = comment1; | |
// Add reply to reply | |
IComment subReply = author1.Comments.AddComment("subreply 3 for reply 2", pres.Slides[0], new PointF(10, 10), DateTime.Now); | |
subReply.ParentComment = reply2; | |
IComment comment2 = author2.Comments.AddComment("comment 2", pres.Slides[0], new PointF(10, 10), DateTime.Now); | |
IComment comment3 = author2.Comments.AddComment("comment 3", pres.Slides[0], new PointF(10, 10), DateTime.Now); | |
IComment reply3 = author1.Comments.AddComment("reply 4 for comment 3", pres.Slides[0], new PointF(10, 10), DateTime.Now); | |
reply3.ParentComment = comment3; | |
// Display hierarchy on console | |
ISlide slide = pres.Slides[0]; | |
var comments = slide.GetSlideComments(null); | |
for (int i = 0; i < comments.Length; i++) | |
{ | |
IComment comment = comments[i]; | |
while (comment.ParentComment != null) | |
{ | |
Console.Write("\t"); | |
comment = comment.ParentComment; | |
} | |
Console.Write("{0} : {1}", comments[i].Author.Name, comments[i].Text); | |
Console.WriteLine(); | |
} | |
pres.Save(dataDir + "parent_comment.pptx",SaveFormat.Pptx); | |
// Remove comment1 and all its replies | |
comment1.Remove(); | |
pres.Save(dataDir + "remove_comment.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Comments(); | |
// Instantiate Presentation class | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Adding Empty slide | |
presentation.Slides.AddEmptySlide(presentation.LayoutSlides[0]); | |
// Adding Author | |
ICommentAuthor author = presentation.CommentAuthors.AddAuthor("Jawad", "MF"); | |
// Position of comments | |
PointF point = new PointF(); | |
point.X = 0.2f; | |
point.Y = 0.2f; | |
// Adding slide comment for an author on slide 1 | |
author.Comments.AddComment("Hello Jawad, this is slide comment", presentation.Slides[0], point, DateTime.Now); | |
// Adding slide comment for an author on slide 1 | |
author.Comments.AddComment("Hello Jawad, this is second slide comment", presentation.Slides[1], point, DateTime.Now); | |
// Accessing ISlide 1 | |
ISlide slide = presentation.Slides[0]; | |
// if null is passed as an argument then it will bring comments from all authors on selected slide | |
IComment[] Comments = slide.GetSlideComments(author); | |
// Accessin the comment at index 0 for slide 1 | |
String str = Comments[0].Text; | |
presentation.Save(dataDir + "Comments_out.pptx", SaveFormat.Pptx); | |
if (Comments.GetLength(0) > 0) | |
{ | |
// Select comments collection of Author at index 0 | |
ICommentCollection commentCollection = Comments[0].Author.Comments; | |
String Comment = commentCollection[0].Text; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(dataDir + "AccessSlides.pptx"); | |
// Getting Slide ID | |
uint id = presentation.Slides[0].SlideId; | |
// Accessing Slide by ID | |
IBaseSlide slide = presentation.GetSlideById(id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(dataDir + "AccessSlides.pptx"); | |
// Obtain a slide's reference by its index | |
ISlide slide = presentation.Slides[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation pres = new Presentation(dataDir + "AccessSlides.pptx")) | |
{ | |
// Accessing a slide using its slide index | |
ISlide slide = pres.Slides[0]; | |
System.Console.WriteLine("Slide Number: " + slide.SlideNumber); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate Presentation class that represents the presentation file | |
using (Presentation presentation = new Presentation(dataDir + "AccessSlides.pptx")) | |
{ | |
IMasterNotesSlide notesMaster = presentation.MasterNotesSlideManager.MasterNotesSlide; | |
if (notesMaster != null) | |
{ | |
// Get MasterNotesSlide text style | |
ITextStyle notesStyle = notesMaster.NotesStyle; | |
//Set symbol bullet for the first level paragraphs | |
IParagraphFormat paragraphFormat = notesStyle.GetLevel(0); | |
paragraphFormat.Bullet.Type = BulletType.Symbol; | |
} | |
// Save the PPTX file to the Disk | |
presentation.Save(dataDir + "AddNotesSlideWithNotesStyle_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate Presentation class that represents the presentation file | |
using (Presentation pres = new Presentation()) | |
{ | |
// Instantiate SlideCollection calss | |
ISlideCollection slds = pres.Slides; | |
for (int i = 0; i < pres.LayoutSlides.Count; i++) | |
{ | |
// Add an empty slide to the Slides collection | |
slds.AddEmptySlide(pres.LayoutSlides[i]); | |
} | |
// Save the PPTX file to the Disk | |
pres.Save(dataDir + "EmptySlide_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD(); | |
// Instantiate Presentation class to load the source presentation file | |
using (Presentation pres = new Presentation(dataDir + "ChangePosition.pptx")) | |
{ | |
// Get the slide whose position is to be changed | |
ISlide sld = pres.Slides[0]; | |
// Set the new position for the slide | |
sld.SlideNumber = 2; | |
// Write the presentation to disk | |
pres.Save(dataDir + "Aspose_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD(); | |
// Instantiate Presentation class to load the source presentation file | |
using (Presentation sourcePresentation = new Presentation(dataDir + "AccessSlides.pptx")) | |
{ | |
// Instantiate Presentation class for destination presentation (where slide is to be cloned) | |
using (Presentation destPres = new Presentation()) | |
{ | |
// Clone the desired slide from the source presentation to the end of the collection of slides in destination presentation | |
ISlideCollection slideCollection = destPres.Slides; | |
// Clone the desired slide from the source presentation to the specified position in destination presentation | |
slideCollection.InsertClone(1, sourcePresentation.Slides[1]); | |
// Write the destination presentation to disk | |
destPres.Save(dataDir + "CloneAnotherPresentationAtSpecifiedPosition_out.pptx", SaveFormat.Pptx); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD(); | |
// Instantiate Presentation class to load the source presentation file | |
using (Presentation srcPres = new Presentation(dataDir + "CloneAtEndOfAnother.pptx")) | |
{ | |
// Instantiate Presentation class for destination PPTX (where slide is to be cloned) | |
using (Presentation destPres = new Presentation()) | |
{ | |
// Clone the desired slide from the source presentation to the end of the collection of slides in destination presentation | |
ISlideCollection slds = destPres.Slides; | |
slds.AddClone(srcPres.Slides[0]); | |
// Write the destination presentation to disk | |
destPres.Save(dataDir + "Aspose2_out.pptx", SaveFormat.Pptx); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD(); | |
// Instantiate Presentation class to load the source presentation file | |
using (Presentation srcPres = new Presentation(dataDir + "CloneAtEndOfAnotherSpecificPosition.pptx")) | |
{ | |
// Instantiate Presentation class for destination presentation (where slide is to be cloned) | |
using (Presentation destPres = new Presentation()) | |
{ | |
// Clone the desired slide from the source presentation to the end of the collection of slides in destination presentation | |
ISlideCollection slds = destPres.Slides; | |
// Clone the desired slide from the source presentation to the specified position in destination presentation | |
slds.InsertClone(1, srcPres.Slides[1]); | |
// Write the destination presentation to disk | |
destPres.Save(dataDir + "Aspose1_out.pptx", SaveFormat.Pptx); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD(); | |
// Instantiate Presentation class to load the source presentation file | |
using (Presentation srcPres = new Presentation(dataDir + "CloneToAnotherPresentationWithMaster.pptx")) | |
{ | |
// Instantiate Presentation class for destination presentation (where slide is to be cloned) | |
using (Presentation destPres = new Presentation()) | |
{ | |
// Instantiate ISlide from the collection of slides in source presentation along with | |
// Master slide | |
ISlide SourceSlide = srcPres.Slides[0]; | |
IMasterSlide SourceMaster = SourceSlide.LayoutSlide.MasterSlide; | |
// Clone the desired master slide from the source presentation to the collection of masters in the | |
// Destination presentation | |
IMasterSlideCollection masters = destPres.Masters; | |
IMasterSlide DestMaster = SourceSlide.LayoutSlide.MasterSlide; | |
// Clone the desired master slide from the source presentation to the collection of masters in the | |
// Destination presentation | |
IMasterSlide iSlide = masters.AddClone(SourceMaster); | |
// Clone the desired slide from the source presentation with the desired master to the end of the | |
// Collection of slides in the destination presentation | |
ISlideCollection slds = destPres.Slides; | |
slds.AddClone(SourceSlide, iSlide, true); | |
// Clone the desired master slide from the source presentation to the collection of masters in the // Destination presentation | |
// Save the destination presentation to disk | |
destPres.Save(dataDir + "CloneToAnotherPresentationWithMaster_out.pptx", SaveFormat.Pptx); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD(); | |
// Instantiate Presentation class that represents a presentation file | |
using (Presentation pres = new Presentation(dataDir + "CloneWithInSamePresentation.pptx")) | |
{ | |
// Clone the desired slide to the end of the collection of slides in the same presentation | |
ISlideCollection slds = pres.Slides; | |
// Clone the desired slide to the specified index in the same presentation | |
slds.InsertClone(2, pres.Slides[1]); | |
// Write the modified presentation to disk | |
pres.Save(dataDir + "Aspose_CloneWithInSamePresentation_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD(); | |
// Instantiate Presentation class that represents a presentation file | |
using (Presentation pres = new Presentation(dataDir + "CloneWithinSamePresentationToEnd.pptx")) | |
{ | |
// Clone the desired slide to the end of the collection of slides in the same presentation | |
ISlideCollection slds = pres.Slides; | |
slds.AddClone(pres.Slides[0]); | |
// Write the modified presentation to disk | |
pres.Save(dataDir + "Aspose_CloneWithinSamePresentationToEnd_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD(); | |
// Instantiate a Presentation class that represents the presentation file | |
using (Presentation pres = new Presentation(dataDir + "CreateSlidesSVGImage.pptx")) | |
{ | |
// Access the first slide | |
ISlide sld = pres.Slides[0]; | |
// Create a memory stream object | |
MemoryStream SvgStream = new MemoryStream(); | |
// Generate SVG image of slide and save in memory stream | |
sld.WriteAsSvg(SvgStream); | |
SvgStream.Position = 0; | |
// Save memory stream to file | |
using (Stream fileStream = System.IO.File.OpenWrite(dataDir + "Aspose_out.svg")) | |
{ | |
byte[] buffer = new byte[8 * 1024]; | |
int len; | |
while ((len = SvgStream.Read(buffer, 0, buffer.Length)) > 0) | |
{ | |
fileStream.Write(buffer, 0, len); | |
} | |
} | |
SvgStream.Close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD(); | |
Presentation pres = new Presentation(dataDir + "Presentation1.pptx"); | |
ISection section = pres.Sections[2]; | |
pres.Sections.ReorderSectionWithSlides(section, 0); | |
pres.Sections.RemoveSectionWithSlides(pres.Sections[0]); | |
pres.Sections.AppendEmptySection("Last empty section"); | |
pres.Sections.AddSection("First empty", pres.Slides[0]); | |
pres.Sections[0].Name = "New section name"; | |
pres.Save(dataDir + "resultsection1.pptx",Aspose.Slides.Export.SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation pres = new Presentation(dataDir + "RemoveSlideUsingIndex.pptx")) | |
{ | |
// Removing a slide using its slide index | |
pres.Slides.RemoveAt(0); | |
// Writing the presentation file | |
pres.Save(dataDir + "modified_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation pres = new Presentation(dataDir + "RemoveSlideUsingReference.pptx")) | |
{ | |
// Accessing a slide using its index in the slides collection | |
ISlide slide = pres.Slides[0]; | |
// Removing a slide using its reference | |
pres.Slides.Remove(slide); | |
//Writing the presentation file | |
pres.Save(dataDir + "modified_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Hyperlink(); | |
// Instantiate Presentation class | |
Presentation presentation = new Presentation(dataDir + "Hyperlink.pptx"); | |
// Removing the hyperlinks from presentation | |
presentation.HyperlinkQueries.RemoveAllHyperlinks(); | |
//Writing the presentation as a PPTX file | |
presentation.Save(dataDir + "RemovedHyperlink_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (Presentation presentation = new Presentation()) | |
{ | |
IAutoShape shape1 = presentation.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 600, 50, false); | |
shape1.AddTextFrame("Aspose: File Format APIs"); | |
shape1.TextFrame.Paragraphs[0].Portions[0].PortionFormat.HyperlinkClick = new Hyperlink("https://www.aspose.com/"); | |
shape1.TextFrame.Paragraphs[0].Portions[0].PortionFormat.HyperlinkClick.Tooltip = "More than 70% Fortune 100 companies trust Aspose APIs"; | |
shape1.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 32; | |
presentation.Save("presentation-out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Hyperlink(); | |
using (Presentation presentation = new Presentation()) | |
{ | |
IAutoShape shape1 = presentation.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 600, 50, false); | |
shape1.AddTextFrame("Aspose: File Format APIs"); | |
shape1.TextFrame.Paragraphs[0].Portions[0].PortionFormat.HyperlinkClick = new Hyperlink("https://www.aspose.com/"); | |
shape1.TextFrame.Paragraphs[0].Portions[0].PortionFormat.HyperlinkClick.Tooltip = "More than 70% Fortune 100 companies trust Aspose APIs"; | |
shape1.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 32; | |
presentation.Save(dataDir+"presentation-out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Hyperlink(); | |
// Instantiate Presentation class | |
Presentation presentation = new Presentation(dataDir + "Hyperlink.pptx"); | |
// Removing the hyperlinks from presentation | |
presentation.HyperlinkQueries.RemoveAllHyperlinks(); | |
//Writing the presentation as a PPTX file | |
presentation.Save(dataDir + "RemovedHyperlink_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Hyperlink(); | |
using (Presentation presentation = new Presentation()) | |
{ | |
IAutoShape shape1 = presentation.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 450, 50, false); | |
shape1.AddTextFrame("This is a sample of colored hyperlink."); | |
shape1.TextFrame.Paragraphs[0].Portions[0].PortionFormat.HyperlinkClick = new Hyperlink("https://www.aspose.com/"); | |
shape1.TextFrame.Paragraphs[0].Portions[0].PortionFormat.HyperlinkClick.ColorSource = HyperlinkColorSource.PortionFormat; | |
shape1.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillType.Solid; | |
shape1.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red; | |
IAutoShape shape2 = presentation.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 100, 200, 450, 50, false); | |
shape2.AddTextFrame("This is a sample of usual hyperlink."); | |
shape2.TextFrame.Paragraphs[0].Portions[0].PortionFormat.HyperlinkClick = new Hyperlink("https://www.aspose.com/"); | |
presentation.Save(dataDir+"presentation-out-hyperlink.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Layout(); | |
// Instantiate Presentation class that represents the presentation file | |
using (Presentation presentation = new Presentation(dataDir + "AccessSlides.pptx")) | |
{ | |
// Try to search by layout slide type | |
IMasterLayoutSlideCollection layoutSlides = presentation.Masters[0].LayoutSlides; | |
ILayoutSlide layoutSlide = layoutSlides.GetByType(SlideLayoutType.TitleAndObject) ?? layoutSlides.GetByType(SlideLayoutType.Title); | |
if (layoutSlide == null) | |
{ | |
// The situation when a presentation doesn't contain some type of layouts. | |
// presentation File only contains Blank and Custom layout types. | |
// But layout slides with Custom types has different slide names, | |
// like "Title", "Title and Content", etc. And it is possible to use these | |
// names for layout slide selection. | |
// Also it is possible to use the set of placeholder shape types. For example, | |
// Title slide should have only Title pleceholder type, etc. | |
foreach (ILayoutSlide titleAndObjectLayoutSlide in layoutSlides) | |
{ | |
if (titleAndObjectLayoutSlide.Name == "Title and Object") | |
{ | |
layoutSlide = titleAndObjectLayoutSlide; | |
break; | |
} | |
} | |
if (layoutSlide == null) | |
{ | |
foreach (ILayoutSlide titleLayoutSlide in layoutSlides) | |
{ | |
if (titleLayoutSlide.Name == "Title") | |
{ | |
layoutSlide = titleLayoutSlide; | |
break; | |
} | |
} | |
if (layoutSlide == null) | |
{ | |
layoutSlide = layoutSlides.GetByType(SlideLayoutType.Blank); | |
if (layoutSlide == null) | |
{ | |
layoutSlide = layoutSlides.Add(SlideLayoutType.TitleAndObject, "Title and Object"); | |
} | |
} | |
} | |
} | |
// Adding empty slide with added layout slide | |
presentation.Slides.InsertEmptySlide(0, layoutSlide); | |
// Save presentation | |
presentation.Save(dataDir + "AddLayoutSlides_out.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Layout(); | |
using (Presentation presentation1 = new Presentation(dataDir + "AccessSlides.pptx")) | |
using (Presentation presentation2 = new Presentation(dataDir + "HelloWorld.pptx")) | |
{ | |
for (int i = 0; i < presentation1.Masters.Count; i++) | |
{ | |
for (int j = 0; j < presentation2.Masters.Count; j++) | |
{ | |
if (presentation1.Masters[i].Equals(presentation2.Masters[j])) | |
Console.WriteLine(string.Format("SomePresentation1 MasterSlide#{0} is equal to SomePresentation2 MasterSlide#{1}", i, j)); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Layout(); | |
// Instantiate a Presentation object that represents a presentation file | |
Presentation presentation = new Presentation(); | |
// Set SlideSize.Type Property | |
presentation.SlideSize.SetSize(SlideSizeType.A4Paper,SlideSizeScaleType.EnsureFit); | |
// Set different properties of PDF Options | |
PdfOptions opts = new PdfOptions(); | |
opts.SufficientResolution = 600; | |
// Save presentation to disk | |
presentation.Save(dataDir + "SetPDFPageSize_out.pdf", SaveFormat.Pdf, opts); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Layout(); | |
// Instantiate a Presentation object that represents a presentation file | |
Presentation presentation = new Presentation(dataDir + "AccessSlides.pptx"); | |
Presentation auxPresentation = new Presentation(); | |
ISlide slide = presentation.Slides[0]; | |
// Set the slide size of generated presentations to that of source | |
auxPresentation.SlideSize.SetSize(presentation.SlideSize.Type,SlideSizeScaleType.EnsureFit); | |
auxPresentation.Slides.InsertClone(0, slide); | |
auxPresentation.Slides.RemoveAt(0); | |
// Save Presentation to disk | |
auxPresentation.Save(dataDir + "Set_Size&Type_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Layout(); | |
// Instantiate a Presentation object that represents a presentation file | |
Presentation presentation = new Presentation(dataDir + "AccessSlides.pptx"); | |
Presentation auxPresentation = new Presentation(); | |
ISlide slide = presentation.Slides[0]; | |
// Set the slide size of generated presentations to that of source | |
presentation.SlideSize.SetSize(540, 720, SlideSizeScaleType.EnsureFit); // Method SetSize is used for set slide size with scale content to ensure fit | |
presentation.SlideSize.SetSize(SlideSizeType.A4Paper, SlideSizeScaleType.Maximize); // Method SetSize is used for set slide size with maximize size of content | |
// Save Presentation to disk | |
auxPresentation.Save(dataDir + "Set_Size&Type_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Media(); | |
string presName = dataDir + "AudioSlide.pptx"; | |
// Instantiate Presentation class that represents the presentation file | |
Presentation pres = new Presentation(presName); | |
// Access the desired slide | |
ISlide slide = pres.Slides[0]; | |
// Get the slideshow transition effects for slide | |
ISlideShowTransition transition = slide.SlideShowTransition; | |
//Extract sound in byte array | |
byte[] audio = transition.Sound.BinaryData; | |
System.Console.WriteLine("Length: " + audio.Length); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Media(); | |
// Instantiate a Presentation object that represents a presentation file | |
Presentation presentation = new Presentation(dataDir + "Video.pptx"); | |
foreach (ISlide slide in presentation.Slides) | |
{ | |
foreach (IShape shape in presentation.Slides[0].Shapes) | |
{ | |
if (shape is VideoFrame) | |
{ | |
IVideoFrame vf = shape as IVideoFrame; | |
String type = vf.EmbeddedVideo.ContentType; | |
int ss = type.LastIndexOf('/'); | |
type = type.Remove(0, type.LastIndexOf('/') + 1); | |
Byte[] buffer = vf.EmbeddedVideo.BinaryData; | |
using (FileStream stream = new FileStream(dataDir + "NewVideo_out." + type, FileMode.Create, FileAccess.Write, FileShare.Read)) | |
{ | |
stream.Write(buffer, 0, buffer.Length); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Check if source slide has notes | |
if (srcSlide.Notes != null) | |
{ | |
//Create notes page in terget slide | |
targetSlide.AddNotes(); | |
//Add each paragraph from the source notes page to the target slide notes | |
for (int j = 0; j < srcSlide.Notes.Paragraphs.Count; j++) | |
targetSlide.Notes.Paragraphs.Add(new Paragraph(srcSlide.Notes.Paragraphs[j])); | |
//Remove the default paragraph that is created on creation of the notes page | |
targetSlide.Notes.Paragraphs.RemoveAt(0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Instantiate a Presentation object that represents a presentation file | |
Presentation presentation = new Presentation(dataDir + "AccessSlides.pptx"); | |
// Removing notes of first slide | |
INotesSlideManager mgr = presentation.Slides[0].NotesSlideManager; | |
mgr.RemoveNotesSlide(); | |
// Save presentation to disk | |
presentation.Save(dataDir + "RemoveNotesAtSpecificSlide_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Notes(); | |
// Instantiate a Presentation object that represents a presentation file | |
Presentation presentation = new Presentation(dataDir + "AccessSlides.pptx"); | |
// Removing notes of all slides | |
INotesSlideManager mgr = null; | |
for (int i = 0; i < presentation.Slides.Count; i++) | |
{ | |
mgr = presentation.Slides[i].NotesSlideManager; | |
mgr.RemoveNotesSlide(); | |
} | |
// Save presentation to disk | |
presentation.Save(dataDir + "RemoveNotesFromAllSlides_out.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Thumbnail(); | |
// Instantiate a Presentation class that represents the presentation file | |
using (Presentation pres = new Presentation(dataDir + "ThumbnailFromSlide.pptx")) | |
{ | |
// Access the first slide | |
ISlide sld = pres.Slides[0]; | |
// Create a full scale image | |
Bitmap bmp = sld.GetThumbnail(1f, 1f); | |
// Save the image to disk in JPEG format | |
bmp.Save(dataDir + "Thumbnail_out.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Thumbnail(); | |
// Instantiate a Presentation class that represents the presentation file | |
using (Presentation pres = new Presentation(dataDir + "ThumbnailFromSlideInNotes.pptx")) | |
{ | |
// Access the first slide | |
ISlide sld = pres.Slides[0]; | |
// User defined dimension | |
int desiredX = 1200; | |
int desiredY = 800; | |
// Getting scaled value of X and Y | |
float ScaleX = (float)(1.0 / pres.SlideSize.Size.Width) * desiredX; | |
float ScaleY = (float)(1.0 / pres.SlideSize.Size.Height) * desiredY; | |
// Create a full scale image | |
Bitmap bmp = sld.GetThumbnail(ScaleX, ScaleY); | |
// Save the image to disk in JPEG format | |
bmp.Save(dataDir + "Notes_tnail_out.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Thumbnail(); | |
// Instantiate a Presentation class that represents the presentation file | |
using (Presentation pres = new Presentation(dataDir + "ThumbnailWithUserDefinedDimensions.pptx")) | |
{ | |
// Access the first slide | |
ISlide sld = pres.Slides[0]; | |
// User defined dimension | |
int desiredX = 1200; | |
int desiredY = 800; | |
// Getting scaled value of X and Y | |
float ScaleX = (float)(1.0 / pres.SlideSize.Size.Width) * desiredX; | |
float ScaleY = (float)(1.0 / pres.SlideSize.Size.Height) * desiredY; | |
// Create a full scale image | |
Bitmap bmp = sld.GetThumbnail(ScaleX, ScaleY); | |
// Save the image to disk in JPEG format | |
bmp.Save(dataDir + "Thumbnail2_out.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Slides_Presentations_Transitions(); | |
// Instantiate Presentation class that represents a presentation file | |
using (Presentation pres = new Presentation(dataDir + "BetterSlideTransitions.pptx")) | |
{ | |
// Apply circle type transition on slide 1 | |
pres.Slides[0].SlideShowTransition.Type = TransitionType.Circle; | |
// Set the transition time of 3 seconds | |
pres.Slides[0].SlideShowTransition.AdvanceOnClick = true; | |
pres.Slides[0].SlideShowTransition.AdvanceAfterTime = 3000; | |
// Apply comb type transition on slide 2 | |
pres.Slides[1].SlideShowTransition.Type = TransitionType.Comb; | |
// Set the transition time of 5 seconds | |
pres.Slides[1].SlideShowTransition.AdvanceOnClick = true; | |
pres.Slides[1].SlideShowTransition.AdvanceAfterTime = 5000; | |
// Apply zoom type transition on slide 3 | |
pres.Slides[2].SlideShowTransition.Type = TransitionType.Zoom; | |
// Set the transition time of 7 seconds | |
pres.Slides[2].SlideShowTransition.AdvanceOnClick = true; | |
pres.Slides[2].SlideShowTransition.AdvanceAfterTime = 7000; | |
// Write the presentation to disk | |
pres.Save(dataDir + "SampleTransition_out.pptx", SaveFormat.Pptx); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
made public