This Gist contains code snippets for sample code of Aspose.Slides
-
-
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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()); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters