Skip to content

Commit c82e5d3

Browse files
committed
Added examples ver. 25.8
1 parent 5652141 commit c82e5d3

File tree

11 files changed

+272
-7
lines changed

11 files changed

+272
-7
lines changed
49.6 KB
Binary file not shown.

Examples/Data/Slides/Media/audio.mp3

547 KB
Binary file not shown.

Examples/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@
2525
<dependency>
2626
<groupId>com.aspose</groupId>
2727
<artifactId>aspose-cells</artifactId>
28-
<version>25.6</version>
28+
<version>25.7</version>
2929
<type>jar</type>
3030
</dependency>
3131
<dependency>
3232
<groupId>com.aspose</groupId>
3333
<artifactId>aspose-slides</artifactId>
34-
<version>25.7</version>
34+
<version>25.8</version>
3535
<classifier>jdk16</classifier>
3636
</dependency>
3737
<dependency>
3838
<groupId>com.aspose</groupId>
3939
<artifactId>aspose-slides</artifactId>
40-
<version>25.7</version>
40+
<version>25.8</version>
4141
<classifier>javadoc</classifier>
4242
</dependency>
4343
</dependencies>

Examples/src/main/java/com/aspose/slides/examples/RunExamples.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ public static void main(String[] args) throws Exception
103103
//TimeUnitTypeEnum.main(null);
104104
//LeaderLineColor.main(null);
105105
//ChartDataPointIndex.main(null);
106+
//ExtractExcelDataExample.main(null);
107+
//ImportingChartsFromExcelExample.main(null);
106108

107109
//// =====================================================
108110
//// Presentations
@@ -310,6 +312,7 @@ public static void main(String[] args) throws Exception
310312
//AdjustValueTypeExample.main(null);
311313
//PictureFrameIsCameoExample.main(null);
312314
//InkEffectsExample.main(null);
315+
//BrightnessContrastEffectExample.main(null);
313316

314317
//// =====================================================
315318
//// Slides
@@ -423,6 +426,7 @@ public static void main(String[] args) throws Exception
423426
//VolumeAudioExample.main(null);
424427
//TrimmingTimeAudioExample.main(null);
425428
//VideoCaptionsExample.main(null);
429+
//AudioCaptionsExample.main(null);
426430

427431
//// =====================================================
428432
//// Rendering - Printing a Slide
@@ -556,6 +560,8 @@ public static void main(String[] args) throws Exception
556560
//GetPresentationRowTextExample.main(null);
557561
//DisableFontLigaturesExample.main(null);
558562
//SplitTextByColumnsExample.main(null);
563+
//ManageScriptFontsExample.main(null);
564+
//GetPlaceholderTextExample.main(null);
559565

560566
//// =====================================================
561567
//// VBA Macros
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.aspose.slides.examples.charts;
2+
3+
import com.aspose.slides.*;
4+
import com.aspose.slides.Collections.Generic.Dictionary;
5+
import com.aspose.slides.Collections.Generic.KeyValuePair;
6+
import com.aspose.slides.Collections.Generic.List;
7+
import com.aspose.slides.examples.RunExamples;
8+
9+
public class ExtractExcelDataExample
10+
{
11+
public static void main(String[] args)
12+
{
13+
14+
// The path to the documents directory.
15+
String dataDir = RunExamples.getDataDir_Charts();
16+
String externalWbPath = dataDir + "book1.xlsx";
17+
18+
//ExStart:ExtractExcelDataExample
19+
// extract a value from a cell
20+
IExcelDataWorkbook workbook = new ExcelDataWorkbook(externalWbPath);
21+
IExcelDataCell cell = workbook.getCell("Sheet2", "B2");
22+
System.out.println(cell.getValue());
23+
24+
//retrieve worksheet names and chart names from an Excel workbook
25+
List<String> sheetNames = workbook.getWorksheetNames();
26+
for (String name : sheetNames)
27+
{
28+
System.out.println("Worksheet " + name + " has the following charts:");
29+
30+
Dictionary<Integer, String> sheetCharts = workbook.getChartsFromWorksheet(name);
31+
for (KeyValuePair<Integer, String> chart : sheetCharts)
32+
System.out.println(chart.getKey() + " - " + chart.getValue());
33+
}
34+
//ExEnd:ExtractExcelDataExample
35+
}
36+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.aspose.slides.examples.charts;
2+
3+
import com.aspose.slides.*;
4+
import com.aspose.slides.Collections.Generic.Dictionary;
5+
import com.aspose.slides.Collections.Generic.KeyValuePair;
6+
import com.aspose.slides.Collections.Generic.List;
7+
import com.aspose.slides.examples.RunExamples;
8+
9+
public class ImportingChartsFromExcelExample
10+
{
11+
public static void main(String[] args)
12+
{
13+
// Path to excel file
14+
String dataDir = RunExamples.getDataDir_Charts();
15+
String externalWbPath = dataDir + "book1.xlsx";
16+
17+
// Path to output file
18+
String outFileName = RunExamples.getOutPath() + "ImportExcelChart.pptx";
19+
20+
//ExStart:ImportingChartsFromExcelExample
21+
// Initializes a new instance using the specified file path
22+
ExcelDataWorkbook workbook = new ExcelDataWorkbook(externalWbPath);
23+
24+
Presentation pres = new Presentation();
25+
try {
26+
ILayoutSlide blankLayout = pres.getLayoutSlides().getByType(SlideLayoutType.Blank);
27+
28+
// Gets the names of all worksheets contained in the Excel workbook
29+
List<String> worksheetNames = workbook.getWorksheetNames();
30+
for (String name : worksheetNames)
31+
{
32+
// Gets a dictionary containing the indexes and names of all charts in the specified worksheet of an Excel workbook
33+
Dictionary<Integer, String> worksheetCharts = workbook.getChartsFromWorksheet(name);
34+
for (KeyValuePair<Integer, String> chart : worksheetCharts)
35+
{
36+
ISlide slide = pres.getSlides().addEmptySlide(blankLayout);
37+
// Imports the chart from a workbook file by its name and worksheet name
38+
ExcelWorkbookImporter.addChartFromWorkbook(slide.getShapes(), 10, 10, workbook, name, chart.getKey(), false);
39+
}
40+
}
41+
42+
// Saves result
43+
pres.save(outFileName, SaveFormat.Pptx);
44+
} finally {
45+
if (pres != null) pres.dispose();
46+
}
47+
//ExEnd:ImportingChartsFromExcelExample
48+
}
49+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.aspose.slides.examples.shapes;
2+
3+
import com.aspose.slides.*;
4+
import com.aspose.slides.examples.RunExamples;
5+
6+
public class BrightnessContrastEffectExample
7+
{
8+
public static void main(String[] args)
9+
{
10+
// Path to source presentation
11+
String presentationName = RunExamples.getDataDir_Shapes() + "BrightnessContrast.pptx";
12+
13+
//ExStart:BrightnessContrastEffectExample
14+
Presentation presentation = new Presentation(presentationName);
15+
try {
16+
// Get slide
17+
ISlide slide = presentation.getSlides().get_Item(0);
18+
19+
// Get picture frame
20+
IPictureFrame pictureFrame = (IPictureFrame)(slide.getShapes().get_Item(0));
21+
22+
// Get image transform operations
23+
IImageTransformOperationCollection imageTransform = pictureFrame.getPictureFormat().getPicture().getImageTransform();
24+
for (IImageTransformOperation effect : imageTransform)
25+
{
26+
if (effect instanceof IBrightnessContrast)
27+
{
28+
// Get brightness and contrast values
29+
IBrightnessContrast brightnessContrast = (IBrightnessContrast)effect;
30+
IBrightnessContrastEffectiveData brightnessContrastData = brightnessContrast.getEffective();
31+
32+
System.out.println("Brightness value = " + brightnessContrastData.getBrightness());
33+
System.out.println("Contrast value = " + brightnessContrastData.getContrast());
34+
}
35+
}
36+
} finally {
37+
if (presentation != null) presentation.dispose();
38+
}
39+
//ExEnd:BrightnessContrastEffectExample
40+
}
41+
}

Examples/src/main/java/com/aspose/slides/examples/slides/layout/ManageHeaderFooterText.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ public static void main(String[] args)
1515
String dataDir = RunExamples.getDataDir_Slides_Presentations_Layout();
1616

1717
// Load Presentation
18-
Presentation pres = new Presentation(dataDir + "headerTest.pptx");
18+
Presentation pres = new Presentation(dataDir + "presentation.pptx");
1919

2020
// Setting Footer
2121
pres.getHeaderFooterManager().setAllFootersText("My Footer text");
2222
pres.getHeaderFooterManager().setAllFootersVisibility(true);
2323

2424
// Access and Update Header
25-
IMasterNotesSlide masterNotesSlide = pres.getMasterNotesSlideManager().getMasterNotesSlide();
25+
IMasterSlide masterNotesSlide = pres.getMasters().get_Item(0);
2626
if (null != masterNotesSlide)
2727
{
2828
updateHeaderFooterText(masterNotesSlide);
2929
}
3030

3131
// Save presentation
32-
pres.save(dataDir + "HeaderFooterJava.pptx", SaveFormat.Pptx);
32+
pres.save(RunExamples.getOutPath() + "HeaderFooterJava.pptx", SaveFormat.Pptx);
3333

3434
//ExEnd:ManageHeaderFooterText
3535

@@ -43,7 +43,7 @@ public static void updateHeaderFooterText(IBaseSlide master)
4343
{
4444
if (shape.getPlaceholder() != null)
4545
{
46-
if (shape.getPlaceholder().getType() == PlaceholderType.Header)
46+
if (shape.getPlaceholder().getType() == PlaceholderType.Footer)
4747
{
4848
((IAutoShape) shape).getTextFrame().setText("HI there new header");
4949
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.aspose.slides.examples.slides.media;
2+
3+
import com.aspose.slides.*;
4+
import com.aspose.slides.examples.RunExamples;
5+
6+
import java.io.FileInputStream;
7+
import java.io.FileNotFoundException;
8+
import java.io.FileOutputStream;
9+
import java.io.IOException;
10+
11+
public class AudioCaptionsExample
12+
{
13+
public static void main(String[] args)
14+
{
15+
String mediaFile = RunExamples.getDataDir_Slides_Presentations_Media() + "audio.mp3";
16+
String trackFile = RunExamples.getDataDir_Slides_Presentations_Media() + "bunny.vtt";
17+
String outCaption = RunExamples.getOutPath() + "AudioCaption_out.vtt";
18+
String outAddPath = RunExamples.getOutPath() + "AudioCaptionAdd_out.pptx";
19+
String outRemovePath = RunExamples.getOutPath() + "AudioCaptionRemove_out.pptx";
20+
21+
//ExStart:AudioCaptionsExample
22+
// Add captions to a VideoFrame
23+
Presentation pres = new Presentation();
24+
try {
25+
IAudio audio = pres.getAudios().addAudio(new FileInputStream(mediaFile), LoadingStreamBehavior.KeepLocked);
26+
IAudioFrame audioFrame = pres.getSlides().get_Item(0).getShapes().addAudioFrameEmbedded(10, 10, 50, 50, audio);
27+
28+
// Adds the new captions track from file
29+
audioFrame.getCaptionTracks().add("New track", trackFile);
30+
31+
pres.save(outAddPath, SaveFormat.Pptx);
32+
} catch (FileNotFoundException e) {
33+
e.printStackTrace();
34+
} finally {
35+
if (pres != null) pres.dispose();
36+
}
37+
38+
// Extract captions from a VideoFrame
39+
Presentation pres1 = new Presentation(outAddPath);
40+
try {
41+
IAudioFrame audioFrame = (IAudioFrame)pres1.getSlides().get_Item(0).getShapes().get_Item(0);
42+
if (audioFrame != null)
43+
{
44+
for (ICaptions captionTrack : audioFrame.getCaptionTracks())
45+
{
46+
// Extracts the captions binary data and saves theme to the file
47+
FileOutputStream fos = new FileOutputStream(outCaption);
48+
fos.write(captionTrack.getBinaryData());
49+
fos.close();
50+
}
51+
52+
// Removes all captions from the VideoFrame
53+
audioFrame.getCaptionTracks().clear();
54+
55+
pres1.save(outRemovePath, SaveFormat.Pptx);
56+
}
57+
} catch (IOException e) {
58+
e.printStackTrace();
59+
} finally {
60+
if (pres1 != null) pres1.dispose();
61+
}
62+
//ExEnd:AudioCaptionsExample
63+
}
64+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.aspose.slides.examples.text;
2+
3+
import com.aspose.slides.*;
4+
5+
public class GetPlaceholderTextExample
6+
{
7+
public static void main(String[] args)
8+
{
9+
//ExStart:GetPlaceholderTextExample
10+
Presentation presentation = new Presentation();
11+
try {
12+
// Add new slide based on LayoutSlides[0]
13+
ISlide slide = presentation.getSlides().addEmptySlide(presentation.getLayoutSlides().get_Item(0));
14+
15+
// Search for specified text in a slide, including its layout (layout template text)
16+
for (ITextFrame textFrame : SlideUtil.getTextBoxesContainsText(slide, "Click", true))
17+
{
18+
// Set text for TextFrame
19+
System.out.println("A text block with the specified text was found.");
20+
textFrame.setText("The new text!");
21+
}
22+
23+
// Find all “Text” placeholders on a slide:
24+
for (IShape shape : SlideUtil.findShapesByPlaceholderType(slide, PlaceholderType.CenteredTitle))
25+
{
26+
System.out.println("Placeholder of type PlaceholderType.CenteredTitle was found.");
27+
((IAutoShape)shape).getTextFrame().setText("This is a Text placeholder.");
28+
}
29+
} finally {
30+
if (presentation != null) presentation.dispose();
31+
}
32+
//ExEnd:GetPlaceholderTextExample
33+
}
34+
}

0 commit comments

Comments
 (0)