Skip to content

Instantly share code, notes, and snippets.

  • Save sohail-aspose/4f89bfbfc9a9109a85fffc9623b2344f to your computer and use it in GitHub Desktop.
Save sohail-aspose/4f89bfbfc9a9109a85fffc9623b2344f to your computer and use it in GitHub Desktop.
This Gist contains code snippets for sample code of Aspose.Slides

This Gist contains code snippets for sample code of Aspose.Slides

// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Create empty presentation instance
Presentation newPptx = new Presentation();
// Adding the Media Player ActiveX control
newPptx.getSlides().get_Item(0).getControls().addControl(ControlType.WindowsMediaPlayer, 100, 100, 400, 400);
// Access the Media Player ActiveX control and set the video path
newPptx.getSlides().get_Item(0).getControls().get_Item(0).getProperties().set_Item("URL", "Wildlife.wmv");
// Save the Presentation
newPptx.save("Output.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Accessing the presentation with ActiveX controls
Presentation pres = new Presentation("template.pptx");
// Create empty presentation instance
Presentation newPptx = new Presentation();
// Remove default slide
newPptx.getSlides().removeAt(0);
// Clone slide with Media Player ActiveX Control
newPptx.getSlides().insertClone(0, pres.getSlides().get_Item(0));
// Access the Media Player ActiveX control and set the video path
newPptx.getSlides().get_Item(0).getControls().get_Item(0).getProperties().set_Item("URL", "Wildlife.wmv");
// Save the Presentation
newPptx.save("Output.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Accessing the presentation with ActiveX controls
Presentation pres = new Presentation("withActiveX.pptm");
// Accessing the first slide in presentation
ISlide slide = pres.getSlides().get_Item(0);
// changing TextBox text
IControl control = slide.getControls().get_Item(0);
if (control.getName() == "TextBox1" && control.getProperties() != null) {
String newText = "Changed text";
control.getProperties().set_Item("Value", newText);
// changing substitute image. PowerPoint will replace this image
// during activeX activation, so sometime it's OK to leave image
// unchanged.
BufferedImage image = new BufferedImage((int) control.getFrame().getWidth(),
(int) control.getFrame().getHeight(), BufferedImage.TYPE_INT_ARGB);
java.awt.Graphics graphics = image.getGraphics();
graphics.setColor(SystemColor.window);
graphics.fillRect(0, 0, image.getWidth(), image.getHeight());
java.awt.Font font = new java.awt.Font(control.getProperties().get_Item("FontName"), java.awt.Font.PLAIN,
16);
graphics.setColor(SystemColor.windowText);
graphics.setFont(font);
graphics.drawString(newText, 10, 20);
graphics.setColor(SystemColor.controlShadow);
graphics.drawLine(0, image.getHeight() - 1, 0, 0);
graphics.drawLine(0, 0, image.getWidth() - 1, 0);
graphics.setColor(SystemColor.controlDkShadow);
graphics.drawLine(1, image.getHeight() - 2, 1, 1);
graphics.drawLine(1, 1, image.getWidth() - 2, 1);
graphics.setColor(SystemColor.controlHighlight);
graphics.drawLine(1, image.getHeight() - 1, image.getWidth() - 1, image.getHeight() - 1);
graphics.drawLine(image.getWidth() - 1, image.getHeight() - 1, image.getWidth() - 1, 1);
graphics.setColor(SystemColor.controlLtHighlight);
graphics.drawLine(0, image.getHeight(), image.getWidth(), image.getHeight());
graphics.drawLine(image.getWidth(), image.getHeight(), image.getWidth(), 0);
graphics.dispose();
control.getSubstitutePictureFormat().getPicture().setImage(pres.getImages().addImage(image));
}
// changing Button caption
control = pres.getSlides().get_Item(0).getControls().get_Item(1);
if (control.getName().equalsIgnoreCase("CommandButton1") && control.getProperties() != null) {
String newCaption = "Show MessageBox";
control.getProperties().set_Item("Caption", newCaption);
// changing substitute
BufferedImage image = new BufferedImage((int) control.getFrame().getWidth(),
(int) control.getFrame().getHeight(), BufferedImage.TYPE_INT_ARGB);
java.awt.Graphics graphics = image.getGraphics();
graphics.setColor(SystemColor.control);
graphics.fillRect(0, 0, image.getWidth(), image.getHeight());
java.awt.Font font = new java.awt.Font(control.getProperties().get_Item("FontName"), java.awt.Font.PLAIN,
16);
graphics.setColor(SystemColor.windowText);
graphics.setFont(font);
FontMetrics metrics = graphics.getFontMetrics(font);
graphics.drawString(newCaption, (image.getWidth() - metrics.stringWidth(newCaption)) / 2, 20);
graphics.setColor(SystemColor.controlLtHighlight);
graphics.drawLine(0, image.getHeight() - 1, 0, 0);
graphics.drawLine(0, 0, image.getWidth() - 1, 0);
graphics.setColor(SystemColor.controlHighlight);
graphics.drawLine(1, image.getHeight() - 2, 1, 1);
graphics.drawLine(1, 1, image.getWidth() - 2, 1);
graphics.setColor(SystemColor.controlShadow);
graphics.drawLine(1, image.getHeight() - 1, image.getWidth() - 1, image.getHeight() - 1);
graphics.drawLine(image.getWidth() - 1, image.getHeight() - 1, image.getWidth() - 1, 1);
graphics.setColor(SystemColor.controlDkShadow);
graphics.drawLine(0, image.getHeight(), image.getWidth(), image.getHeight());
graphics.drawLine(image.getWidth(), image.getHeight(), image.getWidth(), 0);
graphics.dispose();
control.getSubstitutePictureFormat().getPicture().setImage(pres.getImages().addImage(image));
}
// moving 100 points down
for (IControl ctl : pres.getSlides().get_Item(0).getControls()) {
IShapeFrame frame = ctl.getFrame();
ctl.setFrame(new ShapeFrame(frame.getX(), frame.getY() + 100, frame.getWidth(), frame.getHeight(),
frame.getFlipH(), frame.getFlipV(), frame.getRotation()));
}
pres.save("withActiveX-edited_java.pptm", SaveFormat.Pptm);
// removing controls
pres.getSlides().get_Item(0).getControls().clear();
pres.save("withActiveX-cleared_java.pptm", SaveFormat.Pptm);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Creating empty presentation
Presentation pres = new Presentation();
// Adding chart
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 600, 400,
true);
IChartSeriesCollection series = chart.getChartData().getSeries();
if (series.get_Item(0).getOverlap() == 0) {
// Setting series overlap
series.get_Item(0).getParentSeriesGroup().setOverlap((byte) -30);
}
// Saving presentation
pres.save("ErrorBars.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Creating empty presentation//Creating empty presentation
Presentation pres = new Presentation();
// Creating a clustered column chart
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.ClusteredColumn, 20, 20, 500, 400);
// Adding exponential trend line for chart series 1
ITrendline tredLinep = chart.getChartData().getSeries().get_Item(0).getTrendLines()
.add(TrendlineType.Exponential);
tredLinep.setDisplayEquation(false);
tredLinep.setDisplayRSquaredValue(false);
// Adding Linear trend line for chart series 1
ITrendline tredLineLin = chart.getChartData().getSeries().get_Item(0).getTrendLines().add(TrendlineType.Linear);
tredLineLin.setTrendlineType(TrendlineType.Linear);
tredLineLin.getFormat().getLine().getFillFormat().setFillType(FillType.Solid);
tredLineLin.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.RED);
// Adding Logarithmic trend line for chart series 2
ITrendline tredLineLog = chart.getChartData().getSeries().get_Item(1).getTrendLines()
.add(TrendlineType.Logarithmic);
tredLineLog.setTrendlineType(TrendlineType.Logarithmic);
tredLineLog.addTextFrameForOverriding("New log trend line");
// Adding MovingAverage trend line for chart series 2
ITrendline tredLineMovAvg = chart.getChartData().getSeries().get_Item(1).getTrendLines()
.add(TrendlineType.MovingAverage);
tredLineMovAvg.setTrendlineType(TrendlineType.MovingAverage);
tredLineMovAvg.setPeriod((byte) 3);
tredLineMovAvg.setTrendlineName("New TrendLine Name");
// Adding Polynomial trend line for chart series 3
ITrendline tredLinePol = chart.getChartData().getSeries().get_Item(2).getTrendLines()
.add(TrendlineType.Polynomial);
tredLinePol.setTrendlineType(TrendlineType.Polynomial);
tredLinePol.setForward(1);
tredLinePol.setOrder((byte) 3);
// Adding Power trend line for chart series 3
ITrendline tredLinePower = chart.getChartData().getSeries().get_Item(1).getTrendLines()
.add(TrendlineType.Power);
tredLinePower.setTrendlineType(TrendlineType.Power);
tredLinePower.setBackward(1);
// Saving presentation
pres.save("ChartTrendLines.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Creating empty presentation
Presentation pres = new Presentation();
// Creating a bubble chart
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.Bubble, 50, 50, 400, 300, true);
// Adding custom Error bars and setting its format
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
IErrorBarsFormat errBarX = series.getErrorBarsXFormat();
IErrorBarsFormat errBarY = series.getErrorBarsYFormat();
errBarX.isVisible();
errBarY.isVisible();
errBarX.setValueType((byte) ErrorBarValueType.Custom);
errBarY.setValueType((byte) ErrorBarValueType.Custom);
// Accessing chart series data point and setting error bars values for
// individual point
IChartDataPointCollection points = series.getDataPoints();
points.getDataSourceTypeForErrorBarsCustomValues()
.setDataSourceTypeForXPlusValues((byte) DataSourceType.DoubleLiterals);
points.getDataSourceTypeForErrorBarsCustomValues()
.setDataSourceTypeForXMinusValues((byte) DataSourceType.DoubleLiterals);
points.getDataSourceTypeForErrorBarsCustomValues()
.setDataSourceTypeForYPlusValues((byte) DataSourceType.DoubleLiterals);
points.getDataSourceTypeForErrorBarsCustomValues()
.setDataSourceTypeForYMinusValues((byte) DataSourceType.DoubleLiterals);
// Setting error bars for chart series points
for (int i = 0; i < points.size(); i++) {
points.get_Item(i).getErrorBarsCustomValues().getXMinus().setAsLiteralDouble(i + 1);
points.get_Item(i).getErrorBarsCustomValues().getXPlus().setAsLiteralDouble(i + 1);
points.get_Item(i).getErrorBarsCustomValues().getYMinus().setAsLiteralDouble(i + 1);
points.get_Item(i).getErrorBarsCustomValues().getYPlus().setAsLiteralDouble(i + 1);
}
// Saving presentation
pres.save("ErrorBarsCustomValues", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Creating empty presentation
Presentation pres = new Presentation();
// Creating a bubble chart
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.Bubble, 50, 50, 400, 300, true);
// Adding Error bars and setting its format
IErrorBarsFormat errBarX = chart.getChartData().getSeries().get_Item(0).getErrorBarsXFormat();
IErrorBarsFormat errBarY = chart.getChartData().getSeries().get_Item(0).getErrorBarsYFormat();
errBarX.isVisible();
errBarY.isVisible();
errBarX.setValueType((byte) ErrorBarValueType.Fixed);
errBarX.setValue(0.1f);
errBarY.setValueType((byte) ErrorBarValueType.Percentage);
errBarY.setValue(5);
errBarX.setType((byte) ErrorBarType.Plus);
errBarY.getFormat().getLine().setWidth(2.0f);
errBarX.hasEndCap();
// Saving presentation
pres.save("ErrorBars.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Load a presentation
Presentation pres = new Presentation(inFileName);
try {
ISlide slide = pres.getSlides().get_Item(0);
IShapeCollection shapes = slide.getShapes();
IChart chart = (IChart) shapes.get_Item(0);
slide.getTimeline().getMainSequence().addEffect(chart, EffectType.Fade, EffectSubtype.None,
EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMajorGroupingType.ByCategory,
0, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMajorGroupingType.ByCategory,
1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMajorGroupingType.ByCategory,
2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMajorGroupingType.ByCategory,
3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
pres.save(outFileName, SaveFormat.Pptx);
} finally {
if (pres != null)
pres.dispose();
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents a presentation file
Presentation pres = new Presentation(inFileName);
try {
ISlide slide = pres.getSlides().get_Item(0);
IShapeCollection shapes = slide.getShapes();
IChart chart = (IChart) shapes.get_Item(0);
slide.getTimeline().getMainSequence().addEffect(chart, EffectType.Fade, EffectSubtype.None,
EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMajorGroupingType.BySeries,
0, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMajorGroupingType.BySeries,
1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMajorGroupingType.BySeries,
2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart, EffectChartMajorGroupingType.BySeries,
3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
pres.save(outFileName, SaveFormat.Pptx);
} finally {
if (pres != null)
pres.dispose();
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Load a presentation
Presentation pres = new Presentation(inFileName);
try {
ISlide slide = pres.getSlides().get_Item(0);
IShapeCollection shapes = slide.getShapes();
IChart chart = (IChart) shapes.get_Item(0);
slide.getTimeline().getMainSequence().addEffect(chart, EffectType.Fade, EffectSubtype.None,
EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart,
EffectChartMinorGroupingType.ByElementInSeries, 0, 0, EffectType.Appear, EffectSubtype.None,
EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart,
EffectChartMinorGroupingType.ByElementInSeries, 0, 1, EffectType.Appear, EffectSubtype.None,
EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart,
EffectChartMinorGroupingType.ByElementInSeries, 0, 2, EffectType.Appear, EffectSubtype.None,
EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart,
EffectChartMinorGroupingType.ByElementInSeries, 0, 3, EffectType.Appear, EffectSubtype.None,
EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart,
EffectChartMinorGroupingType.ByElementInSeries, 1, 0, EffectType.Appear, EffectSubtype.None,
EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart,
EffectChartMinorGroupingType.ByElementInSeries, 1, 1, EffectType.Appear, EffectSubtype.None,
EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart,
EffectChartMinorGroupingType.ByElementInSeries, 1, 2, EffectType.Appear, EffectSubtype.None,
EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart,
EffectChartMinorGroupingType.ByElementInSeries, 1, 3, EffectType.Appear, EffectSubtype.None,
EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart,
EffectChartMinorGroupingType.ByElementInSeries, 2, 0, EffectType.Appear, EffectSubtype.None,
EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart,
EffectChartMinorGroupingType.ByElementInSeries, 2, 1, EffectType.Appear, EffectSubtype.None,
EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart,
EffectChartMinorGroupingType.ByElementInSeries, 2, 2, EffectType.Appear, EffectSubtype.None,
EffectTriggerType.AfterPrevious);
((Sequence) slide.getTimeline().getMainSequence()).addEffect(chart,
EffectChartMinorGroupingType.ByElementInSeries, 2, 3, EffectType.Appear, EffectSubtype.None,
EffectTriggerType.AfterPrevious);
pres.save(outFileName, SaveFormat.Pptx);
} finally {
if (pres != null)
pres.dispose();
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
//Instantiate Presentation class that represents PPTX file
Presentation pres = new Presentation();
// Access first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add chart with default data
IChart chart = sld.getShapes().addChart(ChartType.ClusteredColumn, 0, 0, 500, 500);
// Setting chart Title
chart.ChartTitle.TextFrameForOverriding.Text = "Sample Title";
chart.getChartTitle().addTextFrameForOverriding("Sample Title");
chart.getChartTitle().getTextFrameForOverriding().getTextFrameFormat().setCenterText(NullableBool.True);
chart.getChartTitle().setHeight(20);
chart.hasTitle();
// Set first series to Show Values
chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat().setShowValue(true);
// Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
// Getting the chart data WorkSheet
IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();
// Delete default generated series and categories
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
int s = chart.getChartData().getSeries().size();
s = chart.getChartData().getCategories().size();
// Adding new series
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 1, "Series 1"), chart.getType());
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 2, "Series 2"), chart.getType());
// Adding new categories
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 1, 0, "Caetegoty 1"));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 2, 0, "Caetegoty 2"));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 3, 0, "Caetegoty 3"));
// Take first chart series
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
// Now populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 1, 20));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 1, 50));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 1, 30));
// Setting fill color for series
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(Color.RED);
// Take second chart series
series = chart.getChartData().getSeries().get_Item(1);
// Now populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 2, 30));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 2, 10));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 2, 60));
// Setting fill color for series
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(Color.GREEN);
// Create custom labels for each of categories for new series
// first label will be show Category name
IDataLabel lbl = series.getDataPoints().get_Item(0).getLabel();
lbl.getDataLabelFormat().setShowCategoryName(true);
lbl = series.getDataPoints().get_Item(1).getLabel();
lbl.getDataLabelFormat().setShowSeriesName(true);
// Show value for third label
lbl = series.getDataPoints().get_Item(2).getLabel();
lbl.getDataLabelFormat().setShowValue(true);
lbl.getDataLabelFormat().setShowSeriesName(true);
lbl.getDataLabelFormat().setSeparator("/");
// Save presentation with chart
pres.save("AsposeChart.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation pres = new Presentation();
ISlide slide = pres.getSlides().get_Item(0);
// Creating the default chart
IChart chart = slide.getShapes().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.getChartData().getChartDataWorkbook();
// Delete demo series
chart.getChartData().getSeries().clear();
// Add new series
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 1, 1, "Series 1"), chart.getType());
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 1, 3, "Series 2"), chart.getType());
// Take first chart series
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
// Add new point (1:3) there.
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 2, 1, 1),
fact.getCell(defaultWorksheetIndex, 2, 2, 3));
// Add new point (2:10)
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 3, 1, 2),
fact.getCell(defaultWorksheetIndex, 3, 2, 10));
// Edit the type of series
series.setType(ChartType.ScatterWithStraightLinesAndMarkers);
// Changing the chart series marker
series.getMarker().setSize(10);
series.getMarker().setSymbol(MarkerStyleType.Star);
// Take second chart series
series = chart.getChartData().getSeries().get_Item(1);
// Add new point (5:2) there.
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 2, 3, 5),
fact.getCell(defaultWorksheetIndex, 2, 4, 2));
// Add new point (3:1)
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 3, 3, 3),
fact.getCell(defaultWorksheetIndex, 3, 4, 1));
// Add new point (2:2)
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 4, 3, 2),
fact.getCell(defaultWorksheetIndex, 4, 4, 2));
// Add new point (5:1)
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 5, 3, 5),
fact.getCell(defaultWorksheetIndex, 5, 4, 1));
// Changing the chart series marker
series.getMarker().setSize(10);
series.getMarker().setSymbol(MarkerStyleType.Circle);
pres.save("AsposeScatterChart.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation pres = new Presentation();
ISlide slide = pres.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.StackedColumn, 20, 20, 400, 400);
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
IChartCategory cat;
double total_value = 0.0f;
double[] total_for_Cat = new double[chart.getChartData().getCategories().size()];
for (int k = 0; k < chart.getChartData().getCategories().size(); k++) {
cat = chart.getChartData().getCategories().get_Item(k);
for (int i = 0; i < chart.getChartData().getSeries().size(); i++) {
total_for_Cat[k] = total_for_Cat[k] + (double) (chart.getChartData().getSeries().get_Item(i)
.getDataPoints().get_Item(k).getValue().getData());
}
}
double dataPontPercent = 0f;
for (int x = 0; x < chart.getChartData().getSeries().size(); x++) {
series = chart.getChartData().getSeries().get_Item(x);
series.getLabels().getDefaultDataLabelFormat().setShowLegendKey(false);
for (int j = 0; j < series.getDataPoints().size(); j++) {
IDataLabel lbl = series.getDataPoints().get_Item(j).getLabel();
dataPontPercent = (double) ((series.getDataPoints().get_Item(j).getValue().getData()))
/ (double) (total_for_Cat[j]) * 100;
IPortion port = new Portion();
port.setText(String.format("{0:F2} %", dataPontPercent));
port.getPortionFormat().setFontHeight(8f);
lbl.getTextFrameForOverriding().setText("");
IParagraph para = lbl.getTextFrameForOverriding().getParagraphs().get_Item(0);
para.getPortions().add(port);
lbl.getDataLabelFormat().setShowSeriesName(false);
lbl.getDataLabelFormat().setShowPercentage(false);
lbl.getDataLabelFormat().setShowLegendKey(false);
lbl.getDataLabelFormat().setShowCategoryName(false);
lbl.getDataLabelFormat().setShowBubbleSize(false);
}
}
// Save presentation with chart
pres.save("test.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation pres = new Presentation(sourcePptxFileName);
try {
IChart chart = (IChart) pres.getSlides().get_Item(0).getShapes().get_Item(0);
chart.getAxes().getHorizontalAxis().setCategoryAxisType(CategoryAxisType.Date);
chart.getAxes().getHorizontalAxis().setAutomaticMajorUnit(false);
chart.getAxes().getHorizontalAxis().setMajorUnit(1);
chart.getAxes().getHorizontalAxis().setMajorUnitScale(TimeUnitType.Months);
pres.Save(pptxOutPath, SaveFormat.Pptx);
} finally {
if (pres != null)
pres.dispose();
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation pres = new Presentation();
try {
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.Pie, 50, 50, 500, 400);
chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat().setShowValue(true);
chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat()
.setShowLabelAsDataCallout(true);
chart.getChartData().getSeries().get_Item(0).getLabels().get_Item(2).getDataLabelFormat()
.setShowLabelAsDataCallout(false);
pres.save(pptxFileName, SaveFormat.Pptx);
} finally {
if (pres != null)
pres.dispose();
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiating presentation
Presentation pres = new Presentation();
// Accessing the first slide
ISlide slide = pres.getSlides().get_Item(0);
// Adding the sample chart
IChart chart = slide.getShapes().addChart(ChartType.LineWithMarkers, 50, 50, 500, 400);
// Setting Chart Title
chart.hasTitle();
chart.getChartTitle().addTextFrameForOverriding("");
IPortion chartTitle = chart.getChartTitle().getTextFrameForOverriding().getParagraphs().get_Item(0)
.getPortions().get_Item(0);
chartTitle.setText("Sample Chart");
chartTitle.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
chartTitle.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.GRAY);
chartTitle.getPortionFormat().setFontHeight(20);
chartTitle.getPortionFormat().setFontBold(NullableBool.True);
chartTitle.getPortionFormat().setFontItalic(NullableBool.True);
// Setting Major grid lines format for value axis
chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().getFillFormat()
.setFillType(FillType.Solid);
chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().getFillFormat().getSolidFillColor()
.setColor(Color.BLUE);
chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().setWidth(5);
chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().setDashStyle(LineDashStyle.DashDot);
// Setting Minor grid lines format for value axis
chart.getAxes().getVerticalAxis().getMinorGridLinesFormat().getLine().getFillFormat()
.setFillType(FillType.Solid);
chart.getAxes().getVerticalAxis().getMinorGridLinesFormat().getLine().getFillFormat().getSolidFillColor()
.setColor(Color.RED);
chart.getAxes().getVerticalAxis().getMinorGridLinesFormat().getLine().setWidth(3);
// Setting value axis number format
chart.getAxes().getVerticalAxis().isNumberFormatLinkedToSource();
chart.getAxes().getVerticalAxis().setDisplayUnit(DisplayUnitType.Thousands);
chart.getAxes().getVerticalAxis().setNumberFormat("0.0%");
// Setting chart maximum, minimum values
chart.getAxes().getVerticalAxis().isAutomaticMajorUnit();
chart.getAxes().getVerticalAxis().isAutomaticMaxValue();
chart.getAxes().getVerticalAxis().isAutomaticMinorUnit();
chart.getAxes().getVerticalAxis().isAutomaticMinValue();
chart.getAxes().getVerticalAxis().setMaxValue(15f);
chart.getAxes().getVerticalAxis().setMinValue(-2f);
chart.getAxes().getVerticalAxis().setMinorUnit(0.5f);
chart.getAxes().getVerticalAxis().setMajorUnit(2.0f);
// Setting Value Axis Text Properties
IChartPortionFormat txtVal = chart.getAxes().getVerticalAxis().getTextFormat().getPortionFormat();
txtVal.setFontBold(NullableBool.True);
txtVal.setFontHeight(16);
txtVal.setFontItalic(NullableBool.True);
txtVal.getFillFormat().setFillType(FillType.Solid);
txtVal.getFillFormat().getSolidFillColor().setColor(new Color(PresetColor.DarkGreen));
txtVal.setLatinFont(new FontData("Times New Roman"));
// Setting value axis title
chart.getAxes().getVerticalAxis().hasTitle();
chart.getAxes().getVerticalAxis().getTitle().addTextFrameForOverriding("");
IPortion valtitle = chart.getAxes().getVerticalAxis().getTitle().getTextFrameForOverriding().getParagraphs()
.get_Item(0).getPortions().get_Item(0);
valtitle.setText("Primary Axis");
valtitle.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
valtitle.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.GRAY);
valtitle.getPortionFormat().setFontHeight(20);
valtitle.getPortionFormat().setFontBold(NullableBool.True);
valtitle.getPortionFormat().setFontItalic(NullableBool.True);
// Setting Major grid lines format for Category axis
chart.getAxes().getHorizontalAxis().getMajorGridLinesFormat().getLine().getFillFormat()
.setFillType(FillType.Solid);
chart.getAxes().getHorizontalAxis().getMajorGridLinesFormat().getLine().getFillFormat().getSolidFillColor()
.setColor(Color.GREEN);
chart.getAxes().getHorizontalAxis().getMajorGridLinesFormat().getLine().setWidth(5);
// Setting Minor grid lines format for Category axis
chart.getAxes().getHorizontalAxis().getMinorGridLinesFormat().getLine().getFillFormat()
.setFillType(FillType.Solid);
chart.getAxes().getHorizontalAxis().getMinorGridLinesFormat().getLine().getFillFormat().getSolidFillColor()
.setColor(Color.YELLOW);
chart.getAxes().getHorizontalAxis().getMinorGridLinesFormat().getLine().setWidth(3);
// Setting Category Axis Text Properties
IChartPortionFormat txtCat = chart.getAxes().getHorizontalAxis().getTextFormat().getPortionFormat();
txtCat.setFontBold(NullableBool.True);
txtCat.setFontHeight(16);
txtCat.setFontItalic(NullableBool.True);
txtCat.getFillFormat().setFillType(FillType.Solid);
txtCat.getFillFormat().getSolidFillColor().setColor(Color.BLUE);
txtCat.setLatinFont(new FontData("Arial"));
// Setting Category Title
chart.getAxes().getHorizontalAxis().hasTitle();
chart.getAxes().getHorizontalAxis().getTitle().addTextFrameForOverriding("");
IPortion catTitle = chart.getAxes().getHorizontalAxis().getTitle().getTextFrameForOverriding().getParagraphs()
.get_Item(0).getPortions().get_Item(0);
catTitle.setText("Sample Category");
catTitle.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
catTitle.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.GRAY);
catTitle.getPortionFormat().setFontHeight(20);
catTitle.getPortionFormat().setFontBold(NullableBool.True);
catTitle.getPortionFormat().setFontItalic(NullableBool.True);
// Setting category axis label position
chart.getAxes().getHorizontalAxis().setTickLabelPosition(TickLabelPositionType.Low);
// Setting category axis label rotation angle
chart.getAxes().getHorizontalAxis().setTickLabelRotationAngle(45);
// Setting Legends Text Properties
IChartPortionFormat txtleg = chart.getLegend().getTextFormat().getPortionFormat();
txtleg.setFontBold(NullableBool.True);
txtleg.setFontHeight(16);
txtleg.setFontItalic(NullableBool.True);
txtleg.getFillFormat().setFillType(FillType.Solid);
txtleg.getFillFormat().getSolidFillColor().setColor(new Color(PresetColor.DarkRed));
// Set show chart legends without overlapping chart
chart.getLegend().setOverlay(true);
// chart.ChartData.Series[0].PlotOnSecondAxis=true;
chart.getChartData().getSeries().get_Item(0).setPlotOnSecondAxis(true);
// Setting secondary value axis
chart.getAxes().getSecondaryVerticalAxis().isVisible();
chart.getAxes().getSecondaryVerticalAxis().getFormat().getLine().setStyle(LineStyle.ThickBetweenThin);
chart.getAxes().getSecondaryVerticalAxis().getFormat().getLine().setWidth(20);
// Setting secondary value axis Number format
chart.getAxes().getSecondaryVerticalAxis().isNumberFormatLinkedToSource();
chart.getAxes().getSecondaryVerticalAxis().setDisplayUnit(DisplayUnitType.Hundreds);
chart.getAxes().getSecondaryVerticalAxis().setNumberFormat("0.0%");
// Setting chart maximum, minimum values
chart.getAxes().getSecondaryVerticalAxis().isAutomaticMajorUnit();
chart.getAxes().getSecondaryVerticalAxis().isAutomaticMaxValue();
chart.getAxes().getSecondaryVerticalAxis().isAutomaticMinorUnit();
chart.getAxes().getSecondaryVerticalAxis().isAutomaticMinValue();
chart.getAxes().getSecondaryVerticalAxis().setMaxValue(20f);
chart.getAxes().getSecondaryVerticalAxis().setMinValue(-5f);
chart.getAxes().getSecondaryVerticalAxis().setMinorUnit(0.5f);
chart.getAxes().getSecondaryVerticalAxis().setMajorUnit(2.0f);
// Setting chart back wall color
chart.getBackWall().setThickness(1);
chart.getBackWall().getFormat().getFill().setFillType(FillType.Solid);
chart.getBackWall().getFormat().getFill().getSolidFillColor().setColor(Color.ORANGE);
chart.getFloor().getFormat().getFill().setFillType(FillType.Solid);
chart.getFloor().getFormat().getFill().getSolidFillColor().setColor(Color.RED);
// Setting Plot area color
chart.getPlotArea().getFormat().getFill().setFillType(FillType.Solid);
chart.getPlotArea().getFormat().getFill().getSolidFillColor().setColor(new Color(PresetColor.LightCyan));
// Save Presentation
pres.save("FormattedChart.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents PPTX file//Instantiate
// Presentation class that represents PPTX file
Presentation pres = new Presentation();
// Access first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add chart with default data
IChart chart = sld.getShapes().addChart(ChartType.ClusteredColumn, 0, 0, 500, 500);
// Set first series to Show Values
chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat().setShowValue(true);
// Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
// Getting the chart data WorkSheet
IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();
// Delete default generated series and categories
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
int s = chart.getChartData().getSeries().size();
s = chart.getChartData().getCategories().size();
// Adding new series
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 1, "Series 1"), chart.getType());
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 2, "Series 2"), chart.getType());
// Adding new categories
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 1, 0, "Caetegoty 1"));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 2, 0, "Caetegoty 2"));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 3, 0, "Caetegoty 3"));
// Take first chart series
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
// Now populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 1, 20));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 1, 50));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 1, 30));
// Setting automatic fill color for series
series.getFormat().getFill().setFillType(FillType.NotDefined);
// Take second chart series
series = chart.getChartData().getSeries().get_Item(1);
// Now populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 2, 30));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 2, 10));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 2, 60));
// Setting fill color for series
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(Color.GRAY);
// Save presentation with chart
pres.save("AutomaticColor.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Creating empty presentation
Presentation pres = new Presentation();
// Access first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add chart with default data
IChart chart = sld.getShapes().addChart(ChartType.StackedColumn3D, 0, 0, 500, 500);
// Getting the chart data WorkSheet
IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();
// Delete default generated series and categories
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
// Adding new series
chart.getChartData().getSeries().add(fact.getCell(0, 0, 1, "Series 1"), chart.getType());
chart.getChartData().getSeries().add(fact.getCell(0, 0, 2, "Series 2"), chart.getType());
// Adding new categories
chart.getChartData().getCategories().add(fact.getCell(0, 1, 0, "Caetegoty 1"));
chart.getChartData().getCategories().add(fact.getCell(0, 2, 0, "Caetegoty 2"));
chart.getChartData().getCategories().add(fact.getCell(0, 3, 0, "Caetegoty 3"));
// Take first chart series
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
// Populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 1, 20));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 1, 50));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 1, 30));
// Take second chart series
series = chart.getChartData().getSeries().get_Item(1);
// Populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 2, 30));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 2, 10));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 2, 60));
// Set GapWidth value
series.getParentSeriesGroup().setGapWidth(75);
// Save presentation with chart
pres.save("3Drotation.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Creating empty presentation
Presentation pres = new Presentation();
// Access first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add chart with default data
IChart chart = sld.getShapes().addChart(ChartType.StackedColumn3D, 0, 0, 500, 500);
// Getting the chart data WorkSheet
IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();
// Delete default generated series and categories
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
// Adding new series
chart.getChartData().getSeries().add(fact.getCell(0, 0, 1, "Series 1"), chart.getType());
chart.getChartData().getSeries().add(fact.getCell(0, 0, 2, "Series 2"), chart.getType());
// Adding new categories
chart.getChartData().getCategories().add(fact.getCell(0, 1, 0, "Caetegoty 1"));
chart.getChartData().getCategories().add(fact.getCell(0, 2, 0, "Caetegoty 2"));
chart.getChartData().getCategories().add(fact.getCell(0, 3, 0, "Caetegoty 3"));
// Set Rotation3D properties
chart.getRotation3D().setRightAngleAxes(true);
chart.getRotation3D().setRotationX((byte) 40);
chart.getRotation3D().setRotationY((byte) 270);
chart.getRotation3D().setDepthPercents(150);
// Take first chart series
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
// Populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 1, 20));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 1, 50));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 1, 30));
// Take second chart series
series = chart.getChartData().getSeries().get_Item(1);
// Populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 2, 30));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 2, 10));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 2, 60));
// Save presentation with chart
pres.save("3Drotation.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation object
Presentation pres = new Presentation();
// Add Pie chart on first slide
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.PieOfPie, 50, 50, 500, 400);
// Getting chart data
IChartData chartData = chart.getChartData();
// Accessing first chart series
IChartSeries series = chartData.getSeries().get_Item(0);
// Setting series properties
series.getLabels().getDefaultDataLabelFormat().setShowValue(true);
series.getParentSeriesGroup().setSecondPieSize(149);
series.getParentSeriesGroup().setPieSplitBy(PieSplitType.ByPercentage);
series.getParentSeriesGroup().setPieSplitPosition((double) 53);
// Saving presentation to disk
pres.save("pieOFpie.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Creating empty presentation//Creating empty presentation
Presentation pres = new Presentation();
// Creating a clustered column chart
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.ClusteredColumn, 100, 50, 600, 400);
// Setting series fill format to automatic
for (int i = 0; i < chart.getChartData().getSeries().size(); i++) {
chart.getChartData().getSeries().get_Item(i).getAutomaticSeriesColor();
}
// Saving presentation
pres.save("AutoFillSeries.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Create an instance of Presentation class
Presentation pres = new Presentation();
// Get reference of the slide
ISlide slide = pres.getSlides().get_Item(0);
// Add a clustered column chart on the slide
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 500, 500);
// Set Legend Properties
chart.getLegend().setX(50 / chart.getWidth());
chart.getLegend().setY(50 / chart.getHeight());
chart.getLegend().setWidth(100 / chart.getWidth());
chart.getLegend().setHeight(100 / chart.getHeight());
// Write presentation to disk
pres.save("Legend.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate the presentation//Instantiate the presentation
Presentation pres = new Presentation();
// Access the first presentation slide
ISlide slide = pres.getSlides().get_Item(0);
// Adding a default clustered column chart
IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 500, 400);
// Accessing the chart series collection
IChartSeriesCollection series = chart.getChartData().getSeries();
// Setting the preset number format
// Traverse through every chart series
for (IChartSeries ser : series) {
// Traverse through every data cell in series
for (IChartDataPoint cell : ser.getDataPoints()) {
// Setting the number format
cell.getValue().getAsCell().setPresetNumberFormat((byte) 10); // 0.00%
}
}
// Saving presentation
pres.save("PresetNumberFormat.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents PPTX file
Presentation pres = new Presentation();
// Access first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add chart with default data
IChart chart = sld.getShapes().addChart(ChartType.Pie, 100, 100, 400, 400);
// Setting chart Title
chart.getChartTitle().addTextFrameForOverriding("Sample Title");
chart.getChartTitle().getTextFrameForOverriding().getTextFrameFormat().setCenterText(NullableBool.True);
chart.getChartTitle().setHeight(20);
chart.hasTitle();
// Set first series to Show Values
chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat().setShowValue(true);
// Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
// Getting the chart data WorkSheet
IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();
// Delete default generated series and categories
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
// Adding new categories
chart.getChartData().getCategories().add(fact.getCell(0, 1, 0, "First Qtr"));
chart.getChartData().getCategories().add(fact.getCell(0, 2, 0, "2nd Qtr"));
chart.getChartData().getCategories().add(fact.getCell(0, 3, 0, "3rd Qtr"));
// Adding new series
IChartSeries series = chart.getChartData().getSeries().add(fact.getCell(0, 0, 1, "Series 1"), chart.getType());
// Now populating series data
series.getDataPoints().addDataPointForPieSeries(fact.getCell(defaultWorksheetIndex, 1, 1, 20));
series.getDataPoints().addDataPointForPieSeries(fact.getCell(defaultWorksheetIndex, 2, 1, 50));
series.getDataPoints().addDataPointForPieSeries(fact.getCell(defaultWorksheetIndex, 3, 1, 30));
// Not working in new version
// Adding new points and setting sector color
// series.IsColorVaried = true;
chart.getChartData().getSeriesGroups().get_Item(0).isColorVaried();
IChartDataPoint point = series.getDataPoints().get_Item(0);
point.getFormat().getFill().setFillType(FillType.Solid);
point.getFormat().getFill().getSolidFillColor().setColor(Color.CYAN);
// Setting Sector border
point.getFormat().getLine().getFillFormat().setFillType(FillType.Solid);
point.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.GRAY);
point.getFormat().getLine().setWidth(3.0);
point.getFormat().getLine().setStyle(LineStyle.ThinThick);
point.getFormat().getLine().setDashStyle(LineDashStyle.DashDot);
IChartDataPoint point1 = series.getDataPoints().get_Item(1);
point1.getFormat().getFill().setFillType(FillType.Solid);
point1.getFormat().getFill().getSolidFillColor().setColor(new Color(PresetColor.Brown));
// Setting Sector border
point1.getFormat().getLine().getFillFormat().setFillType(FillType.Solid);
point1.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
point1.getFormat().getLine().setWidth(3.0);
point1.getFormat().getLine().setStyle(LineStyle.Single);
point1.getFormat().getLine().setDashStyle(LineDashStyle.LargeDashDot);
IChartDataPoint point2 = series.getDataPoints().get_Item(2);
point2.getFormat().getFill().setFillType(FillType.Solid);
point2.getFormat().getFill().getSolidFillColor().setColor(new Color(PresetColor.Coral));
// Setting Sector border
point2.getFormat().getLine().getFillFormat().setFillType(FillType.Solid);
point2.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.RED);
point2.getFormat().getLine().setWidth(2.0);
point2.getFormat().getLine().setStyle(LineStyle.ThinThin);
point2.getFormat().getLine().setDashStyle(LineDashStyle.LargeDashDotDot);
// Create custom labels for each of categories for new series
IDataLabel lbl1 = series.getDataPoints().get_Item(0).getLabel();
// lbl.ShowCategoryName = true;
lbl1.getDataLabelFormat().setShowValue(true);
IDataLabel lbl2 = series.getDataPoints().get_Item(1).getLabel();
lbl2.getDataLabelFormat().setShowValue(true);
lbl2.getDataLabelFormat().setShowLegendKey(true);
lbl2.getDataLabelFormat().setShowPercentage(true);
IDataLabel lbl3 = series.getDataPoints().get_Item(2).getLabel();
lbl3.getDataLabelFormat().setShowSeriesName(true);
lbl3.getDataLabelFormat().setShowPercentage(true);
// Showing Leader Lines for Chart
series.getLabels().getDefaultDataLabelFormat().setShowLeaderLines(true);
// Setting Rotation Angle for Pie Chart Sectors
chart.getChartData().getSeriesGroups().get_Item(0).setFirstSliceAngle(180);
// Save presentation with chart
pres.save("AsposePieChart.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation pres = new Presentation();
ISlide slide = pres.getSlides().get_Item(0);
// Creating the default chart
IChart chart = slide.getShapes().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.getChartData().getChartDataWorkbook();
// Delete demo series
chart.getChartData().getSeries().clear();
// Add new series
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 1, 1, "Series 1"), chart.getType());
IPPImage imgx1 = null;
try {
imgx1 = pres.getImages().addImage(new FileInputStream(new File("Desert.jpg")));
} catch (IOException e) {
}
// Set the picture
IPPImage imgx2 = null;
try {
imgx2 = pres.getImages().addImage(
new FileInputStream(new File("C:\\Users\\Public\\Pictures\\Sample Pictures\\Tulips.jpg")));
} catch (IOException e) {
}
// Take first chart series
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
// Add new point (1:3) there.
IChartDataPoint point = series.getDataPoints()
.addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 1, 1, (double) 4.5));
point.getMarker().getFormat().getFill().setFillType(FillType.Picture);
point.getMarker().getFormat().getFill().getPictureFillFormat().getPicture().setImage(imgx1);
point = series.getDataPoints()
.addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 2, 1, (double) 2.5));
point.getMarker().getFormat().getFill().setFillType(FillType.Picture);
point.getMarker().getFormat().getFill().getPictureFillFormat().getPicture().setImage(imgx2);
point = series.getDataPoints()
.addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 3, 1, (double) 3.5));
point.getMarker().getFormat().getFill().setFillType(FillType.Picture);
point.getMarker().getFormat().getFill().getPictureFillFormat().getPicture().setImage(imgx1);
point = series.getDataPoints()
.addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 4, 1, (double) 4.5));
point.getMarker().getFormat().getFill().setFillType(FillType.Picture);
point.getMarker().getFormat().getFill().getPictureFillFormat().getPicture().setImage(imgx2);
// Changing the chart series marker
series.getMarker().setSize(15);
pres.save("AsposeScatterChart.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Create an instance of Presentation class
Presentation pres = new Presentation();
// Get reference of the slide
ISlide sld = pres.getSlides().get_Item(0);
// Adding a chart on slide
IChart ch = sld.getShapes().addChart(ChartType.ClusteredColumn, 20, 20, 500, 300);
// Setting the position of label from axis
ch.getAxes().getHorizontalAxis().setLabelOffset(500);
// Write the presentation to disk
pres.save("D:\\Position.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation pres = new Presentation();
{
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.Doughnut, 50, 50, 400, 400);
chart.getChartData().getSeriesGroups().get_Item(0).setDoughnutHoleSize((byte) 90);
pres.save("ChartSeries.API.DoughnutHoleSize.pptx", SaveFormat.Pptx);
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents PPTX file//Instantiate
// Presentation class that represents PPTX file
Presentation pres = new Presentation("AsposeChart.pptx");
// Access first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add chart with default data
IChart chart = (IChart) sld.getShapes().get_Item(0);
// Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
// Getting the chart data WorkSheet
IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();
// 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.getChartData().getSeries().get_Item(0);
// Now updating series data
fact.getCell(defaultWorksheetIndex, 0, 1, "New_Series1");// modifying
// series
// name
series.getDataPoints().get_Item(0).getValue().setData(90);
series.getDataPoints().get_Item(1).getValue().setData(123);
series.getDataPoints().get_Item(2).getValue().setData(44);
// Take Second chart series
series = chart.getChartData().getSeries().get_Item(1);
// Now updating series data
fact.getCell(defaultWorksheetIndex, 0, 2, "New_Series2");// modifying
// series
// name
series.getDataPoints().get_Item(0).getValue().setData(23);
series.getDataPoints().get_Item(1).getValue().setData(67);
series.getDataPoints().get_Item(2).getValue().setData(99);
// Now, Adding a new series
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 3, "Series 3"), chart.getType());
// Take 3rd chart series
series = chart.getChartData().getSeries().get_Item(2);
// Now populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 3, 20));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 3, 50));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 3, 30));
chart.setType(ChartType.ClusteredCylinder);
// Save presentation with chart
pres.save("AsposeChartModified.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation pres = new Presentation("CustomDemo.pptx");
// Create a reference to DocumentProperties object associated with
// Presentation
IDocumentProperties dp = pres.getDocumentProperties();
// Access and modify custom properties
for (int i = 0; i < dp.getCount(); i++) {
// Display names and values of custom properties
System.out.println("Custom Property Name : " + dp.getPropertyName(i));
System.out.println("Custom Property Value : " + dp.get_Item(dp.getPropertyName(i)));
// Modify values of custom properties
dp.set_Item(dp.getPropertyName(i), "New Value " + (i + 1));
}
// Save your presentation to a file
pres.save("CustomDemoModified.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate the Presentation class that represents the presentation
Presentation pres = new Presentation("HelloWorld.pptx");
// Create a reference to IDocumentProperties object associated with
// Presentation
IDocumentProperties dp = pres.getDocumentProperties();
// Display the built-in properties
System.out.println("Category : " + dp.getCategory());
System.out.println("Current Status : " + dp.getContentStatus());
System.out.println("Creation Date : " + dp.getCreatedTime());
System.out.println("Author : " + dp.getAuthor());
System.out.println("Description : " + dp.getComments());
System.out.println("KeyWords : " + dp.getKeywords());
System.out.println("Last Modified By : " + dp.getLastSavedBy());
System.out.println("Supervisor : " + dp.getManager());
System.out.println("Modified Date : " + dp.getLastSavedTime());
System.out.println("Presentation Format : " + dp.getPresentationFormat());
System.out.println("Last Print Date : " + dp.getLastPrinted());
System.out.println("Is Shared between producers : " + dp.getSharedDoc());
System.out.println("Subject : " + dp.getSubject());
System.out.println("Title : " + dp.getTitle());
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("Source.odp");
// Saving the PPTX presentation to PPTX format
pres.save("Aspose.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Accessing the Document Properties of a Password Protected
// Presentation without Password
// creating instance of load options to set the presentation access
// password
com.aspose.slides.LoadOptions loadOptions = new com.aspose.slides.LoadOptions();
// Setting the access password to null
loadOptions.setPassword(null);
// Setting the access to document properties
loadOptions.setOnlyLoadDocumentProperties(true);
// Opening the presentation file by passing the file path and load
// options to the constructor of Presentation class
Presentation pres = new Presentation("demoPassDocument.pptx", loadOptions);
// Getting Document Properties
IDocumentProperties docProps = pres.getDocumentProperties();
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation presPPTX = new Presentation();
// Getting Document Properties
IDocumentProperties dProps = presPPTX.getDocumentProperties();
// Adding Custom properties
dProps.set_Item("New Custom", 12);
dProps.set_Item("My Name", "Mudassir");
dProps.set_Item("Custom", 124);
// Getting property name at particular index
String getPropertyName = dProps.getPropertyName(2);
// Removing selected property
dProps.remove(getPropertyName);
// Saving presentation
presPPTX.save("CustomDemo.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// The path to the documents directory.
String dataDir = Utils.getDataDir(ConvertingPresentationToPDFIncludingHiddenSlides.class);
Presentation pres = new Presentation(dataDir + "demo.pptx");
try {
// Instantiate the PdfOptions class
PdfOptions pdfOptions = new PdfOptions();
// Specify that the generated document should include hidden slides
pdfOptions.setShowHiddenSlides(true);
// Save the presentation to PDF with specified options
pres.save(dataDir + "Presentation.pdf", SaveFormat.Pdf, pdfOptions);
} finally {
if (pres != null)
pres.dispose();
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
public void CustomHtmlExport() {
// Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("Presentation.pptx");
// Setting HTML Options
HtmlOptions opts = new HtmlOptions();
opts.setHtmlFormatter(HtmlFormatter.createCustomFormatter(new CustomFormattingController()));
// Saving to individual files
for (int i = 0; i < pres.getSlides().size(); i++)
pres.save("slide" + (i + 1) + ".html", new int[] { i + 1 }, SaveFormat.Html, opts);
}
private class CustomFormattingController implements IHtmlFormattingController {
private String SlideHeader = "<div class=\"slide\" name=\"slide\" id=\"slide{0}\">";
private String SlideFooter = "</div>";
public CustomFormattingController() {
}
public void writeDocumentStart(IHtmlGenerator generator, IPresentation presentation) {
}
public void writeDocumentEnd(IHtmlGenerator generator, IPresentation presentation) {
}
public void writeSlideStart(IHtmlGenerator generator, ISlide slide) {
generator.addHtml(String.format(SlideHeader, generator.getSlideIndex() + 1));
}
public void writeSlideEnd(IHtmlGenerator generator, ISlide slide) {
generator.addHtml(SlideFooter);
}
public void writeShapeStart(IHtmlGenerator generator, IShape shape) {
}
public void writeShapeEnd(IHtmlGenerator generator, IShape shape) {
}
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("demo.pptx");
// Setting array of slides positions
int[] slides = new int[] { 2, 3, 5 };
// Save the presentation to PDF
pres.save("demo.pdf", slides, SaveFormat.Pdf);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a PPTX file
Presentation pres = new Presentation("Aspose.ppt");
// Saving the PPTX presentation to PPTX format
pres.save("Aspose.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
//Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("TestNotes.pptx");
//Saving the presentation to PDF notes
pres.save("TestNotes.pdf", SaveFormat.PdfNotes);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
//Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("TestNotes.pptx");
//Saving the presentation to TIFF notes
pres.save("TestNotes.tiff", SaveFormat.TiffNotes);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("demo.pptx");
HtmlOptions htmlOpt = new HtmlOptions();
htmlOpt.setHtmlFormatter(HtmlFormatter.createDocumentFormatter("", false));
// Saving the presentation to HTML
pres.save("demo.html", SaveFormat.Html, htmlOpt);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("demo.pptx");
// Instantiate the PdfOptions class
PdfOptions opts = new PdfOptions();
// Setting PDF password
opts.setPassword("password");
// Save the presentation to password protected PDF
pres.save("demo.pdf", SaveFormat.Pdf, opts);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("demo.pptx");
// Instantiate the PdfOptions class
PdfOptions opts = new PdfOptions();
// Set Jpeg Quality
opts.setJpegQuality((byte) 90);
// Define behavior for metafiles
opts.setSaveMetafilesAsPng(true);
// Set Text Compression level
opts.setTextCompression(PdfTextCompression.Flate);
// Define the PDF standard
opts.setCompliance(PdfCompliance.Pdf15);
// Save the presentation to PDF with specified options
pres.save("demo.pdf", SaveFormat.Pdf, opts);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("demo.pptx");
// Save the presentation to PDF with default options
pres.save("demoDefault.pdf", SaveFormat.Pdf);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a Presentation file
Presentation pres = new Presentation("demo.pptx");
TiffOptions options = new TiffOptions();
options.setPixelFormat(ImagePixelFormat.Format8bppIndexed);
/*
* 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
pres.save("demo.tiff", SaveFormat.Tiff, options);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a Presentation file
Presentation pres = new Presentation("demo.pptx");
// Instantiate the TiffOptions class
TiffOptions opts = new TiffOptions();
// Setting compression type
// Possible values are:
// Default - Specifies the default compression scheme (LZW).
// None - Specifies no compression.
// CCITT3
// CCITT4
// LZW
// RLE
opts.setCompressionType(TiffCompressionTypes.Default);
// 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.setDpiX(200);
opts.setDpiY(100);
// Set Image Size
opts.setImageSize(new java.awt.Dimension(1728, 1078));
// Save the presentation to TIFF with specified image size
pres.save("demo.tiff", SaveFormat.Tiff, opts);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("demo.pptx");
// Saving the presentation to TIFF document
pres.save("demo.tiff", SaveFormat.Tiff);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("demo.pptx");
// Saving the presentation to XPS document
pres.save("demo.xps", SaveFormat.Xps);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("demo.pptx");
// Instantiate the TiffOptions class
XpsOptions opts = new XpsOptions();
// Save MetaFiles as PNG
opts.setSaveMetafilesAsPng(true);
// Save the presentation to XPS document
pres.save("demo.xps", SaveFormat.Xps, opts);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = (ISlide) pres.getSlides().get_Item(0);
// Add an AutoShape of Rectangle type
IAutoShape ashp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 150, 75, 150, 50);
// Add ITextFrame to the Rectangle
ashp.addTextFrame("Hello World");
// Change the text color to Black (which is White by default)
ashp.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().getFillFormat()
.setFillType(FillType.Solid);
ashp.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().getFillFormat()
.getSolidFillColor().setColor(java.awt.Color.BLACK);
// Change the line color of the rectangle to White
ashp.getShapeStyle().getLineColor().setColor(java.awt.Color.WHITE);
// Remove any fill formatting in the shape
ashp.getFillFormat().setFillType(FillType.NoFill);
// Save the presentation to disk
pres.save("HelloWorld.pptx", com.aspose.slides.SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Getting the file format using the PresentationFactory class instance
int format = PresentationFactory.getInstance().getPresentationInfo("test.pdf").getLoadFormat();
// It will return "LoadFormat.Unknown" or 255 if the file is other than
// presentation formats
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
IPresentationInfo info;
info = PresentationFactory.getInstance().getPresentationInfo("HelloWorld.pptx");
switch (info.getLoadFormat()) {
case LoadFormat.Pptx:
break;
case LoadFormat.Unknown:
break;
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation pres = new Presentation("CustomDemo.pptx");
// Create a reference to DocumentProperties object associated with
// Presentation
IDocumentProperties dp = pres.getDocumentProperties();
// Access and modify custom properties
for (int i = 0; i < dp.getCount(); i++) {
// Display names and values of custom properties
System.out.println("Custom Property Name : " + dp.getPropertyName(i));
System.out.println("Custom Property Value : " + dp.get_Item(dp.getPropertyName(i)));
// Modify values of custom properties
dp.set_Item(dp.getPropertyName(i), "New Value " + (i + 1));
}
// Save your presentation to a file
pres.save("CustomDemoModified.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate the Presentation class that represents the presentation
Presentation pres = new Presentation("HelloWorld.pptx");
// Create a reference to IDocumentProperties object associated with
// Presentation
IDocumentProperties dp = pres.getDocumentProperties();
// Display the builtin properties
System.out.println("Category : " + dp.getCategory());
System.out.println("Current Status : " + dp.getContentStatus());
System.out.println("Creation Date : " + dp.getCreatedTime());
System.out.println("Author : " + dp.getAuthor());
System.out.println("Description : " + dp.getComments());
System.out.println("KeyWords : " + dp.getKeywords());
System.out.println("Last Modified By : " + dp.getLastSavedBy());
System.out.println("Supervisor : " + dp.getManager());
System.out.println("Modified Date : " + dp.getLastSavedTime());
System.out.println("Presentation Format : " + dp.getPresentationFormat());
System.out.println("Last Print Date : " + dp.getLastPrinted());
System.out.println("Is Shared between producers : " + dp.getSharedDoc());
System.out.println("Subject : " + dp.getSubject());
System.out.println("Title : " + dp.getTitle());
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation presPPTX = new Presentation();
// Getting Document Properties
IDocumentProperties dProps = presPPTX.getDocumentProperties();
// Adding Custom properties
dProps.set_Item("New Custom", 12);
dProps.set_Item("My Name", "Mudassir");
dProps.set_Item("Custom", 124);
// Getting property name at particular index
String getPropertyName = dProps.getPropertyName(2);
// Removing selected property
dProps.remove(getPropertyName);
// Saving presentation
presPPTX.save("CustomDemo.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation pres = new Presentation("HelloWorld.pptx");
// Create a reference to IDocumentProperties object associated with
// Presentation
IDocumentProperties dp = pres.getDocumentProperties();
// Set the built-in properties
dp.setAuthor("Aspose.Slides for Java");
dp.setTitle("Modifying Presentation Properties");
dp.setSubject("Aspose Subject");
dp.setComments("Aspose Description");
dp.setManager("Aspose Manager");
// Save your presentation to a file
pres.save("DocProps.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
//Instantiate a Presentation object that represents a PPTX file
Presentation pres = new Presentation("Test.pptx");
//Removing the hyperlinks from presentation
pres.getHyperlinkQueries().removeAllHyperlinks();
//Writing the presentation as a PPTX file
pres.save("TestSaved.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation pres = new Presentation("HelloWorld.pptx");
// Create a reference to IDocumentProperties object associated with
// Presentation
IDocumentProperties dp = pres.getDocumentProperties();
// Set the built-in properties
dp.setAuthor("Aspose.Slides for Java");
dp.setTitle("Modifying Presentation Properties");
dp.setSubject("Aspose Subject");
dp.setComments("Aspose Description");
dp.setManager("Aspose Manager");
// Save your presentation to a file
pres.save("DocProps.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Loading Pass protected presentation
// creating instance of load options to set the presentation access
// password
com.aspose.slides.LoadOptions loadOptions = new com.aspose.slides.LoadOptions();
// Setting the access password
loadOptions.setPassword("pass");
// Opening the presentation file by passing the file path and load
// options to the constructor of Presentation class
Presentation pres = new Presentation("demoPass.pptx", loadOptions);
// Printing the total number of slides present in the presentation
System.out.println(pres.getSlides().size());
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Opening the presentation file by passing the file path to the
// constructor of Presentation class
Presentation pres = new Presentation("HelloWorld.pptx");
// Printing the total number of slides present in the presentation
System.out.println(pres.getSlides().size());
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// read the info of presentation
IPresentationInfo info = PresentationFactory.getInstance().getPresentationInfo("presentation.pptx");
// obtain the current properties
IDocumentProperties props = info.readDocumentProperties();
// set the new values of Author and Title fields
props.setAuthor("New Author");
props.setTitle("New Title");
// update the presentation with a new values
info.updateDocumentProperties(props);
info.writeBindedPresentation("presentation.pptx");
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
public static void main(String args[]) {
updateByTemplate();
}
private static void updateByTemplate() {
DocumentProperties template = new DocumentProperties();
template.setAuthor("Template Author");
template.setTitle("Template Title");
template.setCategory("Template Category");
template.setKeywords("Keyword1, Keyword2, Keyword3");
template.setCompany("Our Company");
template.setComments("Created from template");
template.setContentType("Template Content");
template.setSubject("Template Subject");
updateByTemplate("doc1.pptx", template);
updateByTemplate("doc2.odp", template);
updateByTemplate("doc3.ppt", template);
}
private static void updateByTemplate(String path, IDocumentProperties template) {
IPresentationInfo toUpdate = PresentationFactory.getInstance().getPresentationInfo(path);
toUpdate.updateDocumentProperties(template);
toUpdate.writeBindedPresentation(path);
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
public static void main(String args[]) {
updateByTemplate();
}
private static void updateByTemplate() {
DocumentProperties template;
IPresentationInfo info = PresentationFactory.getInstance().getPresentationInfo("presentation.pptx");
template = (DocumentProperties) info.readDocumentProperties();
template.setAuthor("Template Author");
template.setTitle("Template Title");
template.setCategory("Template Category");
template.setKeywords("Keyword1, Keyword2, Keyword3");
template.setCompany("Our Company");
template.setComments("Created from template");
template.setContentType("Template Content");
template.setSubject("Template Subject");
updateByTemplate("doc1.pptx", template);
updateByTemplate("doc2.odp", template);
updateByTemplate("doc3.ppt", template);
}
private static void updateByTemplate(String path, IDocumentProperties template) {
IPresentationInfo toUpdate = PresentationFactory.getInstance().getPresentationInfo(path);
toUpdate.updateDocumentProperties(template);
toUpdate.writeBindedPresentation(path);
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Opening the presentation file
Presentation pres = new Presentation("demoWriteProtected.pptx");
// Checking if presentation is write protected
if (pres.getProtectionManager().isWriteProtected())
// Removing Write protection
pres.getProtectionManager().removeWriteProtection();
// Saving presentation
pres.save("newDemo.pptx", com.aspose.slides.SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Opening the presentation file
Presentation pres = new Presentation();
// Setting view type
pres.getViewProperties().setLastView((byte) ViewType.SlideMasterView);
// Saving presentation
pres.save("newDemo.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object to load source file
Presentation presentation = new Presentation("MyTest.pptx");
// Instantiate Presentation object
Presentation auxPresentation = new Presentation();
// Loading slide for cloning
ISlide slide = presentation.getSlides().get_Item(0);
// Cloning slide to Presentation at position 0 or first
auxPresentation.getSlides().insertClone(0, slide);
// Set slide size type
auxPresentation.getSlideSize().setType(SlideSizeType.Custom);
// Setting custom slide size
Dimension2D dimension = presentation.getSlideSize().getSize();
dimension.setSize(612F, 792F);
auxPresentation.getSlideSize().setSize(dimension);
// Save Presentation to disk
auxPresentation.save("testPDFnotes.pdf", SaveFormat.PdfNotes);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a PPT file
Presentation pres = new Presentation();
// ....do some work here.....
// Setting Password
pres.getProtectionManager().encrypt("pass");
// Save your presentation to a file
pres.save("demoPass.pptx", com.aspose.slides.SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a PPT file
Presentation pres = new Presentation();
// ....do some work here.....
// Setting access to document properties in password protected mode
pres.getProtectionManager().setEncryptDocumentProperties(false);
// Setting Password
pres.getProtectionManager().encrypt("pass");
// Save your presentation to a file
pres.save("demoPassDocument.pptx", com.aspose.slides.SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Saving a Presentation to File
// Instantiate a Presentation object that represents a PPT file
Presentation pres = new Presentation();
// ...do some work here...
// Save your presentation to a file
pres.save("demoPass.pptx", com.aspose.slides.SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a PPT file
Presentation pres = new Presentation();
// ....do some work here.....
// Setting Write protection Password
pres.getProtectionManager().setWriteProtection("test");
// Save your presentation to a file
pres.save("demoWriteProtected.pptx", com.aspose.slides.SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Create an instance of Presentation class
Presentation pres = new Presentation();
// Setting View Properties of Presentation
pres.getViewProperties().getSlideViewProperties().setScale(50); //zoom value in percentages for slide view
pres.getViewProperties().getNotesViewProperties().setScale(50); //zoom value in percentages for notes view
// Write the presentation as a PPTX file
pres.save("Zoom.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Opening the presentation file by passing the file path to the
// constructor of Presentation class
Presentation pres = new Presentation("HelloWorld.pptx");
// Get the slide number
int firstSlideNumber = pres.getFirstSlideNumber();
// Set the slide number
pres.setFirstSlideNumber(10);
// Write the presentation to disk
pres.save("HelloWorld.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Getting the file format using the PresentationFactory class instance
int format = PresentationFactory.getInstance().getPresentationInfo("test.pdf").getLoadFormat();
// It will return "LoadFormat.Unknown" or 255 if the file is other than
// presentation formats
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation pres = new Presentation("Sample.pptx");
try {
SwfOptions swfOptions = new SwfOptions();
swfOptions.setViewerIncluded(false);
// Saving presentation
pres.save("Sample.swf", SaveFormat.Swf, swfOptions);
} catch (Exception e) {
System.out.println(e.getMessage());
} finally {
if (pres != null)
pres.dispose();
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation pres = new Presentation("Sample.pptx");
IAutoShape shape = (IAutoShape) pres.getSlides().get_Item(0).getShapes().get_Item(0);
ITextFrame textFrame = (ITextFrame) shape.getTextFrame();
for (IParagraph paragraph : textFrame.getParagraphs()) {
for (IPortion portion : paragraph.getPortions()) {
Point2D.Float point = portion.getCoordinates();
System.out.println("X: " + point.x + " Y: " + point.y);
}
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation pres = new Presentation("Sample.pptx");
IAutoShape shape = (IAutoShape) pres.getSlides().get_Item(0).getShapes().get_Item(0);
ITextFrame textFrame = (ITextFrame) shape.getTextFrame();
Rectangle2D.Float rect = ((IParagraph) textFrame.getParagraphs().get_Item(0)).getRect();
System.out.println("X: " + rect.x + " Y: " + rect.y + " Width: " + rect.width + " Height: " + rect.height);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Create an instance of Presentation class
Presentation pres = new Presentation();
ISlide slide = pres.getSlides().get_Item(0);
// Add a shape on slide
IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Ellipse, 30, 30, 100, 100);
shape.getFillFormat().setFillType(FillType.Solid);
shape.getFillFormat().getSolidFillColor().setColor(Color.GREEN);
ILineFillFormat format = shape.getLineFormat().getFillFormat();
format.setFillType(FillType.Solid);
format.getSolidFillColor().setColor(Color.ORANGE);
shape.getLineFormat().setWidth(2.0);
// Set ThreeDFormat properties of shape
shape.getThreeDFormat().setDepth(4);
shape.getThreeDFormat().getBevelTop().setBevelType(BevelPresetType.Circle);
shape.getThreeDFormat().getBevelTop().setHeight(6);
shape.getThreeDFormat().getBevelTop().setWidth(6);
shape.getThreeDFormat().getCamera().setCameraType(CameraPresetType.OrthographicFront);
shape.getThreeDFormat().getLightRig().setLightType(LightRigPresetType.ThreePt);
shape.getThreeDFormat().getLightRig().setDirection(LightingDirection.Top);
// Write the presentation as a PPTX file
pres.save("Bavel.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
try {
// Embed video inside presentation
IVideo vid = pres.getVideos().addVideo(new FileInputStream(new File("Wildlife.wmv")));
// Add Video Frame
IVideoFrame vf = sld.getShapes().addVideoFrame(50, 150, 300, 350, vid);
// Set video to Video Frame
vf.setEmbeddedVideo(vid);
// Set Play Mode and Volume of the Video
vf.setPlayMode(VideoPlayModePreset.Auto);
vf.setVolume(AudioVolumeMode.Loud);
// Write the PPTX file to disk
pres.save("VideoFrame.pptx", SaveFormat.Pptx);
} catch (Exception e) {
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Load the wav sound file to stream
try {
FileInputStream fstr = new FileInputStream(new File("06.wav"));
// Add Audio Frame
IAudioFrame af = sld.getShapes().addAudioFrameEmbedded(50, 150, 100, 100, fstr);
// Set Play Mode and Volume of the Audio
af.setPlayMode(AudioPlayModePreset.Auto);
af.setVolume(AudioVolumeMode.Loud);
} catch (Exception e) {
}
// Write the PPTX file to disk
pres.save("AudioFrameEmbed.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add AutoShape of ellipse type
IShape shp = sld.getShapes().addAutoShape(ShapeType.Ellipse, 50, 150, 150, 50);
// Apply some formatting to ellipse shape
shp.getFillFormat().setFillType(FillType.Solid);
shp.getFillFormat().getSolidFillColor().setColor(new Color(PresetColor.Chocolate));
// Apply some formatting to the line of Ellipse
shp.getLineFormat().getFillFormat().setFillType(FillType.Solid);
shp.getLineFormat().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
shp.getLineFormat().setWidth(5);
// Write the PPTX file to disk
pres.save("EllipseShp1.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add AutoShape of ellipse type
sld.getShapes().addAutoShape(ShapeType.Ellipse, 50, 150, 150, 50);
// Write the PPTX file to disk
pres.save("EllipseShp1.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate PresentationEx class that represents the PPTX file
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add an AutoShape of type line
sld.getShapes().addAutoShape(ShapeType.Line, 50, 150, 300, 0);
// Write the PPTX to Disk
pres.save("LineShape1.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Instantiate the Image class
IPPImage imgx = null;
try {
imgx = pres.getImages().addImage(new FileInputStream(new File("asp.jpg")));
} catch (IOException e) {
}
// Add Picture Frame with height and width equivalent of Picture
IPictureFrame pf = sld.getShapes().addPictureFrame(ShapeType.Rectangle, 50, 150, imgx.getWidth(),
imgx.getHeight(), imgx);
// Setting relative scale width and height
pf.setRelativeScaleHeight(0.8f);
pf.setRelativeScaleWidth(1.35f);
// Write the PPTX file to disk
pres.save("RectPicFrame.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Instantiate the Image class
IPPImage imgx = null;
try {
imgx = pres.getImages().addImage(new FileInputStream(new File("asp.jpg")));
} catch (IOException e) {
}
// Add Picture Frame with height and width equivalent of Picture
sld.getShapes().addPictureFrame(ShapeType.Rectangle, 50, 150, imgx.getWidth(), imgx.getHeight(), imgx);
// Write the PPTX file to disk
pres.save("RectPicFrame.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Instantiate the Image class
IPPImage imgx = null;
try {
imgx = pres.getImages().addImage(new FileInputStream(new File("asp.jpg")));
} catch (IOException e) {
}
// Add Picture Frame with height and width equivalent of Picture
IPictureFrame pf = sld.getShapes().addPictureFrame(ShapeType.Rectangle, 50, 150, imgx.getWidth(),
imgx.getHeight(), imgx);
// Apply some formatting to PictureFrameEx
pf.getLineFormat().getFillFormat().setFillType(FillType.Solid);
pf.getLineFormat().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
pf.getLineFormat().setWidth(20);
pf.setRotation(45);
// Write the PPTX file to disk
pres.save("RectPicFrame.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add AutoShape of ellipse type
IShape shp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 50, 150, 150, 50);
// Apply some formatting to ellipse shape
shp.getFillFormat().setFillType(FillType.Solid);
shp.getFillFormat().getSolidFillColor().setColor(new Color(PresetColor.Chocolate));
// Apply some formatting to the line of Ellipse
shp.getLineFormat().getFillFormat().setFillType(FillType.Solid);
shp.getLineFormat().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
shp.getLineFormat().setWidth(5);
// Write the PPTX file to disk
pres.save("RecShp2.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add AutoShape of ellipse type
IShape shp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 50, 150, 150, 50);
// Write the PPTX file to disk
pres.save("RecShp1.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add Video Frame
IVideoFrame vf = sld.getShapes().addVideoFrame(50, 150, 300, 150, "01.avi");
// Set Play Mode and Volume of the Video
vf.setPlayMode(VideoPlayModePreset.Auto);
vf.setVolume(AudioVolumeMode.Loud);
// Write the PPTX file to disk
pres.save("VideoFrame.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Create an instance of Presentation class
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add Video Frame
IVideoFrame vf = sld.getShapes().addVideoFrame(50, 150, 300, 150, "Wildlife.mp4");
// Set Image
IPPImage img = null;
img = pres.getImages().addImage(new FileInputStream(new File("test.png")));
vf.getPictureFormat().getPicture().setImage(img);
// Write the PPTX file to disk
pres.save("Test.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
public static void TestLineDirection() {
Presentation pres = new Presentation("LineExample.pptx");
Slide slide = (Slide) pres.getSlides().get_Item(0);
Shape shape;
for (int i = 0; i < slide.getShapes().size(); i++) {
double dir = 0.0;
shape = (Shape) slide.getShapes().get_Item(i);
if (shape instanceof AutoShape) {
AutoShape ashp = (AutoShape) shape;
if (ashp.getShapeType() == (byte) ShapeType.Line) {
dir = getDirection(ashp.getWidth(), ashp.getHeight(), ashp.getFrame().getFlipH() != 0,
ashp.getFrame().getFlipV() != 0);
}
} else if (shape instanceof Connector) {
Connector ashp = (Connector) shape;
dir = getDirection(ashp.getWidth(), ashp.getHeight(), ashp.getFrame().getFlipH() != 0,
ashp.getFrame().getFlipV() != 0);
}
System.out.println(dir);
}
}
public static double getDirection(float w, float h, boolean flipH, boolean flipV) {
float endLineX = w * (flipH ? -1 : 1);
float endLineY = h * (flipV ? -1 : 1);
float endYAxisX = 0;
float endYAxisY = h;
double angle = (java.lang.Math.atan2(endYAxisY, endYAxisX) - java.lang.Math.atan2(endLineY, endLineX));
if (angle < 0)
angle += 2 * Math.PI;
return angle * 180.0 / Math.PI;
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class
Presentation srcPres = new Presentation("Source Frame.pptx");
// Accessing source slide shape collection
IShapeCollection sourceShapes = srcPres.getSlides().get_Item(0).getShapes();
ILayoutSlide blankLayout = srcPres.getMasters().get_Item(0).getLayoutSlides().getByType(SlideLayoutType.Blank);
ISlide destSlide = srcPres.getSlides().addEmptySlide(blankLayout);
// Accessing destination slide shape collection
IShapeCollection destShapes = destSlide.getShapes();
// Clone shapes by using different methods
destShapes.addClone(sourceShapes.get_Item(1), 50, 150 + sourceShapes.get_Item(0).getHeight());
destShapes.addClone(sourceShapes.get_Item(2));
destShapes.addClone(sourceShapes.get_Item(3), 50, 200, 50, 50);
destShapes.addClone(sourceShapes.get_Item(4));
destShapes.addClone(sourceShapes.get_Item(5), 300, 300, 50, 200);
destShapes.insertClone(0, sourceShapes.get_Item(0), 50, 150);
// Write the PPTX file to disk
srcPres.save("CloneShape.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX file
Presentation input = new Presentation();
// Accessing shapes collection for selected slide
IShapeCollection shapes = input.getSlides().get_Item(0).getShapes();
// 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.setStartShapeConnectedTo(ellipse);
connector.setEndShapeConnectedTo(rectangle);
connector.reroute();
// Saving Presentation
input.save("output.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX file
Presentation input = new Presentation();
// Accessing shapes collection for selected slide
IShapeCollection shapes = input.getSlides().get_Item(0).getShapes();
// 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.setStartShapeConnectedTo(ellipse);
connector.setEndShapeConnectedTo(rectangle);
// Setting the desired connection site index of Ellipse shape for
// connector to get connected
int wantedIndex = 6;
// Checking if desired index is less than maximum site index count
if (ellipse.getConnectionSiteCount() > wantedIndex) {
// Setting the desired connection site for connector on Ellipse
connector.setStartShapeConnectionSiteIndex(wantedIndex);
}
// Saving presentation
input.save("output.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation class that represents the presentation
// file
Presentation p = new Presentation("shape_thumbnail.pptx");
// Create a Appearance bound shape image
BufferedImage image = p.getSlides().get_Item(0).getShapes().get_Item(0)
.getThumbnail(ShapeThumbnailBounds.Appearance, 1, 1);
ImageIO.write(image, "jpeg", new File("PPTX_thumbnail.jpg"));
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation class that represents the presentation
// file
Presentation p = new Presentation("shape_thumbnail.pptx");
// Create a full scale image
BufferedImage image = p.getSlides().get_Item(0).getShapes().get_Item(0).getThumbnail(ShapeThumbnailBounds.Shape,
1, 1);
try {
// Save the image to disk in PNG format
ImageIO.write(image, "jpeg", new File("d:\\Aspose Data\\ContentBG_tnail.jpg"));
} catch (Exception e) {
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX file
Presentation pres = new Presentation();
// Add SmartArt
ISmartArt smart = pres.getSlides().get_Item(0).getShapes().addSmartArt(10, 10, 400, 300,
SmartArtLayoutType.BasicCycle);
// Obtain the reference of a node by using its Index
ISmartArtNode node = smart.getNodes().get_Item(1);
// Generating SmartArt node thumbnail
BufferedImage image = node.getShapes().get_Item(0).getThumbnail();
try {
// Save the image to disk in PNG format
ImageIO.write(image, "png", new File("NodeImage.png"));
} catch (Exception e) {
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation class that represents the presentation
// file
Presentation p = new Presentation("shape_thumbnail.pptx");
// Create a full scale image
BufferedImage image = p.getSlides().get_Item(0).getShapes().get_Item(0).getThumbnail();
try {
// Save the image to disk in PNG format
ImageIO.write(image, "jpeg", new File("ContentBG_tnail.jpg"));
} catch (Exception e) {
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX//Instantiate
// Presentation class that represents the PPTX
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add AutoShape of ellipse type
IShape shp = sld.getShapes().addAutoShape(ShapeType.Ellipse, 50, 150, 75, 150);
// Apply some Gradient formatting to ellipse shape
shp.getFillFormat().setFillType(FillType.Gradient);
shp.getFillFormat().getGradientFormat().setGradientShape(GradientShape.Linear);
// Set the Gradient Direction
shp.getFillFormat().getGradientFormat().setGradientDirection(GradientDirection.FromCorner2);
// Add two Gradient Stops
shp.getFillFormat().getGradientFormat().getGradientStops().add((float) 1.0, Color.pink);
shp.getFillFormat().getGradientFormat().getGradientStops().add((float) 0, Color.red);
// Write the PPTX file to disk
pres.save("EllipseShpGrad.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add AutoShape of rectangle type
IShape shp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 50, 150, 75, 150);
// Set the fill type to Pattern
shp.getFillFormat().setFillType(FillType.Pattern);
// Set the pattern style
shp.getFillFormat().getPatternFormat().setPatternStyle(PatternStyle.Trellis);
// Set the pattern back and fore colors
shp.getFillFormat().getPatternFormat().getBackColor().setColor(Color.LIGHT_GRAY);
shp.getFillFormat().getPatternFormat().getForeColor().setColor(Color.YELLOW);
// Write the PPTX file to disk
pres.save("RectShpPatt.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add AutoShape of rectangle type
IShape shp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 50, 150, 75, 150);
// Set the fill type to Picture
shp.getFillFormat().setFillType(FillType.Picture);
// Set the picture fill mode
shp.getFillFormat().getPictureFillFormat().setPictureFillMode(PictureFillMode.Tile);
// Set the picture
IPPImage imgx = null;
try {
imgx = pres.getImages().addImage(new FileInputStream(new File("aspose1.jpg")));
} catch (IOException e) {
}
shp.getFillFormat().getPictureFillFormat().getPicture().setImage(imgx);
// Write the PPTX file to disk
pres.save("RectShpPic.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add AutoShape of rectangle type
IShape shp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 50, 150, 75, 150);
// Set the fill type to Solid
shp.getFillFormat().setFillType(FillType.Solid);
// Set the color of the rectangle
shp.getFillFormat().getSolidFillColor().setColor(Color.YELLOW);
// Write the PPTX file to disk
pres.save("RectShpSolid.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Calling FindShape method and passing the slide reference with the
// alternative text of the shape to be found
IShape shape = FindShape(slide, "Shape1");
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Method implementation to find a shape in a slide using its alternative
// text
IShape FindShape(ISlide slide, String alttext) {
// Iterating through all shapes inside the slide
for (int i = 0; i < slide.getShapes().size(); i++) {
// If the alternative text of the slide matches with the required
// one then
// return the shape
if (slide.getShapes().get_Item(i).getAlternativeText().compareTo(alttext) == 0)
return slide.getShapes().get_Item(i);
}
return null;
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add three AutoShapes of rectangle type
IShape shp1 = sld.getShapes().addAutoShape(ShapeType.Rectangle, 50, 100, 150, 75);
IShape shp2 = sld.getShapes().addAutoShape(ShapeType.Rectangle, 300, 100, 150, 75);
IShape shp3 = sld.getShapes().addAutoShape(ShapeType.Rectangle, 50, 250, 150, 75);
// Set the fill color of the rectangle shape
shp1.getFillFormat().setFillType(FillType.Solid);
shp1.getFillFormat().getSolidFillColor().setColor(Color.BLACK);
shp2.getFillFormat().setFillType(FillType.Solid);
shp2.getFillFormat().getSolidFillColor().setColor(Color.BLACK);
shp3.getFillFormat().setFillType(FillType.Solid);
shp3.getFillFormat().getSolidFillColor().setColor(Color.BLACK);
// Set the line width
shp1.getLineFormat().setWidth(15);
shp2.getLineFormat().setWidth(15);
shp3.getLineFormat().setWidth(15);
// Set the color of the line of rectangle
shp1.getLineFormat().getFillFormat().setFillType(FillType.Solid);
shp1.getLineFormat().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
shp2.getLineFormat().getFillFormat().setFillType(FillType.Solid);
shp2.getLineFormat().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
shp3.getLineFormat().getFillFormat().setFillType(FillType.Solid);
shp3.getLineFormat().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
// Set the Join Style
shp1.getLineFormat().setJoinStyle(LineJoinStyle.Miter);
shp2.getLineFormat().setJoinStyle(LineJoinStyle.Bevel);
shp3.getLineFormat().setJoinStyle(LineJoinStyle.Round);
// Add text to each rectangle
((IAutoShape) shp1).getTextFrame().setText("This is Miter Join Style");
((IAutoShape) shp2).getTextFrame().setText("This is Bevel Join Style");
((IAutoShape) shp3).getTextFrame().setText("This is Round Join Style");
// Write the PPTX file to disk
pres.save("RectShpLnJoin.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add AutoShape of rectangle type
IShape shp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 50, 150, 150, 75);
// Set the fill color of the rectangle shape
shp.getFillFormat().setFillType(FillType.Solid);
shp.getFillFormat().getSolidFillColor().setColor(Color.WHITE);
// Apply some formatting on the line of the rectangle
shp.getLineFormat().setStyle(LineStyle.ThickThin);
shp.getLineFormat().setWidth(7);
shp.getLineFormat().setDashStyle(LineDashStyle.Dash);
// set the color of the line of rectangle
shp.getLineFormat().getFillFormat().setFillType(FillType.Solid);
shp.getLineFormat().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
// Write the PPTX file to disk
pres.save("RectShpLn.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation presentation1 = new Presentation();
ISlide slide = presentation1.getSlides().get_Item(0);
IAutoShape shp3 = slide.getShapes().addAutoShape(ShapeType.Rectangle, 200, 365, 400, 150);
shp3.getFillFormat().setFillType(FillType.NoFill);
shp3.addTextFrame(" ");
ITextFrame txtFrame = shp3.getTextFrame();
IParagraph para = txtFrame.getParagraphs().get_Item(0);
IPortion portion = para.getPortions().get_Item(0);
portion.setText("Watermark Text Watermark Text Watermark Text");
shp3 = slide.getShapes().addAutoShape(ShapeType.Triangle, 200, 365, 400, 150);
slide.getShapes().reorder(2, shp3);
presentation1.save("D:\\sample_output.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation presentation1 = new Presentation();
ISlide slide = presentation1.getSlides().get_Item(0);
for (int i = 0; i < iCount; i++) {
IAutoShape ashp = (IAutoShape) slide.getShapes().get_Item(i);
if (ashp.getAlternativeText().compareTo(alttext) == 0) {
ashp.setHidden(true);
}
}
presentation1.save("sample_output.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation presentation1 = new Presentation();
ISlide slide = presentation1.getSlides().get_Item(0);
String alttext = "User Defined";
int iCount = slide.getShapes().size();
for (int i = 0; i < iCount; i++) {
IAutoShape ashp = (IAutoShape) slide.getShapes().get_Item(0);
if (ashp.getAlternativeText().compareTo(alttext) == 0) {
slide.getShapes().remove(ashp);
}
}
presentation1.save("sample_output.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation presentation1 = new Presentation();
ISlide slide = presentation1.getSlides().get_Item(0);
IAutoShape shp = slide.getShapes().addAutoShape(ShapeType.Rectangle, 50, 40, 150, 50);
IAutoShape shp1 = slide.getShapes().addAutoShape(ShapeType.Moon, 160, 40, 150, 50);
shp.getFillFormat().setFillType(FillType.Solid);
shp.getFillFormat().getSolidFillColor().setColor(Color.GRAY);
for (int i = 0; i < slide.getShapes().size(); i++) {
if (slide.getShapes().get_Item(i) instanceof IAutoShape) {
IAutoShape ashp = (IAutoShape) slide.getShapes().get_Item(i);
ashp.setAlternativeText("User Defind");
}
}
presentation1.save("sample_output.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add AutoShape of rectangle type
IShape shp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 50, 150, 75, 150);
// Rotate the shape to 90 degree
shp.setRotation(90);
// Write the PPTX file to disk
pres.save("RectShpRot.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Accessing the shape collection of slides
IShapeCollection slideShapes = sld.getShapes();
// Adding a group shape to the slide
IGroupShape groupShape = slideShapes.addGroupShape();
// Adding shapes inside Added group shape
groupShape.getShapes().addAutoShape(ShapeType.Rectangle, 300, 100, 100, 100);
groupShape.getShapes().addAutoShape(ShapeType.Rectangle, 500, 100, 100, 100);
groupShape.getShapes().addAutoShape(ShapeType.Rectangle, 300, 300, 100, 100);
groupShape.getShapes().addAutoShape(ShapeType.Rectangle, 500, 300, 100, 100);
// Adding group shape frame
groupShape.setFrame(new ShapeFrame(100, 300, 500, 40, NullableBool.False, NullableBool.False, 0));
// Write the PPTX file to disk
pres.save("GroupShape.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Load the PPTX to PresentationEx object
Presentation pres = new Presentation("OleEmbed.pptx");
// Access the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Cast the shape to OleObjectFrameEx
IOleObjectFrame oof = (IOleObjectFrame) sld.getShapes().get_Item(0);
// Read the OLE Object and write it to disk
if (oof != null) {
FileOutputStream fstr;
fstr = new FileOutputStream("excelFromOLEJ.xls");
byte[] buf = oof.getObjectData();
fstr.write(buf, 0, buf.length);
fstr.flush();
fstr.close();
System.out.println("Excel OLE Object written as excel1.xls file");
}
// Write the PPTX to disk
pres.save("OleEmbed.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
// Access the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Load an Excel file to Array of Bytes
File file = new File("ExcelWiki.xls");
int length = (int) file.length();
FileInputStream fstro = new FileInputStream(file);
byte[] buf = new byte[length];
fstro.read(buf, 0, length);
// Add an Ole Object Frame shape
IOleObjectFrame oof = sld.getShapes().addOleObjectFrame((float) 0, (float) 0,
(float) pres.getSlideSize().getSize().getWidth(), (float) pres.getSlideSize().getSize().getHeight(),
"Excel.Sheet.8", buf);
// Write the PPTX to disk
pres.save("OleEmbed.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a presentation file
Presentation presentation = new Presentation("demo.pptx");
// Getting Slide ID
int id = (int) presentation.getSlides().get_Item(0).getSlideId();
// Accessing Slide by ID
IBaseSlide slide = presentation.getSlideById(id);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("demo.pptx");
// Accessing a slide using its slide index
ISlide slide = pres.getSlides().get_Item(0);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
String presName = "Test.pptx";
// Instantiate Presentation class that represents the presentation file
Presentation pres = new Presentation(presName);
// Try to search by layout slide type
IMasterLayoutSlideCollection layoutSlides = pres.getMasters().get_Item(0).getLayoutSlides();
ILayoutSlide layoutSlide = null;
if (layoutSlides.getByType(SlideLayoutType.TitleAndObject) != null)
layoutSlide = layoutSlides.getByType(SlideLayoutType.TitleAndObject);
else
layoutSlide = layoutSlides.getByType(SlideLayoutType.Title);
if (layoutSlide == null) {
// The situation when a presentation doesn't contain some type of
// layouts.
// Technographics.pptx presentation 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 placeholder type, etc.
for (ILayoutSlide titleAndObjectLayoutSlide : layoutSlides) {
if (titleAndObjectLayoutSlide.getName() == "Title and Object") {
layoutSlide = titleAndObjectLayoutSlide;
break;
}
}
if (layoutSlide == null) {
for (ILayoutSlide titleLayoutSlide : layoutSlides) {
if (titleLayoutSlide.getName() == "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
pres.getSlides().insertEmptySlide(0, layoutSlide);
// Save presentation
pres.save("output.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the presentation file
Presentation pres = new Presentation();
// Instantiate SlideCollection calss
ISlideCollection slds = pres.getSlides();
for (int i = 0; i < pres.getLayoutSlides().size(); i++) {
// Add an empty slide to the Slides collection
slds.addEmptySlide(pres.getLayoutSlides().get_Item(i));
}
// Do some work on the newly added slide
// Save the PPTX file to the Disk
pres.save("EmptySlide.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class to load the source presentation file
Presentation pres = new Presentation("helloworld_clonedPos.pptx");
// Get the slide whose position is to be changed
ISlide sld = pres.getSlides().get_Item(0);
// Set the new position for the slide
sld.setSlideNumber(2);
// Write the presentation to disk
pres.save("helloworld_Pos.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents a presentation file
Presentation pres = new Presentation("helloworld.pptx");
// Clone the desired slide to the end of the collection of slides in the
// same presentation
ISlideCollection slds = pres.getSlides();
// Clone the desired slide to the specified index in the same
// presentation
slds.insertClone(2, pres.getSlides().get_Item(1));
// Write the modified presentation to disk
pres.save("helloworld_clonedPost.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class to load the source presentation file
Presentation srcPres = new Presentation("helloworld.pptx");
// Instantiate Presentation class for destination PPTX (where slide is
// to be cloned)
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.getSlides();
slds.addClone(srcPres.getSlides().get_Item(0));
// Write the destination presentation to disk
destPres.save("helloworld_dest2.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class to load the source presentation file
Presentation srcPres = new Presentation("helloworld.pptx");
// Instantiate Presentation class for destination presentation (where
// slide is to be cloned)
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.getSlides();
// Clone the desired slide from the source presentation to the specified
// position in destination presentation
slds.insertClone(2, srcPres.getSlides().get_Item(1));
// Write the destination presentation to disk
destPres.save("helloworld_dest2.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class to load the source presentation file
Presentation srcPres = new Presentation("helloworld.pptx");
// Instantiate Presentation class for destination presentation (where
// slide is to be cloned)
Presentation destPres = new Presentation();
// Instantiate ISlide from the collection of slides in source
// presentation along with
// master slide
ISlide sourceSlide = srcPres.getSlides().get_Item(0);
// Clone the desired master slide from the source presentation to the
// collection of masters in the
// destination presentation
IMasterSlideCollection masters = destPres.getMasters();
IMasterSlide SourceMaster = sourceSlide.getLayoutSlide().getMasterSlide();
// 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.getSlides();
slds.addClone(sourceSlide, iSlide);
// 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("helloworld_dest3.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents a presentation file
Presentation pres = new Presentation("helloworld.pptx");
// Clone the desired slide to the end of the collection of slides in the
// same presentation
ISlideCollection slds = pres.getSlides();
slds.addClone(pres.getSlides().get_Item(0));
// Write the modified presentation to disk
pres.save("helloworld_cloned.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a PPTX file
Presentation pres = new Presentation("demo.pptx");
// Getting last slide index
int lastSlidePosition = pres.getSlides().size();
ISlide slide = null;
// Iterating through every presentation slide and generating SVG image
for (int i = 0; i < lastSlidePosition; i++) {
// Accessing Slides
slide = pres.getSlides().get_Item(i);
// Getting and saving the slide SVG image
try {
slide.writeAsSvg(new FileOutputStream("D:\\SvgImage" + i + ".svg"));
} catch (IOException e) {
}
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation class that represents the presentation
// file
Presentation pres = new Presentation("Sample.pptx");
// Access the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Create a full scale image
BufferedImage image = sld.getThumbnail(1f, 1f);
// Save the image to disk in JPEG format
try {
ImageIO.write(image, "jpeg", new File("ContentBG_tnail.jpg"));
} catch (IOException e) {
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation class that represents the presentation
// file
Presentation pres = new Presentation("Sample.pptx");
// Access the first slide
ISlide sld = pres.getSlides().get_Item(0);
// User defined dimension
int desiredX = 1200;
int desiredY = 800;
// Getting scaled value of X and Y
float ScaleX = (float) (1.0 / pres.getSlideSize().getSize().getWidth()) * desiredX;
float ScaleY = (float) (1.0 / pres.getSlideSize().getSize().getHeight()) * desiredY;
// Create a full scale image
BufferedImage image = sld.getNotesSlide().getThumbnail(ScaleX, ScaleY);
// Save the image to disk in JPEG format
try {
ImageIO.write(image, "jpeg", new File("ContentBG_tnail.jpg"));
} catch (IOException e) {
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation class that represents the presentation
// file
Presentation pres = new Presentation("Sample.pptx");
// Access the first slide
ISlide sld = pres.getSlides().get_Item(0);
// User defined dimension
int desiredX = 1200;
int desiredY = 800;
// Getting scaled value of X and Y
float ScaleX = (float) (1.0 / pres.getSlideSize().getSize().getWidth()) * desiredX;
float ScaleY = (float) (1.0 / pres.getSlideSize().getSize().getHeight()) * desiredY;
// Create a full scale image
BufferedImage image = sld.getThumbnail(ScaleX, ScaleY);
// Save the image to disk in JPEG format
try {
ImageIO.write(image, "jpeg", new File("ContentBG_tnail.jpg"));
} catch (IOException e) {
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation class that represents the presentation
// file
Presentation pres = new Presentation("Sample.pptx");
// Access the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Create a full scale image
BufferedImage image = sld.getThumbnail(1f, 1f);
// Getting the image of desired window inside generated slide thumbnail
// BufferedImage window = image.getSubimage(windowX, windowY,
// windowsWidth, windowHeight);
BufferedImage windowImage = image.getSubimage(100, 100, 200, 200);
// Save the image to disk in JPEG format
try {
ImageIO.write(windowImage, "jpeg", new File("ContentBG_tnail.jpg"));
} catch (IOException e) {
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Loading a presentation
Presentation pres = new Presentation("example.pptx");
try {
final String path = "path";
final String fileName = "video.html";
final 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.setHtmlFormatter(HtmlFormatter.createCustomFormatter(controller));
htmlOptions.setSlideImageFormat(SlideImageFormat.svg(svgOptions));
// Saving the file
pres.save(path + fileName, SaveFormat.Html, htmlOptions);
} finally {
if (pres != null)
pres.dispose();
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
String presName = "Test.pptx";
// Instantiate Presentation class that represents the presentation file
Presentation pres = new Presentation(presName);
// Access the desired slide
ISlide slide = pres.getSlides().get_Item(0);
// Get the slideshow transition effects for slide
ISlideShowTransition transition = slide.getSlideShowTransition();
// Extract sound in byte array
byte[] audio = transition.getSound().getBinaryData();
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation template = new Presentation("VideoSample.pptx");
for (ISlide slide : template.getSlides()) {
for (IShape shape : template.getSlides().get_Item(0).getShapes()) {
if (shape instanceof VideoFrame) {
IVideoFrame vf = (IVideoFrame) shape;
String type = vf.getEmbeddedVideo().getContentType();
int ss = type.lastIndexOf('-');
byte[] buffer = vf.getEmbeddedVideo().getBinaryData();
new FileOutputStream("testing2" + type);
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
public static void main(String[] args) {
// Load Presentation
Presentation pres = new Presentation("headerTest.pptx");
// Setting Footer
pres.getHeaderFooterManager().setFooterText("My Footer text");
pres.getHeaderFooterManager().setFooterVisible(true);
// Access and Update Header
IMasterNotesSlide masterNotesSlide = pres.getMasterNotesSlideManager().getMasterNotesSlide();
if (null != masterNotesSlide) {
updateHeaderFooterText(masterNotesSlide);
}
// Save presentation
pres.save("HeaderFooterJava.pptx", SaveFormat.Pptx);
}
// Method to set Header/Footer Text
public static void updateHeaderFooterText(IBaseSlide master) {
for (IShape shape : master.getShapes()) {
if (shape.getPlaceholder() != null) {
if (shape.getPlaceholder().getType() == PlaceholderType.Header) {
((IAutoShape) shape).getTextFrame().setText("HI there new header");
}
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents a presentation file
Presentation pres = new Presentation("Sample.pptx");
// Apply circle type transition on slide 1
pres.getSlides().get_Item(0).getSlideShowTransition().setType(TransitionType.Circle);
// Set the transition time of 3 seconds
// Set the transition time of 5 seconds
pres.getSlides().get_Item(0).getSlideShowTransition().setAdvanceOnClick(true);
pres.getSlides().get_Item(0).getSlideShowTransition().setAdvanceAfterTime(3000);
// Apply comb type transition on slide 2
pres.getSlides().get_Item(1).getSlideShowTransition().setType(TransitionType.Comb);
// Set the transition time of 5 seconds
pres.getSlides().get_Item(1).getSlideShowTransition().setAdvanceOnClick(true);
pres.getSlides().get_Item(1).getSlideShowTransition().setAdvanceAfterTime(5000);
// Apply zoom type transition on slide 3
pres.getSlides().get_Item(2).getSlideShowTransition().setType(TransitionType.Zoom);
// Set the transition time of 7 seconds
pres.getSlides().get_Item(2).getSlideShowTransition().setAdvanceOnClick(true);
pres.getSlides().get_Item(2).getSlideShowTransition().setAdvanceAfterTime(7000);
// Write the presentation to disk
pres.save("SampleTransition.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents a presentation file
Presentation pres = new Presentation("Sample.pptx");
// Apply circle type transition on slide 1
pres.getSlides().get_Item(0).getSlideShowTransition().setType(TransitionType.Circle);
// Apply comb type transition on slide 2
pres.getSlides().get_Item(1).getSlideShowTransition().setType(TransitionType.Comb);
// Apply zoom type transition on slide 3
pres.getSlides().get_Item(2).getSlideShowTransition().setType(TransitionType.Zoom);
// Write the presentation to disk
pres.save("SampleTransition.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a PPTX file
Presentation pres = new Presentation("demo.pptx");
// Accessing a slide using its slide position
ISlide slide = pres.getSlides().get_Item(1);
// Setting the slide transition effect to fade
slide.getSlideShowTransition().setType(TransitionType.Fade);
// Setting the speed of slide transition to slow
slide.getSlideShowTransition().setSpeed(TransitionSpeed.Slow);
// Setting the transition to advance on click
slide.getSlideShowTransition().setAdvanceOnClick(true);
// Setting the transition to advance after a specific time period
slide.getSlideShowTransition().setAdvanceAfterTime(5);
// Writing the presentation as a PPTX file
pres.save("modified.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a PPTX file
Presentation pres = new Presentation("demo.pptx");
// Accessing a slide using its slide position
ISlide slide = pres.getSlides().get_Item(1);
// Setting the slide transition effect to fade
slide.getSlideShowTransition().setType(TransitionType.Fade);
// Writing the presentation as a PPTX file
pres.save("modified.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("test.pptx");
// Removing notes of all slides
INotesSlideManager mgr = null;
for (int i = 0; i < pres.getSlides().size(); i++) {
mgr = pres.getSlides().get_Item(i).getNotesSlideManager();
mgr.removeNotesSlide();
}
// Saving presentation to disk
pres.save("test.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("presWithNotes.pptx");
// Removing notes of first slide
INotesSlideManager mgr = pres.getSlides().get_Item(0).getNotesSlideManager();
mgr.removeNotesSlide();
// Saving presentation to disk
pres.save("test.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("demo.pptx");
// Removing a slide using its slide index
pres.getSlides().removeAt(0);
// Writing the presentation file
pres.save("modified.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("demo.pptx");
// Accessing a slide using its index in the slides collection
ISlide slide = pres.getSlides().get_Item(0);
// Removing a slide using its reference
pres.getSlides().remove(slide);
// Writing the presentation file
pres.save("modified.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate the Presentation class that represents the presentation
// file
Presentation pres = new Presentation("MasterBG.pptx");
// Apply Gradiant effect to the Background
pres.getSlides().get_Item(0).getBackground().setType(BackgroundType.OwnBackground);
pres.getSlides().get_Item(0).getBackground().getFillFormat().setFillType(FillType.Gradient);
pres.getSlides().get_Item(0).getBackground().getFillFormat().getGradientFormat().setTileFlip(TileFlip.FlipBoth);
// Write the presentation to disk
pres.save("ContentBG_Grad.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate the Presentation class that represents the presentation
// file
Presentation pres = new Presentation();
// Set the background color of the Master ISlide to Forest Green
pres.getMasters().get_Item(0).getBackground().setType(BackgroundType.OwnBackground);
pres.getMasters().get_Item(0).getBackground().getFillFormat().setFillType(FillType.Solid);
pres.getMasters().get_Item(0).getBackground().getFillFormat().getSolidFillColor().setColor(Color.GREEN);
// Write the presentation to disk
pres.save("MasterBG.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate the PFresentation class that represents the presentation
// file
Presentation pres = new Presentation("MasterBG.pptx");
// Set the background color of the first ISlide to Blue
pres.getSlides().get_Item(0).getBackground().setType(BackgroundType.OwnBackground);
pres.getSlides().get_Item(0).getBackground().getFillFormat().setFillType(FillType.Solid);
pres.getSlides().get_Item(0).getBackground().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
pres.save("ContentBG.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate the Presentation class that represents the presentation
// file
Presentation pres = new Presentation();
// Set the background with Image
pres.getSlides().get_Item(0).getBackground().setType(BackgroundType.OwnBackground);
pres.getSlides().get_Item(0).getBackground().getFillFormat().setFillType(FillType.Picture);
pres.getSlides().get_Item(0).getBackground().getFillFormat().getPictureFillFormat()
.setPictureFillMode(PictureFillMode.Stretch);
// Set the picture
IPPImage imgx = null;
try {
imgx = pres.getImages().addImage(new FileInputStream(new File("Desert.jpg")));
} catch (IOException e) {
}
// Add image to presentation's images collection
pres.getSlides().get_Item(0).getBackground().getFillFormat().getPictureFillFormat().getPicture().setImage(imgx);
// Write the presentation to disk
pres.save("ContentBG_Img.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Create an instance of Presentation class
Presentation pres = new Presentation();
// Set effect
pres.getSlides().get_Item(0).getSlideShowTransition().setType(TransitionType.Cut);
((OptionalBlackTransition) pres.getSlides().get_Item(0).getSlideShowTransition().getValue()).setFromBlack(true);
// Write the presentation to disk
pres.save("Test.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
public static void main(String[] args) {
Presentation pres = new Presentation();
addVideoFromYouTube(pres, "Tj75Arhq5ho");
pres.save("out.pptx", SaveFormat.Pptx);
}
private static void addVideoFromYouTube(Presentation pres, String videoID) {
// add videoFrame
IVideoFrame videoFrame = pres.getSlides().get_Item(0).getShapes().addVideoFrame(10, 10, 427, 240, "https://www.youtube.com/embed/" + videoID);
videoFrame.setPlayMode(VideoPlayModePreset.Auto);
// load thumbnail
String thumbnailUri = "http://img.youtube.com/vi/" + videoID + "/hqdefault.jpg";
URL url;
try {
url = new URL(thumbnailUri);
videoFrame.getPictureFormat().getPicture().setImage(pres.getImages().addImage(url.openStream()));
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation pres = new Presentation("Comments.pptx");
for (ICommentAuthor author : pres.getCommentAuthors()) {
for (IComment comment : author.getComments()) {
System.out.println("ISlide :" + comment.getSlide().getSlideNumber() + " has comment: "
+ comment.getText() + " with Author: " + comment.getAuthor().getName() + " posted on time :"
+ comment.getCreatedTime() + "\n");
}
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation pres = new Presentation();
// Adding Empty slide
pres.getSlides().addEmptySlide(pres.getLayoutSlides().get_Item(0));
// Adding Author
ICommentAuthor author = pres.getCommentAuthors().addAuthor("Mudassir", "MF");
// Position of comments
java.awt.geom.Point2D.Float point = new java.awt.geom.Point2D.Float(0.2f, 0.2f);
java.util.Date date = new java.util.Date();
// Adding slide comment for an author on slide 1
author.getComments().addComment("Hello Mudassir, this is slide comment", pres.getSlides().get_Item(0), point,
date);
// Adding slide comment for an author on slide 1
author.getComments().addComment("Hello Mudassir, this is second slide comment", pres.getSlides().get_Item(1),
point, date);
// Accessing ISlide 1
ISlide slide = pres.getSlides().get_Item(0);
// if null is passed as an argument then it will bring comments from all
// authors on selected slide
IComment[] comments = slide.getSlideComments(author);
// Accessing the comment at index 0 for slide 1
String str = comments[0].getText();
pres.save("Comments.pptx", SaveFormat.Pptx);
if (comments.length > 0) {
// Select comments collection of Author at index 0
ICommentCollection commentCollection = comments[0].getAuthor().getComments();
String comment = commentCollection.get_Item(0).getText();
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation();
// Set SlideSize.Type Property
pres.getSlideSize().setType(SlideSizeType.A4Paper);
// Set different properties of PDF Options
PdfOptions opts = new PdfOptions();
opts.setSufficientResolution(600);
// Save presentation to disk
pres.save("Export.pdf", SaveFormat.Pdf, opts);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation objects that represent presentation files
Presentation presentation = new Presentation("render.pptx");
Presentation auxPresentation = new Presentation();
ISlide slide = presentation.getSlides().get_Item(0);
// Set the slide size of generated presentations to that of source
auxPresentation.getSlideSize().setType(presentation.getSlideSize().getType());
auxPresentation.getSlideSize().setSize(presentation.getSlideSize().getSize());
// Clone required slide
auxPresentation.getSlides().addClone(presentation.getSlides().get_Item(0));
auxPresentation.getSlides().removeAt(0);
// Save Presentation to disk
auxPresentation.save("size.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate the presentation
Presentation pres = new Presentation();
// Accessing the first slide
ISlide slide = pres.getSlides().get_Item(0);
// Adding the SmartArt shape in first slide
ISmartArt smart = slide.getShapes().addSmartArt(0, 0, 400, 400, SmartArtLayoutType.StackedList);
// Accessing the SmartArt node at index 0
ISmartArtNode node = smart.getAllNodes().get_Item(0);
// Accessing the child node at position 1 in parent node
int position = 1;
SmartArtNode chNode = (SmartArtNode) ((SmartArtNodeCollection) node.getChildNodes())
.getNodeByPosition(position);
// Printing the SmartArt child node parameters
System.out.print("Text = " + chNode.getTextFrame().getText() + ", Level = " + chNode.getLevel()
+ ", Position = " + chNode.getPosition());
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation Class
Presentation pres = new Presentation("SimpleSmartArt.pptx");
// Get first slide
ISlide slide = pres.getSlides().get_Item(0);
// Traverse through every shape inside first slide
for (IShape shape : slide.getShapes()) {
// Check if shape is of SmartArt type
if (shape instanceof ISmartArt) {
// Typecast shape to SmartArtEx
ISmartArt smart = (ISmartArt) shape;
// Traverse through all nodes inside SmartArt
for (int i = 0; i < smart.getAllNodes().size(); i++) {
// Accessing SmartArt node at index i
SmartArtNode node0 = (SmartArtNode) smart.getAllNodes().get_Item(i);
// Traversing through the child nodes in SmartArt node at
// index i
for (int j = 0; j < node0.getChildNodes().size(); j++) {
// Accessing the child node in SmartArt node
SmartArtNode node = (SmartArtNode) node0.getChildNodes().get_Item(j);
// Printing the SmartArt child node parameters
System.out.print("j = " + j + ", Text = " + node.getTextFrame().getText() + ", Level = "
+ node.getLevel() + ", Position = " + node.getPosition());
}
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation Class
Presentation pres = new Presentation("SimpleSmartArt.pptx");
// Get first slide
ISlide slide = pres.getSlides().get_Item(0);
// Traverse through every shape inside first slide
for (IShape shape : slide.getShapes()) {
// Check if shape is of SmartArt type
if (shape instanceof ISmartArt) {
// Typecast shape to SmartArtEx
ISmartArt smart = (ISmartArt) shape;
// Traverse through all nodes inside SmartArt
for (int i = 0; i < smart.getAllNodes().size(); i++) {
// Accessing SmartArt node at index i
SmartArtNode node = (SmartArtNode) smart.getAllNodes().get_Item(i);
// Printing the SmartArt node parameters
System.out.print(node.getTextFrame().getText() + " " + node.getLevel() + " " + node.getPosition());
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation Class
Presentation pres = new Presentation("SimpleSmartArt.pptx");
// Get first slide
ISlide slide = pres.getSlides().get_Item(0);
// Traverse through every shape inside first slide
for (IShape shape : slide.getShapes()) {
// Check if shape is of SmartArt type
if (shape instanceof ISmartArt) {
// Typecast shape to SmartArtEx
ISmartArt smart = (ISmartArt) shape;
// Checking SmartArt Layout
if (smart.getLayout() == SmartArtLayoutType.BasicBlockList) {
System.out.print("Do some thing here....");
}
}
}
// Saving presentation
pres.save("SimpleSmartArt.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation Class
Presentation pres = new Presentation("SimpleSmartArt.pptx");
// Get first slide
ISlide slide = pres.getSlides().get_Item(0);
// Traverse through every shape inside first slide
for (IShape shape : pres.getSlides().get_Item(0).getShapes()) {
// Check if shape is of SmartArt type
if (shape instanceof ISmartArt) {
// Typecast shape to SmartArtEx
ISmartArt smart = (ISmartArt) shape;
}
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Creating a presentation instance
Presentation pres = new Presentation();
// Access the presentation slide
ISlide slide = pres.getSlides().get_Item(0);
// Add Smart Art IShape
ISmartArt smart = slide.getShapes().addSmartArt(0, 0, 400, 400, SmartArtLayoutType.StackedList);
// Accessing the SmartArt node at index 0
ISmartArtNode node = smart.getAllNodes().get_Item(0);
// Adding new child node at position 2 in parent node
SmartArtNode chNode = (SmartArtNode) ((SmartArtNodeCollection) node.getChildNodes()).addNodeByPosition(2);
// Add Text
chNode.getTextFrame().setText("Sample Text Added");
// Save Presentation
pres.save("AddSmartArtNodeByPosition.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Load the desired the presentation
Presentation pres = new Presentation("SimpleSmartArt.pptx");
// Traverse through every shape inside first slide
for (IShape shape : pres.getSlides().get_Item(0).getShapes()) {
// Check if shape is of SmartArt type
if (shape instanceof SmartArt) {
// Typecast shape to SmartArt
SmartArt smart = (SmartArt) shape;
// Adding a new SmartArt Node
SmartArtNode TemNode = (SmartArtNode) smart.getAllNodes().addNode();
// Adding text
TemNode.getTextFrame().setText("Test");
// Adding new child node in parent node. It will be added in the
// end of collection
SmartArtNode newNode = (SmartArtNode) TemNode.getChildNodes().addNode();
// Adding text
newNode.getTextFrame().setText("New Node Added");
}
}
// Saving Presentation
pres.save("AddSmartArtNode.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX file
Presentation pres = new Presentation();
// Add SmartArt BasicBlockList
ISmartArt smart = pres.getSlides().get_Item(0).getShapes().addSmartArt(10, 10, 400, 300,
SmartArtLayoutType.BasicBlockList);
// Change LayoutType to BasicProcess
smart.setLayout(SmartArtLayoutType.BasicProcess);
// Saving Presentation
pres.save("output.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation Class
Presentation pres = new Presentation("SimpleSmartArt.pptx");
// Get first slide
ISlide slide = pres.getSlides().get_Item(0);
// Traverse through every shape inside first slide
for (IShape shape : slide.getShapes()) {
// Check if shape is of SmartArt type
if (shape instanceof ISmartArt) {
// Typecast shape to SmartArtEx
ISmartArt smart = (ISmartArt) shape;
// Checking SmartArt color type
if (smart.getColorStyle() == SmartArtColorType.ColoredFillAccent1) {
// Changing SmartArt color type
smart.setColorStyle(SmartArtColorType.ColorfulAccentColors);
}
}
}
// Saving presentation
pres.save("ChangeSmartArtColorStyle.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation Class
Presentation pres = new Presentation("SimpleSmartArt.pptx");
// Get first slide
ISlide slide = pres.getSlides().get_Item(0);
// Traverse through every shape inside first slide
for (IShape shape : slide.getShapes()) {
// Check if shape is of SmartArt type
if (shape instanceof ISmartArt) {
// Typecast shape to SmartArtEx
ISmartArt smart = (ISmartArt) shape;
// Checking SmartArt style
if (smart.getQuickStyle() == SmartArtQuickStyleType.SimpleFill) {
// Changing SmartArt Style
smart.setQuickStyle(SmartArtQuickStyleType.Cartoon);
}
}
}
// Saving presentation
pres.save("ChangeSmartArtStyle.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX file
Presentation pres = new Presentation();
// Add SmartArt BasicCycle
ISmartArt smart = pres.getSlides().get_Item(0).getShapes().addSmartArt(10, 10, 400, 300,
SmartArtLayoutType.BasicCycle);
// Obtain the reference of a node by using its Index
ISmartArtNode node = smart.getNodes().get_Item(1); // select second root node
// Setting the text of the TextFrame
node.getTextFrame().setText("Second root node");
// Saving Presentation
pres.save("output.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Creating a presentation instance
Presentation pres = new Presentation("AddSmartArtNode.pptx");
// Traverse through every shape inside first slide
for (IShape shape : pres.getSlides().get_Item(0).getShapes()) {
// Check if shape is of SmartArt type
if (shape instanceof ISmartArt) {
// Typecast shape to SmartArtEx
ISmartArt smart = (SmartArt) shape;
// Traversing through all nodes of SmartArt shape
for (int i = 0; i < smart.getAllNodes().size(); i++) {
ISmartArtNode node = smart.getAllNodes().get_Item(i);
String tc = node.getTextFrame().getText();
// Check if node is Assistant node
if (node.isAssistant()) {
// Setting Assistant node to false and making it normal
// node
node.isAssistant();
}
}
}
}
// Save Presentation
pres.save("ChangeAssitantNode.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX file
Presentation pres = new Presentation();
// Add SmartArt RadialCycle
ISmartArt smart = pres.getSlides().get_Item(0).getShapes().addSmartArt(10, 10, 400, 300,
SmartArtLayoutType.RadialCycle);
// Add node on SmartArt
ISmartArtNode node = smart.getAllNodes().addNode();
// Check isHidden property
boolean hidden = node.isHidden(); // returns true
if (hidden) {
// do some actions or notifications
}
// Saving Presentation
pres.save("output.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation Class
Presentation pres = new Presentation();
// Get first slide
ISlide slide = pres.getSlides().get_Item(0);
// Add Smart Art Shape
ISmartArt smart = slide.getShapes().addSmartArt(0, 0, 400, 400, SmartArtLayoutType.BasicBlockList);
// Saving presentation
pres.save("SimpleSmartArt.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX file
Presentation pres = new Presentation();
// Add SmartArt BasicProcess
ISmartArt smart = pres.getSlides().get_Item(0).getShapes().addSmartArt(10, 10, 400, 300,
SmartArtLayoutType.OrganizationChart);
// Get or Set the organization chart type
smart.getNodes().get_Item(0).setOrganizationChartLayout(OrganizationChartLayoutType.LeftHanging);
// Saving Presentation
pres.save("output.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents the PPTX file
Presentation pres = new Presentation();
// Add SmartArt BasicProcess
ISmartArt smart = pres.getSlides().get_Item(0).getShapes().addSmartArt(10, 10, 400, 300,
SmartArtLayoutType.BasicProcess);
// Get or Set the state of SmartArt Diagram
smart.setReversed(true);
boolean flag = smart.isReversed();
// Saving Presentation
pres.save("output.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Load the desired the presentation
Presentation pres = new Presentation("AddSmartArtNode.pptx");
// Traverse through every shape inside first slide
for (IShape shape : pres.getSlides().get_Item(0).getShapes()) {
// Check if shape is of SmartArt type
if (shape instanceof ISmartArt) {
// Typecast shape to SmartArtEx
ISmartArt smart = (ISmartArt) shape;
if (smart.getAllNodes().size() > 0) {
// Accessing SmartArt node at index 0
ISmartArtNode node = smart.getAllNodes().get_Item(0);
// Removing the selected node
smart.getAllNodes().removeNode(node);
}
}
}
// Save Presentation
pres.save("RemoveSmartArtNode.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Load the desired the presentation
Presentation pres = new Presentation("AddSmartArtNode.pptx");
// Traverse through every shape inside first slide
for (IShape shape : pres.getSlides().get_Item(0).getShapes()) {
// Check if shape is of SmartArt type
if (shape instanceof SmartArt) {
// Typecast shape to SmartArt
SmartArt smart = (SmartArt) shape;
if (smart.getAllNodes().size() > 0) {
// Accessing SmartArt node at index 0
ISmartArtNode node = smart.getAllNodes().get_Item(0);
if (node.getChildNodes().size() >= 2) {
// Removing the child node at position 1
((SmartArtNodeCollection) node.getChildNodes()).removeNodeByPosition(1);
}
}
}
}
// Save Presentation
pres.save("RemoveSmartArtNodeByPosition.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate the presentation
Presentation pres = new Presentation();
// Accessing the slide
ISlide slide = pres.getSlides().get_Item(0);
// Adding SmartArt shape and nodes
ISmartArt chevron = slide.getShapes().addSmartArt(10, 10, 800, 60,
com.aspose.slides.SmartArtLayoutType.ClosedChevronProcess);
ISmartArtNode node = chevron.getAllNodes().addNode();
node.getTextFrame().setText("Some text");
// Setting node fill color
for (IShape item : node.getShapes()) {
item.getFillFormat().setFillType(FillType.Solid);
item.getFillFormat().getSolidFillColor().setColor(Color.RED);
}
// Save the presentation
pres.save("TestSmart.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents PPTX
Presentation pres = new Presentation("table.pptx");
// Access the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Initialize null TableEx
ITable tbl = null;
// Iterate through the shapes and set a reference to the table found
for (IShape shp : sld.getShapes())
if (shp instanceof ITable)
tbl = (ITable) shp;
// Set the text of the first column of second row
tbl.getRows().get_Item(0).get_Item(1).getTextFrame().setText("New");
// Save the PPTX to Disk
pres.save("table1.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class Object
Presentation pres = new Presentation();
// Access first slide
ISlide sld = pres.getSlides().get_Item(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 = sld.getShapes().addTable(50, 50, dblCols, dblRows);
// Creating a Buffered Image object to hold the image file
BufferedImage image = null;
image = ImageIO.read(new File("image1.jpg"));
IPPImage imgx1 = pres.getImages().addImage(image);
tbl.get_Item(0, 0).getFillFormat().setFillType(FillType.Picture);
tbl.get_Item(0, 0).getFillFormat().getPictureFillFormat().setPictureFillMode(PictureFillMode.Stretch);
tbl.get_Item(0, 0).getFillFormat().getPictureFillFormat().getPicture().setImage(imgx1);
// Save PPTX to Disk
pres.save("table.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate PresentationEx class that represents the PPTX file
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add an AutoShape of type line
IAutoShape shp = sld.getShapes().addAutoShape(ShapeType.Line, 50, 150, 300, 0);
// Apply some formatting on the line
shp.getLineFormat().setStyle(LineStyle.ThickBetweenThin);
shp.getLineFormat().setWidth(10);
shp.getLineFormat().setDashStyle(LineDashStyle.DashDot);
shp.getLineFormat().setBeginArrowheadLength(LineArrowheadLength.Short);
shp.getLineFormat().setBeginArrowheadStyle(LineArrowheadStyle.Oval);
shp.getLineFormat().setEndArrowheadLength(LineArrowheadLength.Long);
shp.getLineFormat().setEndArrowheadStyle(LineArrowheadStyle.Triangle);
shp.getLineFormat().getFillFormat().setFillType(FillType.Solid);
shp.getLineFormat().getFillFormat().getSolidFillColor().setColor(new Color(PresetColor.Maroon));
// Write the PPTX to Disk
pres.save("LineShape2.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate PresentationEx class that represents the PPTX file
Presentation pres = new Presentation();
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add an AutoShape of type line
sld.getShapes().addAutoShape(ShapeType.Line, 50, 150, 300, 0);
// Write the PPTX to Disk
pres.save("LineShape1.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents PPTX file
Presentation pres = new Presentation();
// Access first slide
ISlide sld = pres.getSlides().get_Item(0);
// Define columns with widths and rows with heights
double[] dblCols = { 50, 50, 50 };
double[] dblRows = { 50, 30, 30, 30 };
// Add table shape to slide
ITable tbl = sld.getShapes().addTable(100, 50, dblCols, dblRows);
// Set border format for each cell
for (int row = 0; row < tbl.getRows().size(); row++) {
for (int cell = 0; cell < tbl.getRows().get_Item(row).size(); cell++) {
tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().getFillFormat().setFillType(FillType.Solid);
tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().getFillFormat().getSolidFillColor()
.setColor(Color.RED);
tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().setWidth(5);
tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().getFillFormat()
.setFillType(FillType.Solid);
tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().getFillFormat().getSolidFillColor()
.setColor(Color.RED);
tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().setWidth(5);
tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().getFillFormat().setFillType(FillType.Solid);
tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().getFillFormat().getSolidFillColor()
.setColor(Color.RED);
tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().setWidth(5);
tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().getFillFormat().setFillType(FillType.Solid);
tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().getFillFormat().getSolidFillColor()
.setColor(Color.RED);
tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().setWidth(5);
}
}
tbl.getColumns().get_Item(0).get_Item(0).getTextFrame().setText("00");
tbl.getColumns().get_Item(0).get_Item(1).getTextFrame().setText("01");
tbl.getColumns().get_Item(0).get_Item(2).getTextFrame().setText("02");
tbl.getColumns().get_Item(0).get_Item(3).getTextFrame().setText("03");
tbl.getColumns().get_Item(1).get_Item(0).getTextFrame().setText("10");
tbl.getColumns().get_Item(2).get_Item(0).getTextFrame().setText("20");
tbl.getColumns().get_Item(1).get_Item(1).getTextFrame().setText("11");
tbl.getColumns().get_Item(2).get_Item(1).getTextFrame().setText("21");
// AddClone adds a row in the end of the table
tbl.getRows().addClone(tbl.getRows().get_Item(0), false);
// AddClone adds a column in the end of the table
tbl.getColumns().addClone(tbl.getColumns().get_Item(0), false);
// InsertClone adds a row at specific position in a table
tbl.getRows().insertClone(2, tbl.getRows().get_Item(0), false);
// InsertClone adds a row at specific position in a table
tbl.getColumns().insertClone(2, tbl.getColumns().get_Item(0), false);
// Save PPTX to Disk
pres.save("Cloning.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents PPTX file
Presentation pres = new Presentation();
// Access first slide
ISlide sld = pres.getSlides().get_Item(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 tbl = sld.getShapes().addTable(100, 50, dblCols, dblRows);
// Set border format for each cell
for (int row = 0; row < tbl.getRows().size(); row++) {
for (int cell = 0; cell < tbl.getRows().get_Item(row).size(); cell++) {
tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().getFillFormat().setFillType(FillType.Solid);
tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().getFillFormat().getSolidFillColor()
.setColor(Color.RED);
tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().setWidth(5);
tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().getFillFormat()
.setFillType(FillType.Solid);
tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().getFillFormat().getSolidFillColor()
.setColor(Color.RED);
tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().setWidth(5);
tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().getFillFormat().setFillType(FillType.Solid);
tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().getFillFormat().getSolidFillColor()
.setColor(Color.RED);
tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().setWidth(5);
tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().getFillFormat().setFillType(FillType.Solid);
tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().getFillFormat().getSolidFillColor()
.setColor(Color.RED);
tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().setWidth(5);
}
}
// Merge cells 1 & 2 of row 1
tbl.mergeCells(tbl.getRows().get_Item(0).get_Item(0), tbl.getRows().get_Item(1).get_Item(0), false);
// Add text to the merged cell
tbl.getRows().get_Item(0).get_Item(0).getTextFrame().setText("Merged Cells");
// Save PPTX to Disk
pres.save("table.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
//Check if the first row of a table is with header formatting
public boolean getFirstRow();
//Set the first row of a table as header with a special formatting.
public void setFirstRow(boolean value);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
//Instantiate Presentation class that represents PPTX file
Presentation pres = new Presentation();
//Access first slide
ISlide sld = pres.getSlides().get_Item(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 tbl = sld.getShapes().addTable(100, 50, dblCols, dblRows);
//Set border format for each cell
for(int row = 0; row < tbl.getRows().size(); row++)
{
for (int cell = 0; cell < tbl.getRows().get_Item(row).size(); cell++)
{
tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().getFillFormat().setFillType(FillType.NoFill);
tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().getFillFormat().setFillType(FillType.NoFill);
tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().getFillFormat().setFillType(FillType.NoFill);
tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().getFillFormat().setFillType(FillType.NoFill);
}
}
//Save PPTX to Disk
pres.save("table_no_border.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation pres = new Presentation();
ISlide slide = pres.getSlides().get_Item(0);
double[] colWidth = { 100, 50, 30 };
double[] rowHeight = { 30, 50, 30 };
ITable table = slide.getShapes().addTable(100, 100, colWidth, rowHeight);
table.getRows().removeAt(1, false);
table.getColumns().removeAt(1, false);
pres.save("TestTable.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Create an instance of Presentation class
Presentation pres = new Presentation();
// Get the first slide
ISlide slide = pres.getSlides().get_Item(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.getShapes().addTable(100, 50, dblCols, dblRows);
// Add text to the merged cell
tbl.getRows().get_Item(0).get_Item(1).getTextFrame().setText("10");
tbl.getRows().get_Item(0).get_Item(2).getTextFrame().setText("20");
tbl.getRows().get_Item(0).get_Item(3).getTextFrame().setText("30");
// Accessing the text frame
ITextFrame txtFrame = tbl.getRows().get_Item(0).get_Item(0).getTextFrame();
// Create the Paragraph object for text frame
IParagraph para = txtFrame.getParagraphs().get_Item(0);
// Create Portion object for paragraph
IPortion portion = para.getPortions().get_Item(0);
portion.setText("Text here");
portion.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
portion.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
// Aligning the text vertically
ICell cell = tbl.getRows().get_Item(0).get_Item(0);
cell.setTextAnchorType(TextAnchorType.Center);
cell.setTextVerticalType(TextVerticalType.Vertical270);
// Save Presentation
pres.save("TableCellVertical.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// The path to the documents directory.
String dataDir = Utils.getDataDir(ManagingParagraphPictureBulletsInPPTX.class);
Presentation pres = new Presentation();
try {
// Accessing the first slide
ISlide slide = pres.getSlides().get_Item(0);
// Instantiate the image for bullets
BufferedImage img = null;
try {
img = ImageIO.read(new File(dataDir + "asp1.jpg"));
} catch (IOException e) {
}
IPPImage imgx = pres.getImages().addImage(img);
// Adding and accessing Autoshape
IAutoShape aShp = slide.getShapes().addAutoShape(ShapeType.Rectangle, 200, 200, 400, 200);
// Accessing the text frame of created autoshape
ITextFrame txtFrm = aShp.getTextFrame();
// Removing the default exisiting paragraph
txtFrm.getParagraphs().removeAt(0);
// Creating new paragraph
Paragraph para = new Paragraph();
para.setText("Welcome to Aspose.Slides");
// Setting paragraph bullet style and image
para.getParagraphFormat().getBullet().setType(BulletType.Picture);
para.getParagraphFormat().getBullet().getPicture().setImage(imgx);
// Setting Bullet Height
para.getParagraphFormat().getBullet().setHeight(100);
// Adding Paragraph to text frame
txtFrm.getParagraphs().add(para);
// Writing the presentation as a PPTX file
pres.save(dataDir + "Bullet.pptx", SaveFormat.Pptx);
// Writing the presentation as a PPT file
pres.save(dataDir + "Bullet.ppt", SaveFormat.Ppt);
} finally {
if (pres != null)
pres.dispose();
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Create an instance of Presentation class
Presentation Pres = new Presentation();
// Get first slide
ISlide Slide = Pres.getSlides().get_Item(0);
// Add an AutoShape of Rectangle type
IAutoShape aShp = Slide.getShapes().addAutoShape(ShapeType.Rectangle, 150, 75, 150, 50);
// Add TextFrame to the Rectangle
aShp.addTextFrame("Aspose TextBox");
// Enable shape fill in case we want to get shadow of text.
aShp.getFillFormat().setFillType(FillType.Solid);
aShp.getFillFormat().getSolidFillColor().setColor(Color.gray);
// Add inner shadow and set all necessary parameters
aShp.getEffectFormat().enableInnerShadowEffect();
IInnerShadow Shadow = aShp.getEffectFormat().getInnerShadowEffect();
Shadow.setBlurRadius(50);
Shadow.setDirection(0);
Shadow.setDistance(0);
Shadow.getShadowColor().setColor(Color.BLUE);
// Write the presentation to disk
Pres.save("ShadowPres.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Create an instance of Presentation class
Presentation Pres = new Presentation();
// Get first slide
ISlide Slide = Pres.getSlides().get_Item(0);
// Add an AutoShape of Rectangle type
IAutoShape aShp = Slide.getShapes().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.getFillFormat().setFillType(FillType.NoFill);
// Add outer shadow and set all necessary parameters
aShp.getEffectFormat().enableOuterShadowEffect();
IOuterShadow Shadow = aShp.getEffectFormat().getOuterShadowEffect();
Shadow.setBlurRadius(4.0);
Shadow.setDirection(45);
Shadow.setDistance(3);
Shadow.setRectangleAlign(RectangleAlignment.TopLeft);
Shadow.getShadowColor().setColor(Color.black);
// Write the presentation to disk
Pres.save("OutShadow.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents PPTX
Presentation pres = new Presentation();
// Access first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add an AutoShape of Rectangle type
IAutoShape ashp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 150, 75, 150, 50);
// Add TextFrame to the Rectangle
ashp.addTextFrame(" ");
// Accessing the text frame
ITextFrame txtFrame = ashp.getTextFrame();
// Create the Paragraph object for text frame
IParagraph para = txtFrame.getParagraphs().get_Item(0);
// Create Portion object for paragraph
IPortion portion = para.getPortions().get_Item(0);
// Set Text
portion.setText("Aspose TextBox");
// Save the PPTX to Disk
pres.save("Textbox.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Load the presentation file
Presentation pres = new Presentation("input.pptx");
// Access the default first slide of presentation
ISlide slide = pres.getSlides().get_Item(0);
// Desired index
int index = 0;
// Accessing the added shape
IAutoShape ashape = (IAutoShape) slide.getShapes().get_Item(index);
try {
// Creating output HTML file
OutputStream os = new FileOutputStream("first paragraph_Java.html");
Writer writer = new OutputStreamWriter(os, "UTF-8");
// Extracting first paragraph as HTML
// Writing Paragraphs data to HTML by providing paragraph starting
// index, total paragraphs to be copied
writer.write(ashape.getTextFrame().getParagraphs().exportToHtml(0,
ashape.getTextFrame().getParagraphs().getCount(), null));
writer.close();
} catch (Exception fo) {
fo.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Create Empty presentation instance
Presentation pres = new Presentation();
// Access the default first slide of presentation
ISlide slide = pres.getSlides().get_Item(0);
// Adding the AutoShape to accommodate the HTML content
IAutoShape ashape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 10, 10,
(float) pres.getSlideSize().getSize().getWidth(), (float) pres.getSlideSize().getSize().getHeight());
ashape.getFillFormat().setFillType(FillType.NoFill);
// Adding text frame to the shape
ashape.addTextFrame("");
// Clearing all paragraphs in added text frame
ashape.getTextFrame().getParagraphs().clear();
// Loading the HTML file using InputStream
InputStream inputStream = new FileInputStream("html from pp2010 clipboard.html");
Reader reader = new InputStreamReader(inputStream);
int data = reader.read();
String content = ReadFile("html from pp2010 clipboard.html");
// Adding text from HTML stream reader in text frame
ashape.getTextFrame().getParagraphs().addFromHtml(content);
// Saving Presentation
pres.save("output.pptx", SaveFormat.Pptx);
public static String ReadFile(String FileName) throws Exception {
File file = new File(FileName);
StringBuilder contents = new StringBuilder();
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file));
String text = null;
// repeat until all lines is read
while ((text = reader.readLine()) != null) {
contents.append(text).append(System.getProperty("line.separator"));
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
return contents.toString();
}
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a PPTX file
Presentation pres = new Presentation();
// Get first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add an AutoShape of Rectangle type
IAutoShape ashp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 50, 50, 200, 50);
// Remove any fill style associated with the AutoShape
ashp.getFillFormat().setFillType(FillType.NoFill);
// Access the TextFrame associated with the AutoShape
ITextFrame tf = ashp.getTextFrame();
tf.setText("Aspose TextBox");
// Access the Portion associated with the TextFrame
IPortion port = tf.getParagraphs().get_Item(0).getPortions().get_Item(0);
// Set the Font for the Portion
port.getPortionFormat().setLatinFont(new FontData("Times New Roman"));
// Set Bold property of the Font
port.getPortionFormat().setFontBold(NullableBool.True);
// Set Italic property of the Font
port.getPortionFormat().setFontItalic(NullableBool.True);
// Set Underline property of the Font
port.getPortionFormat().setFontUnderline(TextUnderlineType.Single);
// Set the Height of the Font
port.getPortionFormat().setFontHeight(25);
// Set the color of the Font
port.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
port.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
// Save the presentation to disk
pres.save("pptxFont.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a PPTX file
Presentation pres = new Presentation("welcome.pptx");
// Accessing a slide using its slide position
ISlide slide = pres.getSlides().get_Item(0);
// Accessing the first and second placeholder in the slide and
// typecasting it as AutoShape
ITextFrame tf1 = ((IAutoShape) slide.getShapes().get_Item(0)).getTextFrame();
ITextFrame tf2 = ((IAutoShape) slide.getShapes().get_Item(1)).getTextFrame();
// Accessing the first Paragraph
IParagraph para1 = tf1.getParagraphs().get_Item(0);
IParagraph para2 = tf2.getParagraphs().get_Item(0);
// Justify the paragraph
para2.getParagraphFormat().setAlignment(TextAlignment.JustifyLow);
// Accessing the first portion
IPortion port1 = para1.getPortions().get_Item(0);
IPortion port2 = para2.getPortions().get_Item(0);
// Define new fonts
FontData fd1 = new FontData("Elephant");
FontData fd2 = new FontData("Castellar");
// Assign new fonts to portion
port1.getPortionFormat().setLatinFont(fd1);
port2.getPortionFormat().setLatinFont(fd2);
// Set font to Bold
port1.getPortionFormat().setFontBold(NullableBool.True);
port2.getPortionFormat().setFontBold(NullableBool.True);
// Set font to Italic
port1.getPortionFormat().setFontItalic(NullableBool.True);
port2.getPortionFormat().setFontItalic(NullableBool.True);
// Set font color
port1.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
port1.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
port2.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
port2.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.GREEN);
// Save the PPTX to disk
pres.save("WelcomeFont.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Loading a presentation with an AutoShape having some text in it.
Presentation pres = new Presentation("Spacing.pptx");
// Obtain a slide's reference by its index
ISlide sld = pres.getSlides().get_Item(0);
// Access the TextFrame
ITextFrame tf = ((IAutoShape) sld.getShapes().get_Item(0)).getTextFrame();
// Access the Paragraph
IParagraph para = tf.getParagraphs().get_Item(1);
// Set properties of Paragraph
para.getParagraphFormat().setSpaceWithin(80);
para.getParagraphFormat().setSpaceBefore(40);
para.getParagraphFormat().setSpaceAfter(40);
// SAVING presentation
pres.save("LineSpacing.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation class that represents a PPTX file
Presentation pres = new Presentation();
// Accessing first slide
ISlide slide = pres.getSlides().get_Item(0);
// Add an AutoShape of Rectangle type
IAutoShape ashp = slide.getShapes().addAutoShape(ShapeType.Rectangle, 50, 150, 300, 150);
// Access TextFrame of the AutoShape
ITextFrame tf = ashp.getTextFrame();
// Create Paragraphs and Portions with different text formats
IParagraph para0 = tf.getParagraphs().get_Item(0);
IPortion port01 = new Portion();
IPortion port02 = new Portion();
para0.getPortions().add(port01);
para0.getPortions().add(port02);
IParagraph para1 = new Paragraph();
tf.getParagraphs().add(para1);
IPortion port10 = new Portion();
IPortion port11 = new Portion();
IPortion port12 = new Portion();
para1.getPortions().add(port10);
para1.getPortions().add(port11);
para1.getPortions().add(port12);
IParagraph para2 = new Paragraph();
tf.getParagraphs().add(para2);
IPortion port20 = new Portion();
IPortion port21 = new Portion();
IPortion port22 = new Portion();
para2.getPortions().add(port20);
para2.getPortions().add(port21);
para2.getPortions().add(port22);
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++) {
tf.getParagraphs().get_Item(i).getPortions().get_Item(j).setText("Portion0" + j);
if (j == 0) {
tf.getParagraphs().get_Item(i).getPortions().get_Item(j).getPortionFormat().getFillFormat()
.setFillType(FillType.Solid);
tf.getParagraphs().get_Item(i).getPortions().get_Item(j).getPortionFormat().getFillFormat()
.getSolidFillColor().setColor(Color.RED);
tf.getParagraphs().get_Item(i).getPortions().get_Item(j).getPortionFormat()
.setFontBold(NullableBool.True);
tf.getParagraphs().get_Item(i).getPortions().get_Item(j).getPortionFormat().setFontHeight(15);
} else if (j == 1) {
tf.getParagraphs().get_Item(i).getPortions().get_Item(j).getPortionFormat().getFillFormat()
.setFillType(FillType.Solid);
tf.getParagraphs().get_Item(i).getPortions().get_Item(j).getPortionFormat().getFillFormat()
.getSolidFillColor().setColor(Color.BLUE);
tf.getParagraphs().get_Item(i).getPortions().get_Item(j).getPortionFormat()
.setFontItalic(NullableBool.True);
tf.getParagraphs().get_Item(i).getPortions().get_Item(j).getPortionFormat().setFontHeight(18);
}
}
// SavePPTX to Disk
pres.save("multiParaPort.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation class that represents a PPTX file
Presentation pres = new Presentation();
// Accessing first slide
ISlide slide = pres.getSlides().get_Item(0);
// Adding and accessing Autoshape
IAutoShape aShp = slide.getShapes().addAutoShape(ShapeType.Rectangle, 200, 200, 400, 200);
// Accessing the text frame of created autoshape
ITextFrame txtFrm = aShp.getTextFrame();
// Removing the default exisiting paragraph
txtFrm.getParagraphs().removeAt(0);
// Creating a paragraph
Paragraph para = new Paragraph();
// Setting paragraph bullet style and symbol
para.getParagraphFormat().getBullet().setType(BulletType.Symbol);
para.getParagraphFormat().getBullet().setChar((char) 8226);
// Setting paragraph text
para.setText("Welcome to Aspose.Slides");
// Setting bullet indent
para.getParagraphFormat().setIndent(25);
// Setting bullet color
para.getParagraphFormat().getBullet().getColor().setColorType(ColorType.RGB);
para.getParagraphFormat().getBullet().getColor().setColor(Color.BLACK);
// set IsBulletHardColor to true to use own bullet color
para.getParagraphFormat().getBullet().isBulletHardColor();
// Setting Bullet Height
para.getParagraphFormat().getBullet().setHeight(100);
// Adding Paragraph to text frame
txtFrm.getParagraphs().add(para);
// Creating second paragraph
Paragraph para2 = new Paragraph();
// Setting paragraph bullet type and style
para2.getParagraphFormat().getBullet().setType(BulletType.Numbered);
para2.getParagraphFormat().getBullet().setNumberedBulletStyle(NumberedBulletStyle.BulletCircleNumWDBlackPlain);
// Adding paragraph text
para2.setText("This is numbered bullet");
// Setting bullet indent
para2.getParagraphFormat().setIndent(25);
para2.getParagraphFormat().getBullet().getColor().setColorType(ColorType.RGB);
para2.getParagraphFormat().getBullet().getColor().setColor(Color.BLACK);
// set IsBulletHardColor to true to use own bullet color
para2.getParagraphFormat().getBullet().isBulletHardColor();
// Setting Bullet Height
para2.getParagraphFormat().getBullet().setHeight(100);
// Adding Paragraph to text frame
txtFrm.getParagraphs().add(para2);
// saving the presentation as a PPTX file
pres.save("Bullet.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation Class
Presentation pres = new Presentation();
// Get first slide
ISlide sld = pres.getSlides().get_Item(0);
// Add a Rectangle Shape
IAutoShape rect = sld.getShapes().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.getTextFrameFormat().setAutofitType(TextAutofitType.Shape);
// Hide the lines of the Rectangle
rect.getLineFormat().getFillFormat().setFillType(FillType.Solid);
// Get first Paragraph in the TextFrame and set its Indent
IParagraph para1 = tf.getParagraphs().get_Item(0);
// Setting paragraph bullet style and symbol
para1.getParagraphFormat().getBullet().setType(BulletType.Symbol);
para1.getParagraphFormat().getBullet().setChar((char) (8226));
para1.getParagraphFormat().setAlignment(TextAlignment.Left);
para1.getParagraphFormat().setDepth((short) 2);
para1.getParagraphFormat().setIndent(30);
// Get second Paragraph in the TextFrame and set its Indent
IParagraph para2 = tf.getParagraphs().get_Item(1);
para2.getParagraphFormat().getBullet().setType(BulletType.Symbol);
para2.getParagraphFormat().getBullet().setChar((char) (8226));
para2.getParagraphFormat().setAlignment(TextAlignment.Left);
para2.getParagraphFormat().setDepth((short) 2);
para2.getParagraphFormat().setIndent(40);
// Get third Paragraph in the TextFrame and set its Indent
IParagraph para3 = tf.getParagraphs().get_Item(2);
para3.getParagraphFormat().getBullet().setType(BulletType.Symbol);
para3.getParagraphFormat().getBullet().setChar((char) (8226));
para3.getParagraphFormat().setAlignment(TextAlignment.Left);
para3.getParagraphFormat().setDepth((short) 2);
para3.getParagraphFormat().setIndent(50);
// Write the Presentation to disk
pres.save("InOutDent.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate a Presentation object that represents a PPTX file
Presentation pres = new Presentation("leftalign.pptx");
// Accessing first slide
ISlide slide = pres.getSlides().get_Item(0);
// Accessing the first and second placeholder in the slide and
// typecasting it as AutoShape
ITextFrame tf1 = ((IAutoShape) slide.getShapes().get_Item(0)).getTextFrame();
ITextFrame tf2 = ((IAutoShape) slide.getShapes().get_Item(1)).getTextFrame();
// Change the text in both Placeholders
tf1.setText("Center Align by Aspose");
tf2.setText("Center Align by Aspose");
// Getting the first paragraph of the Placeholders
IParagraph para1 = tf1.getParagraphs().get_Item(0);
IParagraph para2 = tf2.getParagraphs().get_Item(0);
// Aligning the text paragraph to center
para1.getParagraphFormat().setAlignment(TextAlignment.Center);
para2.getParagraphFormat().setAlignment(TextAlignment.Center);
// Writing the presentation as a PPTX file
pres.save("Centeralign.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Create an instance of Presentation class
Presentation pres = new Presentation();
// Get reference of a slide
ISlide slide = pres.getSlides().get_Item(0);
// Add an AutoShape of Rectangle type
IAutoShape ashp = slide.getShapes().addAutoShape(ShapeType.Rectangle, 150, 75, 400, 300);
ashp.getFillFormat().setFillType(FillType.NoFill);
// Add TextFrame to the Rectangle
ashp.addTextFrame("Aspose TextBox");
IPortion port = ashp.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0);
IPortionFormat pf = port.getPortionFormat();
pf.setFontHeight(50);
// Enable InnerShadowEffect
IEffectFormat ef = pf.getEffectFormat();
ef.enableInnerShadowEffect();
// Set all necessary parameters
ef.getInnerShadowEffect().setBlurRadius(8.0);
ef.getInnerShadowEffect().setDirection(90);
ef.getInnerShadowEffect().setDistance(6.0);
ef.getInnerShadowEffect().getShadowColor().setB((byte) 189);
// Set ColorType as Scheme
ef.getInnerShadowEffect().getShadowColor().setColorType(ColorType.Scheme);
// Set Scheme Color
ef.getInnerShadowEffect().getShadowColor().setSchemeColor(SchemeColor.Accent1);
// Write the presentation as a PPTX file
pres.save("WordArt.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Load presentation
Presentation pres = new Presentation("PresContainsArialFont.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
pres.getFontsManager().replaceFont(sourceFont, destFont);
// Save the presentation
pres.save("PresContainsTimesNoewRomanFont.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Instantiate Presentation class that represents PPTX
Presentation pres = new Presentation("welcome.pptx");
// Access first slide
ISlide sld = pres.getSlides().get_Item(0);
// Iterate through shapes to find the placeholder
for (IShape shp : sld.getShapes())
if (shp.getPlaceholder() != null) {
// Change the text of each placeholder
((IAutoShape) shp).getTextFrame().setText("This is Placeholder");
}
// Save the PPTX to Disk
pres.save("welcome_PH.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Create an instance of Presentation class
Presentation pres = new Presentation();
// Access the first slide
ISlide slide = pres.getSlides().get_Item(0);
// Add an AutoShape of Rectangle type
IAutoShape ashp = slide.getShapes().addAutoShape(ShapeType.Rectangle, 150, 75, 350, 350);
// Add TextFrame to the Rectangle
ashp.addTextFrame(" ");
ashp.getFillFormat().setFillType(FillType.NoFill);
// Accessing the text frame
ITextFrame txtFrame = ashp.getTextFrame();
// Setting text Vertical type
txtFrame.getTextFrameFormat().setTextVerticalType(TextVerticalType.Vertical270);
// Create the Paragraph object for text frame
IParagraph para = txtFrame.getParagraphs().get_Item(0);
// Create Portion object for paragraph
IPortion portion = para.getPortions().get_Item(0);
portion.setText("A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog.");
portion.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
portion.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
// Save Presentation
pres.save("VerticleText.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
Presentation pres = new Presentation();
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 500, 300);
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
series.getLabels().getDefaultDataLabelFormat().setShowCategoryName(true);
series.getLabels().getDefaultDataLabelFormat().getTextFormat().getTextBlockFormat().setRotationAngle(65);
chart.hasTitle();
chart.getChartTitle().addTextFrameForOverriding("Custom title").getTextFrameFormat().setRotationAngle(-30);
pres.save("out.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Create an instance of Presentation class
Presentation pres = new Presentation();
// Access the first slide
ISlide slide = pres.getSlides().get_Item(0);
// Add an AutoShape of Rectangle type
IAutoShape ashp = slide.getShapes().addAutoShape(ShapeType.Rectangle, 150, 75, 350, 350);
// Add TextFrame to the Rectangle
ashp.addTextFrame(" ");
ashp.getFillFormat().setFillType(FillType.NoFill);
// Accessing the text frame
ITextFrame txtFrame = ashp.getTextFrame();
// Setting text autofit type
txtFrame.getTextFrameFormat().setAutofitType(TextAutofitType.Shape);
// Create the Paragraph object for text frame
IParagraph para = txtFrame.getParagraphs().get_Item(0);
// Create Portion object for paragraph
IPortion portion = para.getPortions().get_Item(0);
portion.setText("A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog.");
portion.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
portion.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
// Save Presentation
pres.save("formatText.pptx", SaveFormat.Pptx);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
String[] _fontDir = new String[] { "Sample Fonts" };
// Load the custom font directory fonts
FontsLoader.loadExternalFonts(_fontDir);
// Do Some work and perform presentation/slides rendering
Presentation presentation = new Presentation("input.pptx");
// Save the presentation
presentation.save("output.pptx", SaveFormat.Pptx);
// Clear Font Cache
FontsLoader.clearCache();
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Use load options to define the default regualr and asian fonts
LoadOptions lo = new LoadOptions(LoadFormat.Auto);
lo.setDefaultRegularFont("Wingdings");
lo.setDefaultAsianFont("Wingdings");
// Do Some work and perform presentation/slides rendering
Presentation presentation = new Presentation("input.pptx");
// Generate slide thumbnail
BufferedImage image = presentation.getSlides().get_Item(0).getThumbnail(1, 1);
ImageIO.write(image, "png", new File("output.png"));
// Generate PDF
presentation.save("output.pdf", SaveFormat.Pdf);
// Generate XPS
presentation.save("output.xps", SaveFormat.Xps);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
//Instantiate Presentation
Presentation pres = new Presentation();
// Create new VBA Project
pres.setVbaProject(new VbaProject());
// Add empty module to the VBA project
IVbaModule module = pres.getVbaProject().getModules().addEmptyModule("Module");
// Set module source code
module.setSourceCode("Sub Test(oShape As Shape)MsgBox Test End Sub");
// Create reference to <stdole>
VbaReferenceOleTypeLib stdoleReference =
new VbaReferenceOleTypeLib("stdole", "*\\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\\Windows\\system32\\stdole2.tlb#OLE Automation");
// Create reference to Office
VbaReferenceOleTypeLib officeReference =
new VbaReferenceOleTypeLib("Office", "*\\G{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}#2.0#0#C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE14\\MSO.DLL#Microsoft Office 14.0 Object Library");
// Add references to the VBA project
pres.getVbaProject().getReferences().add(stdoleReference);
pres.getVbaProject().getReferences().add(officeReference);
pres.save("test.pptm", SaveFormat.Pptm);
// For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-Java
// Load Presentation
Presentation pres = new Presentation("presentation.pptx");
// Access the Vba module and remove
pres.getVbaProject().getModules().remove(pres.getVbaProject().getModules().get_Item(0));
// Save Presentation
pres.save("test.pptm", SaveFormat.Pptm);
//Instantiate a Presentation object to load source file
Presentation presentation = new Presentation("MyTest.pptx");
//Instantiate presentaiton object
Presentation auxPresentation = new Presentation();
//Loading slide for cloning
ISlide slide = presentation.getSlides().get_Item(0);
//Cloning slide to presentaiton at poistion 0 or first
auxPresentation.getSlides().insertClone(0, slide);
//Set slide size type
auxPresentation.getSlideSize().setType(SlideSizeType.Custom);
//Setting custom slide size
Dimension2D dimension = presentation.getSlideSize().getSize();
dimension.setSize(612F , 792F);
auxPresentation.getSlideSize().setSize(dimension);
//Save Presentation to disk
auxPresentation.save("testPDFnotes.pdf", SaveFormat.PdfNotes);
//Second plot options for Pie of Pie and Bar of Pie chart
//Instantiate Presentation object
Presentation pres = new Presentation();
//Add Pie chart on first slide
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.PieOfPie, 50, 50, 500, 400);
//Getting chart data
IChartData chartData=chart.getChartData();
//Accessing first chart series
IChartSeries series=chartData.getSeries().get_Item(0);
//Setting series properties
series.getLabels().getDefaultDataLabelFormat().setShowValue(true);
series.getParentSeriesGroup().setSecondPieSize(149);
series.getParentSeriesGroup().setPieSplitBy( PieSplitType.ByPercentage);
series.getParentSeriesGroup().setPieSplitPosition((double) 53);
//Saveing presentation to disk
pres.save("pieOFpie.pptx", SaveFormat.Pptx);
//Instantiate Presentation class that represents the PPTX file
Presentation pres = new Presentation();
//Add SmartArt
ISmartArt smart = pres.getSlides().get_Item(0).getShapes().addSmartArt(10, 10, 400, 300, SmartArtLayoutType.BasicCycle);
//Obtain the reference of a node by using its Index
ISmartArtNode node = smart.getNodes().get_Item(1);
//Generating SmartArt node thumbnail
BufferedImage image = node.getShapes().get_Item(0).getThumbnail();;
try{
//Save the image to disk in PNG format
ImageIO.write(image,"png",new File("NodeImage.png"));
}
catch(Exception e)
{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment