Package com.aspose.slides

Examples of com.aspose.slides.Presentation


public class AsposeApplyProtectionwithPropertiesAccess
{
  public static void main(String[] args)
  {
    //Instantiate a Presentation object that represents a PPT file
    Presentation pres = new Presentation();

    //....do some work here.....

    //Setting access to document properties in password protected mode
    pres.getProtectionManager().setEncryptDocumentProperties ( false);

    //Setting Password
    pres.getProtectionManager().encrypt("pass");

    //Save your presentation to a file
    pres.save("data/AsposeProtection-PropAccess.pptx", com.aspose.slides.SaveFormat.Pptx);
   
      //Printing the status
      System.out.println("Protection Applied successfully!");
  }
View Full Code Here


public class AsposeCloneToSpecifiedPosition
{
  public static void main(String[] args)
  {
    //Instantiate Presentation class that represents a presentation file
    Presentation pres = new Presentation("data/presentation.pptx");

    //Clone the desired slide to the end of the collection of slides in the same presentation
    ISlideCollection slds = pres.getSlides();

    //Clone the desired slide to the specified index in the same presentation
    slds.insertClone(2, pres.getSlides().get_Item(1));

    //Write the modified presentation to disk
    pres.save("data/AsposeCloneToPosition.pptx", SaveFormat.Pptx);
  }
View Full Code Here

    //====================
    // Removing Smart Art
    //====================

    // Load the desired the presentation
    Presentation pres = new Presentation("data/AsposeAddSmartArtNode.pptx");

    // Traverse through every shape inside first slide
    for (IShape shape : pres.getSlides().get_Item(0).getShapes())
    {

      // Check if shape is of SmartArt type
      if (shape instanceof ISmartArt)
      {
        // Typecast shape to SmartArtEx
        ISmartArt smart = (ISmartArt) shape;

        if (smart.getAllNodes().getCount() > 0)
        {
          // Accessing SmartArt node at index 0
          ISmartArtNode node = smart.getAllNodes().get_Item(0);

          // Removing the selected node
          smart.getAllNodes().removeNode(node);

        }
      }
    }

    // Save Presentation
    pres.save("data/AsposeRemoveSmartArtNode.pptx", SaveFormat.Pptx);

    //============================================
    // Removing Smart Art from Specific Location
    //============================================
       
    // Load the desired the presentation
    Presentation pres1 = new Presentation(
        "data/AsposeAddSmartArtNodeByPosition.pptx");

    // Traverse through every shape inside first slide
    for (IShape shape : pres1.getSlides().get_Item(0).getShapes())
    {

      // Check if shape is of SmartArt type
      if (shape instanceof SmartArt)
      {
        // Typecast shape to SmartArt
        SmartArt smart = (SmartArt) shape;

        if (smart.getAllNodes().getCount() > 0)
        {
          // Accessing SmartArt node at index 0
          ISmartArtNode node = smart.getAllNodes().get_Item(0);

          if (node.getChildNodes().getCount() >= 2)
          {
            // Removing the child node at position 1
            ((SmartArtNodeCollection) node.getChildNodes())
                .removeNodeByPosition(1);
          }
        }
      }
    }
    // Save Presentation
    pres1.save("data/AsposeRemoveSmartArtNodeByPosition.pptx",  SaveFormat.Pptx);
    System.out.println("Smart Art removed.");
  }
View Full Code Here

public class AsposeApplyPasswordProtection
{
  public static void main(String[] args)
  {
    //Instantiate a Presentation object that represents a PPT file
    Presentation pres = new Presentation();

    //....do some work here.....

    //Setting Password
    pres.getProtectionManager().encrypt("pass");

    //Save your presentation to a file
    pres.save("data/AsposeProtection.pptx", com.aspose.slides.SaveFormat.Pptx);
     
      //Printing the status
      System.out.println("Protection Applied successfully!");
  }
View Full Code Here

        //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( "data/AsposeProtection-PropAccess.pptx", loadOptions);

        //Getting Document Properties
        IDocumentProperties docProps = pres.getDocumentProperties();

        System.out.println("Properties Count: " + docProps.getCount());
  }
View Full Code Here

    //==================
    // Adding Smart Art
    //==================

    // Load the desired the presentation
    Presentation pres = new Presentation("data/AsposeSmartArt.pptx");

    // Traverse through every shape inside first slide
    for (IShape shape : pres.getSlides().get_Item(0).getShapes())
    {

      // Check if shape is of SmartArt type
      if (shape instanceof SmartArt)
      {

        // Typecast shape to SmartArt
        SmartArt smart = (SmartArt) shape;

        // Adding a new SmartArt Node
        SmartArtNode TemNode = (SmartArtNode) smart.getAllNodes().addNode();

        // Adding text
        TemNode.getTextFrame().setText("Test");

        // Adding new child node in parent node. It will be added in the end of collection
        SmartArtNode newNode = (SmartArtNode) TemNode.getChildNodes().addNode();

        // Adding text
        newNode.getTextFrame().setText("New Node Added");
      }
    }

    // Saving Presentation
    pres.save("data/AsposeAddSmartArtNode.pptx", SaveFormat.Pptx);
   
    //=========================================
    // Adding Smart Art to Specific Location
    //=========================================
   
    //Creating a presentation instance                                                                      
      Presentation pres1 = new Presentation();
                                                                                                              
      //Access the presentation slide                                                                         
      ISlide slide = pres1.getSlides().get_Item(0);                                                            
                                                                                                              
      //Add Smart Art IShape                                                                                  
      ISmartArt smart = slide.getShapes().addSmartArt(0, 0, 400, 400, SmartArtLayoutType.StackedList);        
                                                                                                              
      //Accessing the SmartArt node at index 0                                                                
      ISmartArtNode node = smart.getAllNodes().get_Item(0);                                                   
                                                                                                              
      //Adding new child node at position 2 in parent node                                                    
      SmartArtNode chNode = (SmartArtNode)((SmartArtNodeCollection)node.getChildNodes()).addNodeByPosition(2);
                                                                                                              
      //Add Text                                                                                              
      chNode.getTextFrame().setText("Sample Text Added");                                                     
                                                                                                              
      //Save Presentation                                                                                     
      pres1.save("data/AsposeAddSmartArtNodeByPosition.pptx", SaveFormat.Pptx);
      System.out.println("Smart Art added and to specific location.");
  }
View Full Code Here

public class AsposeShadowEffectsOnText
{
  public static void main(String[] args)
  {
    // instantiate a Presentation Object
    Presentation pres = new Presentation();

    // Get first slide
    ISlide sld = pres.getSlides().get_Item(0);

    // Add an AutoShape of Rectangle type
    IAutoShape ashp = sld.getShapes().addAutoShape(ShapeType.Rectangle,
        150, 75, 150, 50);

    // Add TextFrame to the Rectangle
    ashp.addTextFrame("Aspose TextBox");

    // Disable shape fill in case we want to get shadow of text.
    ashp.getFillFormat().setFillType(FillType.NoFill);

    // Add outer shadow and set all necessary parameters
    OuterShadow shadow = new OuterShadow();
    ashp.getEffectFormat().setOuterShadowEffect(shadow);
    shadow.setBlurRadius(4.0);
    shadow.setDirection(45);
    shadow.setDistance(3);
    shadow.setRectangleAlign(RectangleAlignment.TopLeft);
    shadow.getShadowColor().setPresetColor(PresetColor.Black);

    // Write the presentation to disk
    pres.save("data/AsposeTextShadow.pptx", SaveFormat.Pptx);
    System.out.println("Done");
  }
View Full Code Here

public class AsposeReplaceTxtInPlaceHolders
{
  public static void main(String[] args)
  {
    //Instantiate Presentation class that represents PPTX
    Presentation pres = new Presentation("data/demo.pptx");
   
    //Access first slide
    ISlide slide = pres.getSlides().get_Item(0);
   
    IShape shape= null;
   
    //Iterate through the shapes and set a reference to the table found
    for (int i = 0 ; i < slide.getShapes().size() ; i++)
    {
        shape = slide.getShapes().get_Item(i);
        if (shape.getPlaceholder() != null)
        {
            //Change the text of each placeholder
            ((IAutoShape)shape).getTextFrame().setText("This is Placeholder");
        }
    }
   
    //Write the PPTX to Disk
    pres.save("data/AsposeReplaceTxt.pptx",SaveFormat.Pptx);

        // Status
        System.out.println("Process completed successfully.");
  }
View Full Code Here

public class AsposeThumbnail
{
  public static void main(String[] args) throws Exception
  {
    //Instantiate a Presentation class that represents the PPTX file
    Presentation pres = new Presentation("data/presentation.pptx");
   
    //Access the first slide
    ISlide sld = pres.getSlides().get_Item(0);
   
    //Create a full scale image
    BufferedImage image = sld.getThumbnail(1f, 1f);
   
    //Save the image to disk in JPEG format
View Full Code Here

public class AsposeCharts
{
  public static void main(String[] args) throws Exception
  {
    //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);

    //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(true);

    //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("data/AsposeChart.pptx", SaveFormat.Pptx);
    System.out.println("Done");
  }
View Full Code Here

TOP

Related Classes of com.aspose.slides.Presentation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.