Last active
October 10, 2019 08:25
-
-
Save aspose-slides/53249e5573d2cd6e66f91f708e8fe008 to your computer and use it in GitHub Desktop.
This Gist contains .NET code snippets for examples of 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
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 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); | |
String imagePath = @"C:\Users\Public\Pictures\Sample Pictures\"; | |
//Set the picture | |
System.Drawing.Image img = (System.Drawing.Image)new Bitmap(imagePath + "Desert.jpg"); | |
IPPImage imgx1 = pres.Images.AddImage(img); | |
//Set the picture | |
System.Drawing.Image img2 = (System.Drawing.Image)new Bitmap(imagePath + "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+"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 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(); | |
// 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
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(pptxFileName, 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 | |
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(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
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+"", 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
// 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("a1.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(); | |
// 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
// 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()) | |
{ | |
// 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)); | |
series.ParentSeriesGroup.IsColorVaried = true; | |
presentation.Save("C:\\Aspose Data\\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(); | |
// 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(path + "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.IncludeComments = true; | |
htmlOptions.HtmlFormatter = HtmlFormatter.CreateCustomFormatter(new CustomFormattingController()); | |
// 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+"pres.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")) | |
{ | |
// Saving the presentation to PDF notes | |
presentation.Save(dataDir + "Pdf_Notes_out.tiff", SaveFormat.PdfNotes); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled 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); | |
auxPresentation.Save(dataDir + "PDFnotes_out.pdf", SaveFormat.PdfNotes); |
This file contains bidirectional Unicode text that may be interpreted or compiled 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.IncludeComments = true; | |
htmlOpt.HtmlFormatter = HtmlFormatter.CreateDocumentFormatter("", false); | |
// 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; | |
opts.IncludeComments = true; | |
// 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")) | |
{ | |
// Saving the presentation to TIFF notes | |
pres.Save(dataDir + "TestNotes_out.tiff", SaveFormat.TiffNotes); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled 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; | |
swfOptions.IncludeComments = true; | |
// Saving presentation and notes pages | |
presentation.Save(dataDir + "SaveAsSwf_out.swf", SaveFormat.Swf, swfOptions); | |
swfOptions.ViewerIncluded = true; | |
presentation.Save(dataDir + "SaveNotes_out.swf", SaveFormat.SwfNotes, 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(); | |
// 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; | |
pdfOptions.IncludeComments = true; | |
// 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
string dataDir = RunExamples.GetDataDir_Conversion(); | |
using (Presentation pres = new Presentation(dataDir+"pptxFileName.pptx")) | |
{ | |
using (FileStream stream = new FileStream(outputPath, 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(); | |
// 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; | |
options.IncludeComments = true; | |
/* | |
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("Presentation.pptx")) | |
{ | |
// Saving notes pages | |
pres.Save("Output.html", SaveFormat.HtmlNotes); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled 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
// 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+"Helloworld.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
// 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(); | |
// 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<InterruptionToken> action = (InterruptionToken token) => | |
{ | |
using (Presentation pres = new Presentation("pres.pptx", new LoadOptions { InterruptionToken = token })) | |
{ | |
pres.Slides[0].GetThumbnail(new Size(960, 720)); | |
pres.Save("pres.ppt", SaveFormat.Ppt); | |
} | |
}; | |
InterruptionTokenSource tokenSource = new InterruptionTokenSource(); | |
Run(action, tokenSource.Token); // run action in a separate thread from the pool | |
Thread.Sleep(5000); // some work | |
tokenSource.Interrupt(); // we don't need the result of an interruptable action | |
} | |
private static void Run(Action<InterruptionToken> action, IInterruptionToken token) | |
{ | |
throw new NotImplementedException(); | |
} | |
static void Run(Action<InterruptionToken> action, InterruptionToken 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(); | |
// 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
// 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+"test.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("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
// 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 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(); | |
// 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
// 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
// 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_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(); | |
// 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(path+"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(path+"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
// 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(daraDir + "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(); | |
// 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
// 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.NotesSlideManager.NotesSlide.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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled 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 to load the source presentation file | |
using (Presentation presentation = new Presentation(dataDir + "AccessSlides.pptx")) | |
{ | |
// Apply circle type transition on slide 1 | |
presentation.Slides[0].SlideShowTransition.Type = TransitionType.Circle; | |
// Apply comb type transition on slide 2 | |
presentation.Slides[1].SlideShowTransition.Type = TransitionType.Comb; | |
// Write the presentation to disk | |
presentation.Save(dataDir + "SampleTransition_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
// Instantiate Presentation class to load the source presentation file | |
using (Presentation presentation = new Presentation(dataDir + "AccessSlides.pptx")) | |
{ | |
// Apply circle type transition on slide 1 | |
presentation.Slides[0].SlideShowTransition.Type = TransitionType.Circle; | |
// Apply comb type transition on slide 2 | |
presentation.Slides[1].SlideShowTransition.Type = TransitionType.Comb; | |
This file contains bidirectional Unicode text that may be interpreted or compiled 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 to load the source presentation file | |
using (Presentation presentation = new Presentation(dataDir + "AccessSlides.pptx")) | |
{ | |
// Apply circle type transition on slide 1 | |
presentation.Slides[0].SlideShowTransition.Type = TransitionType.Circle; | |
// Set the transition time of 3 seconds | |
presentation.Slides[0].SlideShowTransition.AdvanceOnClick = true; | |
presentation.Slides[0].SlideShowTransition.AdvanceAfterTime = 3000; | |
// Apply comb type transition on slide 2 | |
presentation.Slides[1].SlideShowTransition.Type = TransitionType.Comb; | |
// Set the transition time of 5 seconds | |
presentation.Slides[1].SlideShowTransition.AdvanceOnClick = true; | |
presentation.Slides[1].SlideShowTransition.AdvanceAfterTime = 5000; | |
// Write the presentation to disk | |
presentation.Save("SampleTransition_out.pptx", SaveFormat.Pptx); | |
// Write the presentation to disk | |
presentation.Save(dataDir + "BetterTransitions_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_Transitions(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(dataDir + "AccessSlides.pptx"); | |
// Set effect | |
presentation.Slides[0].SlideShowTransition.Type = TransitionType.Cut; | |
((OptionalBlackTransition)presentation.Slides[0].SlideShowTransition.Value).FromBlack = true; | |
// Write the presentation to disk | |
presentation.Save(dataDir + "SetTransitionEffects_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_Transitions(); | |
// Instantiate Presentation class that represents a presentation file | |
using (Presentation pres = new Presentation(dataDir + "SimpleSlideTransitions.pptx")) | |
{ | |
// Apply circle type transition on slide 1 | |
pres.Slides[0].SlideShowTransition.Type = TransitionType.Circle; | |
// Apply comb type transition on slide 2 | |
pres.Slides[1].SlideShowTransition.Type = TransitionType.Comb; | |
// Write the presentation to disk | |
pres.Save(dataDir + "SampleTransition_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_SmartArts(); | |
// Load the desired the presentation | |
Presentation pres = new Presentation(dataDir+ "AccessChildNodes.pptx"); | |
// Traverse through every shape inside first slide | |
foreach (IShape shape in pres.Slides[0].Shapes) | |
{ | |
// Check if shape is of SmartArt type | |
if (shape is Aspose.Slides.SmartArt.SmartArt) | |
{ | |
// Typecast shape to SmartArt | |
Aspose.Slides.SmartArt.SmartArt smart = (Aspose.Slides.SmartArt.SmartArt)shape; | |
// Traverse through all nodes inside SmartArt | |
for (int i = 0; i < smart.AllNodes.Count; i++) | |
{ | |
// Accessing SmartArt node at index i | |
Aspose.Slides.SmartArt.SmartArtNode node0 = (Aspose.Slides.SmartArt.SmartArtNode)smart.AllNodes[i]; | |
// Traversing through the child nodes in SmartArt node at index i | |
for (int j = 0; j < node0.ChildNodes.Count; j++) | |
{ | |
// Accessing the child node in SmartArt node | |
Aspose.Slides.SmartArt.SmartArtNode node = (Aspose.Slides.SmartArt.SmartArtNode)node0.ChildNodes[j]; | |
// Printing the SmartArt child node parameters | |
string outString = string.Format("j = {0}, Text = {1}, Level = {2}, Position = {3}", j, node.TextFrame.Text, node.Level, node.Position); | |
Console.WriteLine(outString); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled 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_SmartArts(); | |
// 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 | |
Presentation pres = new Presentation(); | |
// Accessing the first slide | |
ISlide slide = pres.Slides[0]; | |
// Adding the SmartArt shape in first slide | |
ISmartArt smart = slide.Shapes.AddSmartArt(0, 0, 400, 400, SmartArtLayoutType.StackedList); | |
// Accessing the SmartArt node at index 0 | |
ISmartArtNode node = smart.AllNodes[0]; | |
// Accessing the child node at position 1 in parent node | |
int position = 1; | |
SmartArtNode chNode = (SmartArtNode)node.ChildNodes[position]; | |
// Printing the SmartArt child node parameters | |
string outString = string.Format("j = {0}, Text = {1}, Level = {2}, Position = {3}", position, chNode.TextFrame.Text, chNode.Level, chNode.Position); | |
Console.WriteLine(outString); |
This file contains bidirectional Unicode text that may be interpreted or compiled 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_SmartArts(); | |
// Load the desired the presentation | |
Presentation pres = new Presentation(dataDir + "AccessSmartArt.pptx"); | |
// Traverse through every shape inside first slide | |
foreach (IShape shape in pres.Slides[0].Shapes) | |
{ | |
// Check if shape is of SmartArt type | |
if (shape is Aspose.Slides.SmartArt.SmartArt) | |
{ | |
// Typecast shape to SmartArt | |
Aspose.Slides.SmartArt.SmartArt smart = (Aspose.Slides.SmartArt.SmartArt)shape; | |
// Traverse through all nodes inside SmartArt | |
for (int i = 0; i < smart.AllNodes.Count; i++) | |
{ | |
// Accessing SmartArt node at index i | |
Aspose.Slides.SmartArt.SmartArtNode node = (Aspose.Slides.SmartArt.SmartArtNode)smart.AllNodes[i]; | |
// Printing the SmartArt node parameters | |
string outString = string.Format("i = {0}, Text = {1}, Level = {2}, Position = {3}", i, node.TextFrame.Text, node.Level, node.Position); | |
Console.WriteLine(outString); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled 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_SmartArts(); | |
using (Presentation presentation = new Presentation(dataDir + "AccessSmartArtShape.pptx")) | |
{ | |
// Traverse through every shape inside first slide | |
foreach (IShape shape in presentation.Slides[0].Shapes) | |
{ | |
// Check if shape is of SmartArt type | |
if (shape is ISmartArt) | |
{ | |
// Typecast shape to SmartArtEx | |
ISmartArt smart = (ISmartArt) shape; | |
// Checking SmartArt Layout | |
if (smart.Layout == SmartArtLayoutType.BasicBlockList) | |
{ | |
Console.WriteLine("Do some thing here...."); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled 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_SmartArts(); | |
// Load the desired the presentation | |
using (Presentation pres = new Presentation(dataDir + "AccessSmartArtShape.pptx")) | |
{ | |
// Traverse through every shape inside first slide | |
foreach (IShape shape in pres.Slides[0].Shapes) | |
{ | |
// Check if shape is of SmartArt type | |
if (shape is ISmartArt) | |
{ | |
// Typecast shape to SmartArtEx | |
ISmartArt smart = (ISmartArt)shape; | |
System.Console.WriteLine("Shape Name:" + smart.Name); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled 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_SmartArts(); | |
// Load the desired the presentation// Load the desired the presentation | |
Presentation pres = new Presentation(dataDir+ "AddNodes.pptx"); | |
// Traverse through every shape inside first slide | |
foreach (IShape shape in pres.Slides[0].Shapes) | |
{ | |
// Check if shape is of SmartArt type | |
if (shape is Aspose.Slides.SmartArt.SmartArt) | |
{ | |
// Typecast shape to SmartArt | |
Aspose.Slides.SmartArt.SmartArt smart = (Aspose.Slides.SmartArt.SmartArt)shape; | |
// Adding a new SmartArt Node | |
Aspose.Slides.SmartArt.SmartArtNode TemNode = (Aspose.Slides.SmartArt.SmartArtNode)smart.AllNodes.AddNode(); | |
// Adding text | |
TemNode.TextFrame.Text = "Test"; | |
// Adding new child node in parent node. It will be added in the end of collection | |
Aspose.Slides.SmartArt.SmartArtNode newNode = (Aspose.Slides.SmartArt.SmartArtNode)TemNode.ChildNodes.AddNode(); | |
// Adding text | |
newNode.TextFrame.Text = "New Node Added"; | |
} | |
} | |
// Saving Presentation | |
pres.Save(dataDir + "AddSmartArtNode_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_SmartArts(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Creating a presentation instance | |
Presentation pres = new Presentation(); | |
// Access the presentation slide | |
ISlide slide = pres.Slides[0]; | |
// Add Smart Art IShape | |
ISmartArt smart = slide.Shapes.AddSmartArt(0, 0, 400, 400, SmartArtLayoutType.StackedList); | |
// Accessing the SmartArt node at index 0 | |
ISmartArtNode node = smart.AllNodes[0]; | |
// Adding new child node at position 2 in parent node | |
SmartArtNode chNode = (SmartArtNode)((SmartArtNodeCollection)node.ChildNodes).AddNodeByPosition(2); | |
// Add Text | |
chNode.TextFrame.Text = "Sample Text Added"; | |
// Save Presentation | |
pres.Save(dataDir + "AddSmartArtNodeByPosition_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_SmartArts(); | |
// Creating a presentation instance | |
using (Presentation pres = new Presentation(dataDir+ "AssistantNode.pptx")) | |
{ | |
// Traverse through every shape inside first slide | |
foreach (IShape shape in pres.Slides[0].Shapes) | |
{ | |
// Check if shape is of SmartArt type | |
if (shape is Aspose.Slides.SmartArt.ISmartArt) | |
{ | |
// Typecast shape to SmartArtEx | |
Aspose.Slides.SmartArt.ISmartArt smart = (Aspose.Slides.SmartArt.SmartArt)shape; | |
// Traversing through all nodes of SmartArt shape | |
foreach (Aspose.Slides.SmartArt.ISmartArtNode node in smart.AllNodes) | |
{ | |
String tc = node.TextFrame.Text; | |
// Check if node is Assitant node | |
if (node.IsAssistant) | |
{ | |
// Setting Assitant node to false and making it normal node | |
node.IsAssistant = false; | |
} | |
} | |
} | |
} | |
// Save Presentation | |
pres.Save(dataDir + "ChangeAssitantNode_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_SmartArts(); | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Add SmartArt BasicProcess | |
ISmartArt smart = presentation.Slides[0].Shapes.AddSmartArt(10, 10, 400, 300, SmartArtLayoutType.BasicBlockList); | |
// Change LayoutType to BasicProcess | |
smart.Layout = SmartArtLayoutType.BasicProcess; | |
// Saving Presentation | |
presentation.Save(dataDir + "ChangeSmartArtLayout_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_SmartArts(); | |
using (Presentation presentation = new Presentation(dataDir + "AccessSmartArtShape.pptx")) | |
{ | |
// Traverse through every shape inside first slide | |
foreach (IShape shape in presentation.Slides[0].Shapes) | |
{ | |
// Check if shape is of SmartArt type | |
if (shape is ISmartArt) | |
{ | |
// Typecast shape to SmartArtEx | |
ISmartArt smart = (ISmartArt)shape; | |
// Checking SmartArt color type | |
if (smart.ColorStyle == SmartArtColorType.ColoredFillAccent1) | |
{ | |
// Changing SmartArt color type | |
smart.ColorStyle = SmartArtColorType.ColorfulAccentColors; | |
} | |
} | |
} | |
// Saving Presentation | |
presentation.Save(dataDir + "ChangeSmartArtColorStyle_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_SmartArts(); | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Add SmartArt BasicProcess | |
ISmartArt smart = presentation.Slides[0].Shapes.AddSmartArt(10, 10, 400, 300, SmartArtLayoutType.BasicProcess); | |
// Get or Set the state of SmartArt Diagram | |
smart.IsReversed = true; | |
bool flag = smart.IsReversed; | |
// Saving Presentation | |
presentation.Save(dataDir + "ChangeSmartArtState_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_SmartArts(); | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Add SmartArt BasicProcess | |
ISmartArt smart = presentation.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]; // select second root node | |
// Setting the text of the TextFrame | |
node.TextFrame.Text = "Second root node"; | |
// Saving Presentation | |
presentation.Save(dataDir + "ChangeText_On_SmartArt_Node_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_SmartArts(); | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Add SmartArt BasicProcess | |
ISmartArt smart = presentation.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]; // select second root node | |
// Setting the text of the TextFrame | |
node.TextFrame.Text = "Second root node"; | |
// Saving Presentation | |
presentation.Save(dataDir + "ChangeText_On_SmartArt_Node_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_SmartArts(); | |
using (Presentation presentation = new Presentation(dataDir + "AccessSmartArtShape.pptx")) | |
{ | |
// Traverse through every shape inside first slide | |
foreach (IShape shape in presentation.Slides[0].Shapes) | |
{ | |
// Check if shape is of SmartArt type | |
if (shape is ISmartArt) | |
{ | |
// Typecast shape to SmartArtEx | |
ISmartArt smart = (ISmartArt)shape; | |
// Checking SmartArt style | |
if (smart.QuickStyle == SmartArtQuickStyleType.SimpleFill) | |
{ | |
// Changing SmartArt Style | |
smart.QuickStyle = SmartArtQuickStyleType.Cartoon; | |
} | |
} | |
} | |
// Saving Presentation | |
presentation.Save(dataDir + "ChangeSmartArtStyle_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_SmartArts(); | |
// 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 | |
using (Presentation pres = new Presentation()) | |
{ | |
// Access the presentation slide | |
ISlide slide = pres.Slides[0]; | |
// Add Smart Art Shape | |
ISmartArt smart = slide.Shapes.AddSmartArt(0, 0, 400, 400, SmartArtLayoutType.BasicBlockList); | |
// Saving presentation | |
pres.Save(dataDir + "SimpleSmartArt_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
string dataDir = RunExamples.GetDataDir_SmartArts(); | |
// Load the desired the presentation | |
Presentation pres = new Presentation(dataDir + "AccessChildNodes.pptx"); | |
{ | |
ISmartArt smart = pres.Slides[0].Shapes.AddSmartArt(20, 20, 600, 500, SmartArtLayoutType.OrganizationChart); | |
// Move SmartArt shape to new position | |
ISmartArtNode node = smart.AllNodes[1]; | |
ISmartArtShape shape = node.Shapes[1]; | |
shape.X += (shape.Width * 2); | |
shape.Y -= (shape.Height / 2); | |
// Change SmartArt shape's widths | |
node = smart.AllNodes[2]; | |
shape = node.Shapes[1]; | |
shape.Width += (shape.Width / 2); | |
// Change SmartArt shape's height | |
node = smart.AllNodes[3]; | |
shape = node.Shapes[1]; | |
shape.Height += (shape.Height / 2); | |
// Change SmartArt shape's rotation | |
node = smart.AllNodes[4]; | |
shape = node.Shapes[1]; | |
shape.Rotation = 90; | |
pres.Save(dataDir + "SmartArt.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_SmartArts(); | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Accessing the slide | |
ISlide slide = presentation.Slides[0]; | |
// Adding SmartArt shape and nodes | |
var chevron = slide.Shapes.AddSmartArt(10, 10, 800, 60, SmartArtLayoutType.ClosedChevronProcess); | |
var node = chevron.AllNodes.AddNode(); | |
node.TextFrame.Text = "Some text"; | |
// Setting node fill color | |
foreach (var item in node.Shapes) | |
{ | |
item.FillFormat.FillType = FillType.Solid; | |
item.FillFormat.SolidFillColor.Color = Color.Red; | |
} | |
// Saving Presentation | |
presentation.Save(dataDir + "FillFormat_SmartArt_ShapeNode_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_SmartArts(); | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Add SmartArt BasicProcess | |
ISmartArt smart = presentation.Slides[0].Shapes.AddSmartArt(10, 10, 400, 300, SmartArtLayoutType.OrganizationChart); | |
// Get or Set the organization chart type | |
smart.Nodes[0].OrganizationChartLayout = OrganizationChartLayoutType.LeftHanging; | |
// Saving Presentation | |
presentation.Save(dataDir + "OrganizeChartLayoutType_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_SmartArts(); | |
// Load the desired the presentation | |
using (Presentation pres = new Presentation(dataDir+ "RemoveNode.pptx")) | |
{ | |
// Traverse through every shape inside first slide | |
foreach (IShape shape in pres.Slides[0].Shapes) | |
{ | |
// Check if shape is of SmartArt type | |
if (shape is ISmartArt) | |
{ | |
// Typecast shape to SmartArtEx | |
ISmartArt smart = (ISmartArt)shape; | |
if (smart.AllNodes.Count > 0) | |
{ | |
// Accessing SmartArt node at index 0 | |
ISmartArtNode node = smart.AllNodes[0]; | |
// Removing the selected node | |
smart.AllNodes.RemoveNode(node); | |
} | |
} | |
} | |
// Save Presentation | |
pres.Save(dataDir + "RemoveSmartArtNode_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_SmartArts(); | |
// Load the desired the presentation | |
Presentation pres = new Presentation(dataDir + "RemoveNodeSpecificPosition.pptx"); | |
// Traverse through every shape inside first slide | |
foreach (IShape shape in pres.Slides[0].Shapes) | |
{ | |
// Check if shape is of SmartArt type | |
if (shape is Aspose.Slides.SmartArt.SmartArt) | |
{ | |
// Typecast shape to SmartArt | |
Aspose.Slides.SmartArt.SmartArt smart = (Aspose.Slides.SmartArt.SmartArt)shape; | |
if (smart.AllNodes.Count > 0) | |
{ | |
// Accessing SmartArt node at index 0 | |
Aspose.Slides.SmartArt.ISmartArtNode node = smart.AllNodes[0]; | |
if (node.ChildNodes.Count >= 2) | |
{ | |
// Removing the child node at position 1 | |
((Aspose.Slides.SmartArt.SmartArtNodeCollection)node.ChildNodes).RemoveNode(1); | |
} | |
} | |
} | |
} | |
// Save Presentation | |
pres.Save(dataDir + "RemoveSmartArtNodeByPosition_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_Tables(); | |
// Instantiate Presentation class object | |
Presentation presentation = new Presentation(); | |
// Access first slide | |
ISlide islide = presentation.Slides[0]; | |
// Define columns with widths and rows with heights | |
double[] dblCols = { 150, 150, 150, 150 }; | |
double[] dblRows = { 100, 100, 100, 100, 90 }; | |
// Add table shape to slide | |
ITable tbl = islide.Shapes.AddTable(50, 50, dblCols, dblRows); | |
// Creating a Bitmap Image object to hold the image file | |
Bitmap image = new Bitmap(dataDir + "aspose-logo.jpg"); | |
// Create an IPPImage object using the bitmap object | |
IPPImage imgx1 = presentation.Images.AddImage(image); | |
// Add image to first table cell | |
tbl[0, 0].FillFormat.FillType = FillType.Picture; | |
tbl[0, 0].FillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Stretch; | |
tbl[0, 0].FillFormat.PictureFillFormat.Picture.Image = imgx1; | |
// Save PPTX to Disk | |
presentation.Save(dataDir + "Image_In_TableCell_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_Tables(); | |
// Instantiate Presentation class object | |
Presentation presentation = new Presentation(); | |
// Access first slide | |
ISlide islide = presentation.Slides[0]; | |
// Define columns with widths and rows with heights | |
double[] dblCols = { 150, 150, 150, 150 }; | |
double[] dblRows = { 100, 100, 100, 100, 90 }; | |
// Add table shape to slide | |
ITable tbl = islide.Shapes.AddTable(50, 50, dblCols, dblRows); | |
// Creating a Bitmap Image object to hold the image file | |
Bitmap image = new Bitmap(dataDir + "aspose-logo.jpg"); | |
// Create an IPPImage object using the bitmap object | |
IPPImage imgx1 = presentation.Images.AddImage(image); | |
// Add image to first table cell | |
tbl[0, 0].FillFormat.FillType = FillType.Picture; | |
tbl[0, 0].FillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Stretch; | |
tbl[0, 0].FillFormat.PictureFillFormat.Picture.Image = imgx1; | |
tbl[0, 0].FillFormat.PictureFillFormat.CropRight = 20; | |
tbl[0, 0].FillFormat.PictureFillFormat.CropLeft = 20; | |
tbl[0, 0].FillFormat.PictureFillFormat.CropTop = 20; | |
tbl[0, 0].FillFormat.PictureFillFormat.Bottom = 20; | |
// Save PPTX to Disk | |
presentation.Save(dataDir + "Image_In_TableCell_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_Tables(); | |
// Instantiate Presentation class that represents PPTX file | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Access first slide | |
ISlide slide = presentation.Slides[0]; | |
// Define columns with widths and rows with heights | |
double[] dblCols = { 70, 70, 70, 70 }; | |
double[] dblRows = { 70, 70, 70, 70 }; | |
// Add table shape to slide | |
ITable table = slide.Shapes.AddTable(100, 50, dblCols, dblRows); | |
// Set border format for each cell | |
foreach (IRow row in table.Rows) | |
{ | |
foreach (ICell cell in row) | |
{ | |
cell.BorderTop.FillFormat.FillType = FillType.Solid; | |
cell.BorderTop.FillFormat.SolidFillColor.Color = Color.Red; | |
cell.BorderTop.Width = 5; | |
cell.BorderBottom.FillFormat.FillType = FillType.Solid; | |
cell.BorderBottom.FillFormat.SolidFillColor.Color = Color.Red; | |
cell.BorderBottom.Width = 5; | |
cell.BorderLeft.FillFormat.FillType = FillType.Solid; | |
cell.BorderLeft.FillFormat.SolidFillColor.Color = Color.Red; | |
cell.BorderLeft.Width = 5; | |
cell.BorderRight.FillFormat.FillType = FillType.Solid; | |
cell.BorderRight.FillFormat.SolidFillColor.Color = Color.Red; | |
cell.BorderRight.Width = 5; | |
} | |
} | |
// Merging cells (1, 1) x (2, 1) | |
table.MergeCells(table[1, 1], table[2, 1], false); | |
// Merging cells (1, 2) x (2, 2) | |
table.MergeCells(table[1, 2], table[2, 2], false); | |
// split cell (1, 1). | |
table[1, 1].SplitByWidth(table[2, 1].Width / 2); | |
//Write PPTX to Disk | |
presentation.Save(dataDir + "CellSplit_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_Tables(); | |
// Instantiate presentationentation class that representationents PPTX file | |
using (Presentation presentation = new Presentation(dataDir+"Test.pptx")) | |
{ | |
// Access first slide | |
ISlide sld = presentation.Slides[0]; | |
// Define columns with widths and rows with heights | |
double[] dblCols = { 50, 50, 50 }; | |
double[] dblRows = { 50, 30, 30, 30, 30 }; | |
// Add table shape to slide | |
ITable table = sld.Shapes.AddTable(100, 50, dblCols, dblRows); | |
// Add text to the row 1 cell 1 | |
table[0, 0].TextFrame.Text = "Row 1 Cell 1"; | |
// Add text to the row 1 cell 2 | |
table[1, 0].TextFrame.Text = "Row 1 Cell 2"; | |
// Clone Row 1 at end of table | |
table.Rows.AddClone(table.Rows[0], false); | |
// Add text to the row 2 cell 1 | |
table[0, 1].TextFrame.Text = "Row 2 Cell 1"; | |
// Add text to the row 2 cell 2 | |
table[1, 1].TextFrame.Text = "Row 2 Cell 2"; | |
// Clone Row 2 as 4th row of table | |
table.Rows.InsertClone(3,table.Rows[1], false); | |
//Cloning first column at end | |
table.Columns.AddClone(table.Columns[0], false); | |
//Cloning 2nd column at 4th column index | |
table.Columns.InsertClone(3,table.Columns[1], false); | |
// Write PPTX to Disk | |
presentation.Save(dataDir + "table_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_Tables(); | |
using (Presentation pres = new Presentation(dataDir + "SomePresentationWithTable.pptx")) | |
{ | |
ITable table = pres.Slides[0].Shapes[0] as ITable; // assuming that Slide#0.Shape#0 is a table | |
for (int i = 0; i < table.Rows.Count; i++) | |
{ | |
for (int j = 0; j < table.Columns.Count; j++) | |
{ | |
ICell currentCell = table.Rows[i][j]; | |
if (currentCell.IsMergedCell) | |
{ | |
Console.WriteLine(string.Format("Cell {0};{1} is a part of merged cell with RowSpan={2} and ColSpan={3} starting from Cell {4};{5}.", | |
i, j, currentCell.RowSpan, currentCell.ColSpan, currentCell.FirstRowIndex, currentCell.FirstColumnIndex)); | |
} | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled 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_Tables(); | |
// Instantiate Presentation class that represents PPTX file | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Access first slide | |
ISlide slide = presentation.Slides[0]; | |
// Define columns with widths and rows with heights | |
double[] dblCols = { 70, 70, 70, 70 }; | |
double[] dblRows = { 70, 70, 70, 70 }; | |
// Add table shape to slide | |
ITable table = slide.Shapes.AddTable(100, 50, dblCols, dblRows); | |
// Set border format for each cell | |
foreach (IRow row in table.Rows) | |
{ | |
foreach (ICell cell in row) | |
{ | |
cell.BorderTop.FillFormat.FillType = FillType.Solid; | |
cell.BorderTop.FillFormat.SolidFillColor.Color = Color.Red; | |
cell.BorderTop.Width = 5; | |
cell.BorderBottom.FillFormat.FillType = FillType.Solid; | |
cell.BorderBottom.FillFormat.SolidFillColor.Color = Color.Red; | |
cell.BorderBottom.Width = 5; | |
cell.BorderLeft.FillFormat.FillType = FillType.Solid; | |
cell.BorderLeft.FillFormat.SolidFillColor.Color = Color.Red; | |
cell.BorderLeft.Width = 5; | |
cell.BorderRight.FillFormat.FillType = FillType.Solid; | |
cell.BorderRight.FillFormat.SolidFillColor.Color = Color.Red; | |
cell.BorderRight.Width = 5; | |
} | |
} | |
// Merging cells (1, 1) x (2, 1) | |
table.MergeCells(table[1, 1], table[2, 1], false); | |
// Merging cells (1, 2) x (2, 2) | |
table.MergeCells(table[1, 2], table[2, 2], false); | |
// Merging cells (1, 2) x (2, 2) | |
table.MergeCells(table[1, 1], table[1, 2], true); | |
//Write PPTX to Disk | |
presentation.Save(dataDir + "MergeCells1_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_Tables(); | |
// Instantiate Presentation class that represents PPTX file | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Access first slide | |
ISlide sld = presentation.Slides[0]; | |
// Define columns with widths and rows with heights | |
double[] dblCols = { 70, 70, 70, 70 }; | |
double[] dblRows = { 70, 70, 70, 70 }; | |
// Add table shape to slide | |
ITable tbl = sld.Shapes.AddTable(100, 50, dblCols, dblRows); | |
// Set border format for each cell | |
foreach (IRow row in tbl.Rows) | |
{ | |
foreach (ICell cell in row) | |
{ | |
cell.BorderTop.FillFormat.FillType = FillType.Solid; | |
cell.BorderTop.FillFormat.SolidFillColor.Color = Color.Red; | |
cell.BorderTop.Width = 5; | |
cell.BorderBottom.FillFormat.FillType = FillType.Solid; | |
cell.BorderBottom.FillFormat.SolidFillColor.Color = Color.Red; | |
cell.BorderBottom.Width = 5; | |
cell.BorderLeft.FillFormat.FillType = FillType.Solid; | |
cell.BorderLeft.FillFormat.SolidFillColor.Color = Color.Red; | |
cell.BorderLeft.Width = 5; | |
cell.BorderRight.FillFormat.FillType = FillType.Solid; | |
cell.BorderRight.FillFormat.SolidFillColor.Color = Color.Red; | |
cell.BorderRight.Width = 5; | |
} | |
} | |
// Merging cells (1, 1) x (2, 1) | |
tbl.MergeCells(tbl[1, 1], tbl[2, 1], false); | |
// Merging cells (1, 2) x (2, 2) | |
tbl.MergeCells(tbl[1, 2], tbl[2, 2], false); | |
presentation.Save(dataDir + "MergeCells_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_Tables(); | |
// 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]; | |
double[] colWidth = { 100, 50, 30 }; | |
double[] rowHeight = { 30, 50, 30 }; | |
ITable table = slide.Shapes.AddTable(100, 100, colWidth, rowHeight); | |
table.Rows.RemoveAt(1, false); | |
table.Columns.RemoveAt(1, false); | |
pres.Save(dataDir + "TestTable_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_Tables(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(); | |
ISlide slide = presentation.Slides[0]; | |
ITable someTable = presentation.Slides[0].Shapes[0] as ITable; // let's say that the first shape on the first slide is a table | |
// setting table cells' font height | |
PortionFormat portionFormat = new PortionFormat(); | |
portionFormat.FontHeight = 25; | |
someTable.SetTextFormat(portionFormat); | |
// setting table cells' text alignment and right margin in one call | |
ParagraphFormat paragraphFormat = new ParagraphFormat(); | |
paragraphFormat.Alignment = TextAlignment.Right; | |
paragraphFormat.MarginRight = 20; | |
someTable.SetTextFormat(paragraphFormat); | |
// setting table cells' text vertical type | |
TextFrameFormat textFrameFormat = new TextFrameFormat(); | |
textFrameFormat.TextVerticalType = TextVerticalType.Vertical; | |
someTable.SetTextFormat(textFrameFormat); | |
presentation.Save(path + "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_Tables(); | |
// Instantiate Presentation class that represents PPTX file | |
using (Presentation pres = new Presentation()) | |
{ | |
// Access first slide | |
ISlide sld = pres.Slides[0]; | |
// Define columns with widths and rows with heights | |
double[] dblCols = { 70, 70, 70, 70 }; | |
double[] dblRows = { 70, 70, 70, 70 }; | |
// Add table shape to slide | |
ITable tbl = sld.Shapes.AddTable(100, 50, dblCols, dblRows); | |
// Set border format for each cell | |
foreach (IRow row in tbl.Rows) | |
{ | |
foreach (ICell cell in row) | |
{ | |
cell.BorderTop.FillFormat.FillType = FillType.Solid; | |
cell.BorderTop.FillFormat.SolidFillColor.Color = Color.Red; | |
cell.BorderTop.Width = 5; | |
cell.BorderBottom.FillFormat.FillType = FillType.Solid; | |
cell.BorderBottom.FillFormat.SolidFillColor.Color = Color.Red; | |
cell.BorderBottom.Width = 5; | |
cell.BorderLeft.FillFormat.FillType = FillType.Solid; | |
cell.BorderLeft.FillFormat.SolidFillColor.Color = Color.Red; | |
cell.BorderLeft.Width = 5; | |
cell.BorderRight.FillFormat.FillType = FillType.Solid; | |
cell.BorderRight.FillFormat.SolidFillColor.Color = Color.Red; | |
cell.BorderRight.Width = 5; | |
} | |
} | |
//Write PPTX to Disk | |
pres.Save(dataDir + "StandardTables_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_Tables(); | |
// Instantiate Presentation class that represents PPTX// Instantiate Presentation class that represents PPTX | |
using (Presentation presentation = new Presentation(dataDir + "UpdateExistingTable.pptx")) | |
{ | |
// Access the first slide | |
ISlide sld = presentation.Slides[0]; | |
// Initialize null TableEx | |
ITable table = null; | |
// Iterate through the shapes and set a reference to the table found | |
foreach (IShape shape in sld.Shapes) | |
if (shape is ITable) | |
table = (ITable)shape; | |
// Set the text of the first column of second row | |
table[0, 1].TextFrame.Text = "New"; | |
// Write the PPTX to Disk | |
presentation.Save(dataDir + "UpdateTable_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_Tables(); | |
// 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 | |
using (Presentation pres = new Presentation()) | |
{ | |
// Access first slide | |
Slide sld = (Slide)pres.Slides[0]; | |
// Define columns with widths and rows with heights | |
double[] dblCols = { 50, 50, 50, 50 }; | |
double[] dblRows = { 50, 30, 30, 30, 30 }; | |
// Add table shape to slide | |
// Add table shape to slide | |
ITable tbl = sld.Shapes.AddTable(100, 50, dblCols, dblRows); | |
// Set border format for each cell | |
foreach (IRow row in tbl.Rows) | |
foreach (ICell cell in row) | |
{ | |
cell.BorderTop.FillFormat.FillType = FillType.NoFill; | |
cell.BorderBottom.FillFormat.FillType = FillType.NoFill; | |
cell.BorderLeft.FillFormat.FillType = FillType.NoFill; | |
cell.BorderRight.FillFormat.FillType = FillType.NoFill; | |
} | |
//Write PPTX to Disk | |
pres.Save(dataDir + "table_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_Tables(); | |
// Create an instance of Presentation class | |
Presentation pres = new Presentation(); | |
ISlide slide = pres.Slides[0]; | |
ITable someTable = pres.Slides[0].Shapes[0] as ITable; // let's say that the first shape on the first slide is a table | |
// setting first column cells' font height | |
PortionFormat portionFormat = new PortionFormat(); | |
portionFormat.FontHeight = 25; | |
someTable.Columns[0].SetTextFormat(portionFormat); | |
// setting first column cells' text alignment and right margin in one call | |
ParagraphFormat paragraphFormat = new ParagraphFormat(); | |
paragraphFormat.Alignment = TextAlignment.Right; | |
paragraphFormat.MarginRight = 20; | |
someTable.Columns[0].SetTextFormat(paragraphFormat); | |
// setting second column cells' text vertical type | |
TextFrameFormat textFrameFormat = new TextFrameFormat(); | |
textFrameFormat.TextVerticalType = TextVerticalType.Vertical; | |
someTable.Columns[1].SetTextFormat(textFrameFormat); | |
pres.Save(path + "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_Tables(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(); | |
ISlide slide = presentation.Slides[0]; | |
ITable someTable = presentation.Slides[0].Shapes[0] as ITable; // let's say that the first shape on the first slide is a table | |
// setting first row cells' font height | |
PortionFormat portionFormat = new PortionFormat(); | |
portionFormat.FontHeight = 25; | |
someTable.Rows[0].SetTextFormat(portionFormat); | |
// setting first row cells' text alignment and right margin in one call | |
ParagraphFormat paragraphFormat = new ParagraphFormat(); | |
paragraphFormat.Alignment = TextAlignment.Right; | |
paragraphFormat.MarginRight = 20; | |
someTable.Rows[0].SetTextFormat(paragraphFormat); | |
// setting second row cells' text vertical type | |
TextFrameFormat textFrameFormat = new TextFrameFormat(); | |
textFrameFormat.TextVerticalType = TextVerticalType.Vertical; | |
someTable.Rows[1].SetTextFormat(textFrameFormat); | |
presentation.Save(path + "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_Tables(); | |
// Instantiate Presentation class that represents PPTX// Instantiate Presentation class that represents PPTX | |
using (Presentation pres = new Presentation(dataDir + "UpdateExistingTable.pptx")) | |
{ | |
// Access the first slide | |
ISlide sld = pres.Slides[0]; | |
// Initialize null TableEx | |
ITable tbl = null; | |
// Iterate through the shapes and set a reference to the table found | |
foreach (IShape shp in sld.Shapes) | |
if (shp is ITable) | |
tbl = (ITable)shp; | |
// Set the text of the first column of second row | |
tbl[0, 1].TextFrame.Text = "New"; | |
//Write the PPTX to Disk | |
pres.Save(dataDir + "table1_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_Tables(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(); | |
// Get the first slide | |
ISlide slide = presentation.Slides[0]; | |
// Define columns with widths and rows with heights | |
double[] dblCols = { 120, 120, 120, 120 }; | |
double[] dblRows = { 100, 100, 100, 100 }; | |
// Add table shape to slide | |
ITable tbl = slide.Shapes.AddTable(100, 50, dblCols, dblRows); | |
tbl[1, 0].TextFrame.Text = "10"; | |
tbl[2, 0].TextFrame.Text = "20"; | |
tbl[3, 0].TextFrame.Text = "30"; | |
// Accessing the text frame | |
ITextFrame txtFrame = tbl[0, 0].TextFrame; | |
// Create the Paragraph object for text frame | |
IParagraph paragraph = txtFrame.Paragraphs[0]; | |
// Create Portion object for paragraph | |
IPortion portion = paragraph.Portions[0]; | |
portion.Text = "Text here"; | |
portion.PortionFormat.FillFormat.FillType = FillType.Solid; | |
portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black; | |
// Aligning the text vertically | |
ICell cell = tbl[0, 0]; | |
cell.TextAnchorType = TextAnchorType.Center; | |
cell.TextVerticalType = TextVerticalType.Vertical270; | |
// Save Presentation | |
presentation.Save(dataDir + "Vertical_Align_Text_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_Text(); | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Get the first slide of presentation | |
ISlide slide = presentation.Slides[0]; | |
// Add an AutoShape of Rectangle type | |
IAutoShape aShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 300, 300); | |
// Add TextFrame to the Rectangle | |
aShape.AddTextFrame("All these columns are limited to be within a single text container -- " + | |
"you can add or delete text and the new or remaining text automatically adjusts " + | |
"itself to flow within the container. You cannot have text flow from one container " + | |
"to other though -- we told you PowerPoint's column options for text are limited!"); | |
// Get text format of TextFrame | |
ITextFrameFormat format = aShape.TextFrame.TextFrameFormat; | |
// Specify number of columns in TextFrame | |
format.ColumnCount = 3; | |
// Specify spacing between columns | |
format.ColumnSpacing = 10; | |
// Save created presentation | |
presentation.Save("ColumnCount.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_Text(); | |
// Load presentation | |
Presentation presentation = new Presentation(dataDir + "Fonts.pptx"); | |
// Load source font to be replaced | |
IFontData sourceFont = new FontData("Arial"); | |
IFontData[] allFonts = presentation.FontsManager.GetFonts(); | |
IFontData[] embeddedFonts = presentation.FontsManager.GetEmbeddedFonts(); | |
foreach (IFontData font in allFonts) | |
{ | |
if (!embeddedFonts.Contains(font)) | |
{ | |
presentation.FontsManager.AddEmbeddedFont(font, EmbedFontCharacters.All); | |
} | |
} | |
// Save the presentation | |
presentation.Save(dataDir + "AddEmbeddedFont_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_Text(); | |
using (Presentation presentation = new Presentation(dataDir+"test.pptx")) | |
{ | |
// Get slide | |
ISlide slide = presentation.Slides[0]; | |
// Create text box | |
IAutoShape shape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 200, 100); | |
ITextFrame textFrame = shape.TextFrame; | |
textFrame.Paragraphs.Clear(); | |
// Create paragraph for superscript text | |
IParagraph superPar = new Paragraph(); | |
// Create portion with usual text | |
IPortion portion1 = new Portion(); | |
portion1.Text = "SlideTitle"; | |
superPar.Portions.Add(portion1); | |
// Create portion with superscript text | |
IPortion superPortion = new Portion(); | |
superPortion.PortionFormat.Escapement = 30; | |
superPortion.Text = "TM"; | |
superPar.Portions.Add(superPortion); | |
// Create paragraph for subscript text | |
IParagraph paragraph2 = new Paragraph(); | |
// Create portion with usual text | |
IPortion portion2 = new Portion(); | |
portion2.Text = "a"; | |
paragraph2.Portions.Add(portion2); | |
// Create portion with subscript text | |
IPortion subPortion = new Portion(); | |
subPortion.PortionFormat.Escapement = -25; | |
subPortion.Text = "i"; | |
paragraph2.Portions.Add(subPortion); | |
// Add paragraphs to text box | |
textFrame.Paragraphs.Add(superPar); | |
textFrame.Paragraphs.Add(paragraph2); | |
presentation.Save(dataDir+"TestOut.pptx", SaveFormat.Pptx); | |
System.Diagnostics.Process.Start(dataDir + "TestOut.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_Text(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate PresentationEx// Instantiate PresentationEx | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get the first slide | |
ISlide sld = pres.Slides[0]; | |
// Add an AutoShape of Rectangle type | |
IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 75, 150, 50); | |
// Add TextFrame to the Rectangle | |
ashp.AddTextFrame(" "); | |
// Accessing the text frame | |
ITextFrame txtFrame = ashp.TextFrame; | |
// Create the Paragraph object for text frame | |
IParagraph para = txtFrame.Paragraphs[0]; | |
// Create Portion object for paragraph | |
IPortion portion = para.Portions[0]; | |
// Set Text | |
portion.Text = "Aspose TextBox"; | |
// Save the presentation to disk | |
pres.Save(dataDir + "ApplyInnerShadow_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_Text(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(); | |
// Get reference of a slide | |
ISlide slide = presentation.Slides[0]; | |
// Add an AutoShape of Rectangle type | |
IAutoShape ashp = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 75, 400, 300); | |
ashp.FillFormat.FillType = FillType.NoFill; | |
// Add TextFrame to the Rectangle | |
ashp.AddTextFrame("Aspose TextBox"); | |
IPortion port = ashp.TextFrame.Paragraphs[0].Portions[0]; | |
IPortionFormat pf = port.PortionFormat; | |
pf.FontHeight = 50; | |
// Enable InnerShadowEffect | |
IEffectFormat ef = pf.EffectFormat; | |
ef.EnableInnerShadowEffect(); | |
// Set all necessary parameters | |
ef.InnerShadowEffect.BlurRadius = 8.0; | |
ef.InnerShadowEffect.Direction = 90.0F; | |
ef.InnerShadowEffect.Distance = 6.0; | |
ef.InnerShadowEffect.ShadowColor.B = 189; | |
// Set ColorType as Scheme | |
ef.InnerShadowEffect.ShadowColor.ColorType = ColorType.Scheme; | |
// Set Scheme Color | |
ef.InnerShadowEffect.ShadowColor.SchemeColor = SchemeColor.Accent1; | |
// Save Presentation | |
presentation.Save(dataDir + "WordArt_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_Text(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(); | |
IChart chart = presentation.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 50, 50, 500, 300); | |
IChartSeries series = chart.ChartData.Series[0]; | |
series.Labels.DefaultDataLabelFormat.ShowValue = true; | |
series.Labels.DefaultDataLabelFormat.TextFormat.TextBlockFormat.RotationAngle = 65; | |
chart.HasTitle = true; | |
chart.ChartTitle.AddTextFrameForOverriding("Custom title").TextFrameFormat.RotationAngle = -30; | |
// Save Presentation | |
presentation.Save(dataDir + "textframe-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_Text(); | |
// Use load options to define the default regualr and asian fonts// Use load options to define the default regualr and asian fonts | |
LoadOptions loadOptions = new LoadOptions(LoadFormat.Auto); | |
loadOptions.DefaultRegularFont = "Wingdings"; | |
loadOptions.DefaultAsianFont = "Wingdings"; | |
// Load the presentation | |
using (Presentation pptx = new Presentation(dataDir + "DefaultFonts.pptx", loadOptions)) | |
{ | |
// Generate slide thumbnail | |
pptx.Slides[0].GetThumbnail(1, 1).Save(dataDir + "output_out.png", ImageFormat.Png); | |
// Generate PDF | |
pptx.Save(dataDir + "output_out.pdf", SaveFormat.Pdf); | |
// Generate XPS | |
pptx.Save(dataDir + "output_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
string dataDir = RunExamples.GetDataDir_Charts(); | |
using (Presentation pres = new Presentation(dataDir + "Test.pptx")) | |
{ | |
ISequence sequence = pres.Slides[0].Timeline.MainSequence; | |
IAutoShape autoShape = (IAutoShape)pres.Slides[0].Shapes[1]; | |
foreach (IParagraph paragraph in autoShape.TextFrame.Paragraphs) | |
{ | |
IEffect[] effects = sequence.GetEffectsByParagraph(paragraph); | |
if (effects.Length > 0) | |
Console.WriteLine("Paragraph \"" + paragraph.Text + "\" has " + effects[0].Type + " effect."); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled 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_Text(); | |
using (Presentation pres = new Presentation(dataDir+"pres.pptx")) | |
{ | |
// exclude default presentation fonts | |
string[] fontNameExcludeList = { "Calibri", "Arial" }; | |
EmbedAllFontsHtmlController embedFontsController = new EmbedAllFontsHtmlController(fontNameExcludeList); | |
HtmlOptions htmlOptionsEmbed = new HtmlOptions | |
{ | |
HtmlFormatter = HtmlFormatter.CreateCustomFormatter(embedFontsController) | |
}; | |
pres.Save(dataDir+"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_Text(); | |
using (Presentation pres = new Presentation(dataDir+"Test.pptx")) | |
{ | |
IAutoShape shape = pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 200, 250); | |
Paragraph para1 = new Paragraph(); | |
para1.Portions.Add(new Portion("Sample text")); | |
Paragraph para2 = new Paragraph(); | |
para2.Portions.Add(new Portion("Sample text 2")); | |
PortionFormat endParagraphPortionFormat = new PortionFormat(); | |
endParagraphPortionFormat.FontHeight = 48; | |
endParagraphPortionFormat.LatinFont = new FontData("Times New Roman"); | |
para2.EndParagraphPortionFormat = endParagraphPortionFormat; | |
shape.TextFrame.Paragraphs.Add(para1); | |
shape.TextFrame.Paragraphs.Add(para2); | |
pres.Save(dataDir+"pres.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_Text(); | |
// Load the presentation file | |
using (Presentation pres = new Presentation(dataDir + "ExportingHTMLText.pptx")) | |
{ | |
// Acesss the default first slide of presentation | |
ISlide slide = pres.Slides[0]; | |
// Desired index | |
int index = 0; | |
// Accessing the added shape | |
IAutoShape ashape = (IAutoShape)slide.Shapes[index]; | |
StreamWriter sw = new StreamWriter(dataDir + "output_out.html", false, Encoding.UTF8); | |
//Writing Paragraphs data to HTML by providing paragraph starting index, total paragraphs to be copied | |
sw.Write(ashape.TextFrame.Paragraphs.ExportToHtml(0, ashape.TextFrame.Paragraphs.Count, null)); | |
sw.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_Text(); | |
// 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 | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get first slide | |
ISlide sld = pres.Slides[0]; | |
// Add an AutoShape of Rectangle type | |
IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 50, 200, 50); | |
// Remove any fill style associated with the AutoShape | |
ashp.FillFormat.FillType = FillType.NoFill; | |
// Access the TextFrame associated with the AutoShape | |
ITextFrame tf = ashp.TextFrame; | |
tf.Text = "Aspose TextBox"; | |
// Access the Portion associated with the TextFrame | |
IPortion port = tf.Paragraphs[0].Portions[0]; | |
// Set the Font for the Portion | |
port.PortionFormat.LatinFont = new FontData("Times New Roman"); | |
// Set Bold property of the Font | |
port.PortionFormat.FontBold = NullableBool.True; | |
// Set Italic property of the Font | |
port.PortionFormat.FontItalic = NullableBool.True; | |
// Set Underline property of the Font | |
port.PortionFormat.FontUnderline = TextUnderlineType.Single; | |
// Set the Height of the Font | |
port.PortionFormat.FontHeight = 25; | |
// Set the color of the Font | |
port.PortionFormat.FillFormat.FillType = FillType.Solid; | |
port.PortionFormat.FillFormat.SolidFillColor.Color = Color.Blue; | |
//Write the presentation to disk | |
pres.Save(dataDir + "pptxFont_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_Text(); | |
// Instantiate a Presentation object that represents a PPTX file// Instantiate a Presentation object that represents a PPTX file | |
using (Presentation pres = new Presentation(dataDir + "FontProperties.pptx")) | |
{ | |
// Accessing a slide using its slide position | |
ISlide slide = pres.Slides[0]; | |
// Accessing the first and second placeholder in the slide and typecasting it as AutoShape | |
ITextFrame tf1 = ((IAutoShape)slide.Shapes[0]).TextFrame; | |
ITextFrame tf2 = ((IAutoShape)slide.Shapes[1]).TextFrame; | |
// Accessing the first Paragraph | |
IParagraph para1 = tf1.Paragraphs[0]; | |
IParagraph para2 = tf2.Paragraphs[0]; | |
// Accessing the first portion | |
IPortion port1 = para1.Portions[0]; | |
IPortion port2 = para2.Portions[0]; | |
// Define new fonts | |
FontData fd1 = new FontData("Elephant"); | |
FontData fd2 = new FontData("Castellar"); | |
// Assign new fonts to portion | |
port1.PortionFormat.LatinFont = fd1; | |
port2.PortionFormat.LatinFont = fd2; | |
// Set font to Bold | |
port1.PortionFormat.FontBold = NullableBool.True; | |
port2.PortionFormat.FontBold = NullableBool.True; | |
// Set font to Italic | |
port1.PortionFormat.FontItalic = NullableBool.True; | |
port2.PortionFormat.FontItalic = NullableBool.True; | |
// Set font color | |
port1.PortionFormat.FillFormat.FillType = FillType.Solid; | |
port1.PortionFormat.FillFormat.SolidFillColor.Color = Color.Purple; | |
port2.PortionFormat.FillFormat.FillType = FillType.Solid; | |
port2.PortionFormat.FillFormat.SolidFillColor.Color = Color.Peru; | |
//Write the PPTX to disk | |
pres.Save(dataDir + "WelcomeFont_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_Text(); | |
//The following line shall return folders where font files are searched. | |
//Those are folders that have been added with LoadExternalFonts method as well as system font folders. | |
string[] fontFolders = FontsLoader.GetFontFolders(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled 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_Text(); | |
using (Presentation pres = new Presentation("Presentation.pptx")) | |
{ | |
ISlide slide = presentation.Slides[0]; | |
ISmartArt smartArt = (ISmartArt)slide.Shapes[0]; | |
ISmartArtNodeCollection smartArtNodes = smartArt.AllNodes; | |
foreach (ISmartArtNode smartArtNode in smartArtNodes) | |
{ | |
foreach (ISmartArtShape nodeShape in smartArtNode.Shapes) | |
{ | |
if (nodeShape.TextFrame != null) | |
Console.WriteLine(nodeShape.TextFrame.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_Text(); | |
// Create Empty presentation instance// Create Empty presentation instance | |
using (Presentation pres = new Presentation()) | |
{ | |
// Acesss the default first slide of presentation | |
ISlide slide = pres.Slides[0]; | |
// Adding the AutoShape to accomodate the HTML content | |
IAutoShape ashape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, pres.SlideSize.Size.Width - 20, pres.SlideSize.Size.Height - 10); | |
ashape.FillFormat.FillType = FillType.NoFill; | |
// Adding text frame to the shape | |
ashape.AddTextFrame(""); | |
// Clearing all paragraphs in added text frame | |
ashape.TextFrame.Paragraphs.Clear(); | |
// Loading the HTML file using stream reader | |
TextReader tr = new StreamReader(dataDir + "file.html"); | |
// Adding text from HTML stream reader in text frame | |
ashape.TextFrame.Paragraphs.AddFromHtml(tr.ReadToEnd()); | |
// Saving Presentation | |
pres.Save(dataDir + "output_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_Text(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(dataDir + "Fonts.pptx"); | |
// Obtain a slide's reference by its index | |
ISlide sld = presentation.Slides[0]; | |
// Access the TextFrame | |
ITextFrame tf1 = ((IAutoShape)sld.Shapes[0]).TextFrame; | |
// Access the Paragraph | |
IParagraph para1 = tf1.Paragraphs[0]; | |
// Set properties of Paragraph | |
para1.ParagraphFormat.SpaceWithin = 80; | |
para1.ParagraphFormat.SpaceBefore = 40; | |
para1.ParagraphFormat.SpaceAfter = 40; | |
// Save Presentation | |
presentation.Save(dataDir + "LineSpacing_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_Text(); | |
// loading presentation uses SomeFont which is not installed on the system | |
using(Presentation pres = new Presentation("pres.pptx") | |
{ | |
// load SomeFont from file into the byte array | |
byte[] fontData = File.ReadAllBytes(@"fonts\SomeFont.ttf"); | |
// load font represented as byte array | |
FontsLoader.LoadExternalFont(fontData); | |
// font SomeFont will be available during the rendering or other operations | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled 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_Text(); | |
// Instantiate a Presentation object that represents a presentation file | |
using (Presentation presentation = new Presentation(dataDir + "EmbeddedFonts.pptx")) | |
{ | |
// render a slide that contains a text frame that uses embedded "FunSized" | |
presentation.Slides[0].GetThumbnail(new Size(960, 720)).Save(dataDir + "picture1_out.png", ImageFormat.Png); | |
IFontsManager fontsManager = presentation.FontsManager; | |
// get all embedded fonts | |
IFontData[] embeddedFonts = fontsManager.GetEmbeddedFonts(); | |
// find "Calibri" font | |
IFontData funSizedEmbeddedFont = Array.Find(embeddedFonts, delegate(IFontData data) | |
{ | |
return data.FontName == "Calibri"; | |
}); | |
// remove "Calibri" font | |
fontsManager.RemoveEmbeddedFont(funSizedEmbeddedFont); | |
// render the presentation; removed "Calibri" font is replaced to an existing one | |
presentation.Slides[0].GetThumbnail(new Size(960, 720)).Save(dataDir + "picture2_out.png", ImageFormat.Png); | |
// save the presentation without embedded "Calibri" font | |
presentation.Save(dataDir + "WithoutManageEmbeddedFonts_out.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
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Text(); | |
// Instantiate PresentationEx | |
using (Presentation presentation = new Presentation(dataDir + "DefaultFonts.pptx")) | |
{ | |
// Accessing a slide using its slide position | |
ISlide slide = presentation.Slides[0]; | |
// Accessing the first and second placeholder in the slide and typecasting it as AutoShape | |
ITextFrame tf1 = ((IAutoShape)slide.Shapes[0]).TextFrame; | |
ITextFrame tf2 = ((IAutoShape)slide.Shapes[1]).TextFrame; | |
// Accessing the first Paragraph | |
IParagraph para1 = tf1.Paragraphs[0]; | |
IParagraph para2 = tf2.Paragraphs[0]; | |
// Justify the paragraph | |
para2.ParagraphFormat.Alignment = TextAlignment.JustifyLow; | |
// Accessing the first portion | |
IPortion port1 = para1.Portions[0]; | |
IPortion port2 = para2.Portions[0]; | |
// Define new fonts | |
FontData fd1 = new FontData("Elephant"); | |
FontData fd2 = new FontData("Castellar"); | |
// Assign new fonts to portion | |
port1.PortionFormat.LatinFont = fd1; | |
port2.PortionFormat.LatinFont = fd2; | |
// Set font to Bold | |
port1.PortionFormat.FontBold = NullableBool.True; | |
port2.PortionFormat.FontBold = NullableBool.True; | |
// Set font to Italic | |
port1.PortionFormat.FontItalic = NullableBool.True; | |
port2.PortionFormat.FontItalic = NullableBool.True; | |
// Set font color | |
port1.PortionFormat.FillFormat.FillType = FillType.Solid; | |
port1.PortionFormat.FillFormat.SolidFillColor.Color = Color.Purple; | |
port2.PortionFormat.FillFormat.FillType = FillType.Solid; | |
port2.PortionFormat.FillFormat.SolidFillColor.Color = Color.Peru; | |
// Write the PPTX to disk | |
presentation.Save(dataDir + "ManagParagraphFontProperties_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_Text(); | |
Presentation presentation = new Presentation(); | |
// Accessing the first slide | |
ISlide slide = presentation.Slides[0]; | |
// Instantiate the image for bullets | |
Image image = new Bitmap(dataDir + "bullets.png"); | |
IPPImage ippxImage = presentation.Images.AddImage(image); | |
// Adding and accessing Autoshape | |
IAutoShape autoShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 200, 200, 400, 200); | |
// Accessing the text frame of created autoshape | |
ITextFrame textFrame = autoShape.TextFrame; | |
// Removing the default exisiting paragraph | |
textFrame.Paragraphs.RemoveAt(0); | |
// Creating new paragraph | |
Paragraph paragraph = new Paragraph(); | |
paragraph.Text = "Welcome to Aspose.Slides"; | |
// Setting paragraph bullet style and image | |
paragraph.ParagraphFormat.Bullet.Type = BulletType.Picture; | |
paragraph.ParagraphFormat.Bullet.Picture.Image = ippxImage; | |
// Setting Bullet Height | |
paragraph.ParagraphFormat.Bullet.Height = 100; | |
// Adding Paragraph to text frame | |
textFrame.Paragraphs.Add(paragraph); | |
// Writing the presentation as a PPTX file | |
presentation.Save(dataDir + "ParagraphPictureBulletsPPTX_out.pptx", SaveFormat.Pptx); | |
// Writing the presentation as a PPT file | |
presentation.Save(dataDir + "ParagraphPictureBulletsPPT_out.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
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Text(); | |
// 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 a PPTX file | |
using (Presentation pres = new Presentation()) | |
{ | |
// Accessing first slide | |
ISlide slide = pres.Slides[0]; | |
// Add an AutoShape of Rectangle type | |
IAutoShape ashp = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 150, 300, 150); | |
// Access TextFrame of the AutoShape | |
ITextFrame tf = ashp.TextFrame; | |
// Create Paragraphs and Portions with different text formats | |
IParagraph para0 = tf.Paragraphs[0]; | |
IPortion port01 = new Portion(); | |
IPortion port02 = new Portion(); | |
para0.Portions.Add(port01); | |
para0.Portions.Add(port02); | |
IParagraph para1 = new Paragraph(); | |
tf.Paragraphs.Add(para1); | |
IPortion port10 = new Portion(); | |
IPortion port11 = new Portion(); | |
IPortion port12 = new Portion(); | |
para1.Portions.Add(port10); | |
para1.Portions.Add(port11); | |
para1.Portions.Add(port12); | |
IParagraph para2 = new Paragraph(); | |
tf.Paragraphs.Add(para2); | |
IPortion port20 = new Portion(); | |
IPortion port21 = new Portion(); | |
IPortion port22 = new Portion(); | |
para2.Portions.Add(port20); | |
para2.Portions.Add(port21); | |
para2.Portions.Add(port22); | |
for (int i = 0; i < 3; i++) | |
for (int j = 0; j < 3; j++) | |
{ | |
tf.Paragraphs[i].Portions[j].Text = "Portion0" + j.ToString(); | |
if (j == 0) | |
{ | |
tf.Paragraphs[i].Portions[j].PortionFormat.FillFormat.FillType = FillType.Solid; | |
tf.Paragraphs[i].Portions[j].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red; | |
tf.Paragraphs[i].Portions[j].PortionFormat.FontBold = NullableBool.True; | |
tf.Paragraphs[i].Portions[j].PortionFormat.FontHeight = 15; | |
} | |
else if (j == 1) | |
{ | |
tf.Paragraphs[i].Portions[j].PortionFormat.FillFormat.FillType = FillType.Solid; | |
tf.Paragraphs[i].Portions[j].PortionFormat.FillFormat.SolidFillColor.Color = Color.Blue; | |
tf.Paragraphs[i].Portions[j].PortionFormat.FontItalic = NullableBool.True; | |
tf.Paragraphs[i].Portions[j].PortionFormat.FontHeight = 18; | |
} | |
} | |
//Write PPTX to Disk | |
pres.Save(dataDir + "multiParaPort_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_Text(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Creating a presenation instance | |
using (Presentation pres = new Presentation()) | |
{ | |
// Accessing the first slide | |
ISlide slide = pres.Slides[0]; | |
// Adding and accessing Autoshape | |
IAutoShape aShp = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 200, 200, 400, 200); | |
// Accessing the text frame of created autoshape | |
ITextFrame txtFrm = aShp.TextFrame; | |
// Removing the default exisiting paragraph | |
txtFrm.Paragraphs.RemoveAt(0); | |
// Creating a paragraph | |
Paragraph para = new Paragraph(); | |
// Setting paragraph bullet style and symbol | |
para.ParagraphFormat.Bullet.Type = BulletType.Symbol; | |
para.ParagraphFormat.Bullet.Char = Convert.ToChar(8226); | |
// Setting paragraph text | |
para.Text = "Welcome to Aspose.Slides"; | |
// Setting bullet indent | |
para.ParagraphFormat.Indent = 25; | |
// Setting bullet color | |
para.ParagraphFormat.Bullet.Color.ColorType = ColorType.RGB; | |
para.ParagraphFormat.Bullet.Color.Color = Color.Black; | |
para.ParagraphFormat.Bullet.IsBulletHardColor = NullableBool.True; // set IsBulletHardColor to true to use own bullet color | |
// Setting Bullet Height | |
para.ParagraphFormat.Bullet.Height = 100; | |
// Adding Paragraph to text frame | |
txtFrm.Paragraphs.Add(para); | |
// Creating second paragraph | |
Paragraph para2 = new Paragraph(); | |
// Setting paragraph bullet type and style | |
para2.ParagraphFormat.Bullet.Type = BulletType.Numbered; | |
para2.ParagraphFormat.Bullet.NumberedBulletStyle = NumberedBulletStyle.BulletCircleNumWDBlackPlain; | |
// Adding paragraph text | |
para2.Text = "This is numbered bullet"; | |
// Setting bullet indent | |
para2.ParagraphFormat.Indent = 25; | |
para2.ParagraphFormat.Bullet.Color.ColorType = ColorType.RGB; | |
para2.ParagraphFormat.Bullet.Color.Color = Color.Black; | |
para2.ParagraphFormat.Bullet.IsBulletHardColor = NullableBool.True; // set IsBulletHardColor to true to use own bullet color | |
// Setting Bullet Height | |
para2.ParagraphFormat.Bullet.Height = 100; | |
// Adding Paragraph to text frame | |
txtFrm.Paragraphs.Add(para2); | |
//Writing the presentation as a PPTX file | |
pres.Save(dataDir + "Bullet_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_Text(); | |
// 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 | |
Presentation pres = new Presentation(); | |
// Get first slide | |
ISlide sld = pres.Slides[0]; | |
// Add a Rectangle Shape | |
IAutoShape rect = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 500, 150); | |
// Add TextFrame to the Rectangle | |
ITextFrame tf = rect.AddTextFrame("This is first line \rThis is second line \rThis is third line"); | |
// Set the text to fit the shape | |
tf.TextFrameFormat.AutofitType = TextAutofitType.Shape; | |
// Hide the lines of the Rectangle | |
rect.LineFormat.FillFormat.FillType = FillType.Solid; | |
// Get first Paragraph in the TextFrame and set its Indent | |
IParagraph para1 = tf.Paragraphs[0]; | |
// Setting paragraph bullet style and symbol | |
para1.ParagraphFormat.Bullet.Type = BulletType.Symbol; | |
para1.ParagraphFormat.Bullet.Char = Convert.ToChar(8226); | |
para1.ParagraphFormat.Alignment = TextAlignment.Left; | |
para1.ParagraphFormat.Depth = 2; | |
para1.ParagraphFormat.Indent = 30; | |
// Get second Paragraph in the TextFrame and set its Indent | |
IParagraph para2 = tf.Paragraphs[1]; | |
para2.ParagraphFormat.Bullet.Type = BulletType.Symbol; | |
para2.ParagraphFormat.Bullet.Char = Convert.ToChar(8226); | |
para2.ParagraphFormat.Alignment = TextAlignment.Left; | |
para2.ParagraphFormat.Depth = 2; | |
para2.ParagraphFormat.Indent = 40; | |
// Get third Paragraph in the TextFrame and set its Indent | |
IParagraph para3 = tf.Paragraphs[2]; | |
para3.ParagraphFormat.Bullet.Type = BulletType.Symbol; | |
para3.ParagraphFormat.Bullet.Char = Convert.ToChar(8226); | |
para3.ParagraphFormat.Alignment = TextAlignment.Left; | |
para3.ParagraphFormat.Depth = 2; | |
para3.ParagraphFormat.Indent = 50; | |
//Write the Presentation to disk | |
pres.Save(dataDir + "InOutDent_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_Text(); | |
// Instantiate a Presentation object that represents a PPTX file | |
using (Presentation pres = new Presentation(dataDir + "ParagraphsAlignment.pptx")) | |
{ | |
// Accessing first slide | |
ISlide slide = pres.Slides[0]; | |
// Accessing the first and second placeholder in the slide and typecasting it as AutoShape | |
ITextFrame tf1 = ((IAutoShape)slide.Shapes[0]).TextFrame; | |
ITextFrame tf2 = ((IAutoShape)slide.Shapes[1]).TextFrame; | |
// Change the text in both placeholders | |
tf1.Text = "Center Align by Aspose"; | |
tf2.Text = "Center Align by Aspose"; | |
// Getting the first paragraph of the placeholders | |
IParagraph para1 = tf1.Paragraphs[0]; | |
IParagraph para2 = tf2.Paragraphs[0]; | |
// Aligning the text paragraph to center | |
para1.ParagraphFormat.Alignment = TextAlignment.Center; | |
para2.ParagraphFormat.Alignment = TextAlignment.Center; | |
//Writing the presentation as a PPTX file | |
pres.Save(dataDir + "Centeralign_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_Text(); | |
// Load presentation | |
Presentation presentation = new Presentation(dataDir + "Fonts.pptx"); | |
// Load source font to be replaced | |
IFontData sourceFont = new FontData("Arial"); | |
// Load the replacing font | |
IFontData destFont = new FontData("Times New Roman"); | |
// Replace the fonts | |
presentation.FontsManager.ReplaceFont(sourceFont, destFont); | |
// Save the presentation | |
presentation.Save(dataDir + "UpdatedFont_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_Text(); | |
// Instantiate Presentation class that represents PPTX// Instantiate Presentation class that represents PPTX | |
using (Presentation pres = new Presentation(dataDir + "ReplacingText.pptx")) | |
{ | |
// Access first slide | |
ISlide sld = pres.Slides[0]; | |
// Iterate through shapes to find the placeholder | |
foreach (IShape shp in sld.Shapes) | |
if (shp.Placeholder != null) | |
{ | |
// Change the text of each placeholder | |
((IAutoShape)shp).TextFrame.Text = "This is Placeholder"; | |
} | |
// Save the PPTX to Disk | |
pres.Save(dataDir + "output_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_Text(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(); | |
// Get the first slide | |
ISlide slide = presentation.Slides[0]; | |
// Add an AutoShape of Rectangle type | |
IAutoShape ashp = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 75, 350, 350); | |
// Add TextFrame to the Rectangle | |
ashp.AddTextFrame(" "); | |
ashp.FillFormat.FillType = FillType.NoFill; | |
// Accessing the text frame | |
ITextFrame txtFrame = ashp.TextFrame; | |
txtFrame.TextFrameFormat.TextVerticalType = TextVerticalType.Vertical270; | |
// Create the Paragraph object for text frame | |
IParagraph para = txtFrame.Paragraphs[0]; | |
// Create Portion object for paragraph | |
IPortion portion = para.Portions[0]; | |
portion.Text = "A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog."; | |
portion.PortionFormat.FillFormat.FillType = FillType.Solid; | |
portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black; | |
// Save Presentation | |
presentation.Save(dataDir + "RotateText_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_Text(); | |
// Load presentation | |
Presentation presentation = new Presentation(dataDir + "Fonts.pptx"); | |
// Load source font to be replaced | |
IFontData sourceFont = new FontData("SomeRareFont"); | |
// Load the replacing font | |
IFontData destFont = new FontData("Arial"); | |
// Add font rule for font replacement | |
IFontSubstRule fontSubstRule = new FontSubstRule(sourceFont, destFont, FontSubstCondition.WhenInaccessible); | |
// Add rule to font substitute rules collection | |
IFontSubstRuleCollection fontSubstRuleCollection = new FontSubstRuleCollection(); | |
fontSubstRuleCollection.Add(fontSubstRule); | |
// Add font rule collection to rule list | |
presentation.FontsManager.FontSubstRuleList = fontSubstRuleCollection; | |
// Arial font will be used instead of SomeRareFont when inaccessible | |
Bitmap bmp = presentation.Slides[0].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_Text(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(); | |
// Get the first slide | |
ISlide slide = presentation.Slides[0]; | |
// Add an AutoShape of Rectangle type | |
IAutoShape ashp = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 75, 350, 350); | |
// Add TextFrame to the Rectangle | |
ashp.AddTextFrame(" "); | |
ashp.FillFormat.FillType = FillType.NoFill; | |
// Accessing the text frame | |
ITextFrame txtFrame = ashp.TextFrame; | |
txtFrame.TextFrameFormat.AnchoringType = TextAnchorType.Bottom; | |
// Create the Paragraph object for text frame | |
IParagraph para = txtFrame.Paragraphs[0]; | |
// Create Portion object for paragraph | |
IPortion portion = para.Portions[0]; | |
portion.Text = "A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog."; | |
portion.PortionFormat.FillFormat.FillType = FillType.Solid; | |
portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black; | |
// Save Presentation | |
presentation.Save(dataDir + "AnchorText_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_Text(); | |
// Create an instance of Presentation class | |
Presentation presentation = new Presentation(); | |
// Access the first slide | |
ISlide slide = presentation.Slides[0]; | |
// Add an AutoShape of Rectangle type | |
IAutoShape ashp = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 75, 350, 350); | |
// Add TextFrame to the Rectangle | |
ashp.AddTextFrame(" "); | |
ashp.FillFormat.FillType = FillType.NoFill; | |
// Accessing the text frame | |
ITextFrame txtFrame = ashp.TextFrame; | |
txtFrame.TextFrameFormat.AutofitType = TextAutofitType.Shape; | |
// Create the Paragraph object for text frame | |
IParagraph para = txtFrame.Paragraphs[0]; | |
// Create Portion object for paragraph | |
IPortion portion = para.Portions[0]; | |
portion.Text = "A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog."; | |
portion.PortionFormat.FillFormat.FillType = FillType.Solid; | |
portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black; | |
// Save Presentation | |
presentation.Save(dataDir + "formatText_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_Text(); | |
// Instantiate Presentation | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Get first slide | |
ISlide sld = presentation.Slides[0]; | |
// Add an AutoShape of Rectangle type | |
IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 50, 200, 50); | |
// Remove any fill style associated with the AutoShape | |
ashp.FillFormat.FillType = FillType.NoFill; | |
// Access the TextFrame associated with the AutoShape | |
ITextFrame tf = ashp.TextFrame; | |
tf.Text = "Aspose TextBox"; | |
// Access the Portion associated with the TextFrame | |
IPortion port = tf.Paragraphs[0].Portions[0]; | |
// Set the Font for the Portion | |
port.PortionFormat.LatinFont = new FontData("Times New Roman"); | |
// Set Bold property of the Font | |
port.PortionFormat.FontBold = NullableBool.True; | |
// Set Italic property of the Font | |
port.PortionFormat.FontItalic = NullableBool.True; | |
// Set Underline property of the Font | |
port.PortionFormat.FontUnderline = TextUnderlineType.Single; | |
// Set the Height of the Font | |
port.PortionFormat.FontHeight = 25; | |
// Set the color of the Font | |
port.PortionFormat.FillFormat.FillType = FillType.Solid; | |
port.PortionFormat.FillFormat.SolidFillColor.Color = Color.Blue; | |
// Write the PPTX to disk | |
presentation.Save(dataDir + "SetTextFontProperties_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_Text(); | |
using (Presentation pres = new Presentation(dataDir+"test0.pptx")) | |
{ | |
IAutoShape shape = pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 50, 50, 200, 50); | |
shape.AddTextFrame("Text to apply spellcheck language"); | |
shape.TextFrame.Paragraphs[0].Portions[0].PortionFormat.LanguageId = "en-EN"; | |
pres.Save(dataDir+"test1.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_Text(); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate a PPTX class | |
using (Presentation pres = new Presentation()) | |
{ | |
// Get reference of the slide | |
ISlide sld = pres.Slides[0]; | |
// Add an AutoShape of Rectangle type | |
IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 75, 150, 50); | |
// Add TextFrame to the Rectangle | |
ashp.AddTextFrame("Aspose TextBox"); | |
// Disable shape fill in case we want to get shadow of text | |
ashp.FillFormat.FillType = FillType.NoFill; | |
// Add outer shadow and set all necessary parameters | |
ashp.EffectFormat.EnableOuterShadowEffect(); | |
IOuterShadow shadow = ashp.EffectFormat.OuterShadowEffect; | |
shadow.BlurRadius = 4.0; | |
shadow.Direction = 45; | |
shadow.Distance = 3; | |
shadow.RectangleAlign = RectangleAlignment.TopLeft; | |
shadow.ShadowColor.PresetColor = PresetColor.Black; | |
//Write the presentation to disk | |
pres.Save(dataDir + "pres_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_Text(); | |
byte[] memoryFont1 = File.ReadAllBytes("customfonts\\CustomFont1.ttf"); | |
byte[] memoryFont2 = File.ReadAllBytes("customfonts\\CustomFont2.ttf"); | |
ILoadOptions loadOptions = new LoadOptions(); | |
loadOptions.DocumentLevelFontSources.FontFolders = new string[] { "assets\\fonts", "global\\fonts" }; | |
loadOptions.DocumentLevelFontSources.MemoryFonts = new byte[][] { memoryFont1, memoryFont2 }; | |
using (IPresentation presentation = CreatePresentation("MyPresentation.pptx", loadOptions)) | |
{ | |
//work with the presentation | |
//CustomFont1, CustomFont2 as well as fonts from assets\fonts & global\fonts folders and their subfolders are available to the 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_Text(); | |
// 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 a PPTX | |
Presentation pptxPresentation = new Presentation(); | |
// Get first slide | |
ISlide slide = pptxPresentation.Slides[0]; | |
// Add an AutoShape of Rectangle Type | |
IShape pptxShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 150, 150, 50); | |
// Cast the shape to AutoShape | |
IAutoShape pptxAutoShape = (IAutoShape)pptxShape; | |
// Access ITextFrame associated with the AutoShape | |
pptxAutoShape.AddTextFrame(""); | |
ITextFrame ITextFrame = pptxAutoShape.TextFrame; | |
// Add some text to the frame | |
ITextFrame.Paragraphs[0].Portions[0].Text = "Aspose.Slides"; | |
// Set Hyperlink for the portion text | |
IHyperlinkManager HypMan = ITextFrame.Paragraphs[0].Portions[0].PortionFormat.HyperlinkManager; | |
HypMan.SetExternalHyperlinkClick("http://www.aspose.com"); | |
// Save the PPTX Presentation | |
pptxPresentation.Save(dataDir + "hLinkPPTX_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment