Package com.aspose.slides

Examples of com.aspose.slides.Presentation


public class AsposeCreateTable
{
  public static void main(String[] args)
  {
    //Instantiate Presentation class that represents PPTX file
      Presentation pres = new Presentation();

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

      //Define columns with widths and rows with heights
      double[] dblCols = { 50, 50, 50 };
      double[] dblRows = { 50, 30, 30, 30, 30 };

      //Add table shape to slide
      ITable tbl = sld.getShapes().addTable(100, 50, dblCols, dblRows);

      //Set border format for each cell
      for(int row = 0; row < tbl.getRows().size(); row++)
      {
          for (int cell = 0; cell < tbl.getRows().get_Item(row).size(); cell++)
          {
              tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().getFillFormat().setFillType(FillType.Solid);
              tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().getFillFormat().getSolidFillColor().setColor(Color.RED);
              tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().setWidth(5);

              tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().getFillFormat().setFillType(FillType.Solid);
              tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().getFillFormat().getSolidFillColor().setColor(Color.RED);
              tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().setWidth(5);

              tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().getFillFormat().setFillType(FillType.Solid);
              tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().getFillFormat().getSolidFillColor().setColor(Color.RED);
              tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().setWidth(5);

              tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().getFillFormat().setFillType(FillType.Solid);
              tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().getFillFormat().getSolidFillColor().setColor(Color.RED);
              tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().setWidth(5);
          }
      }
      //Merge cells 1 & 2 of row 1
      tbl.mergeCells(tbl.getRows().get_Item(0).get_Item(0), tbl.getRows().get_Item(1).get_Item(0), false);

      //Add text to the merged cell
      tbl.getRows().get_Item(0).get_Item(0).getTextFrame().setText("Merged Cells");

      //Save PPTX to Disk
      pres.save("data/pptx4j/Tables-Aspose.pptx", SaveFormat.Pptx);
     
      System.out.println("Table Created Successfully...");
  }
View Full Code Here


public class AsposeEditExistingCharts
{
  public static void main(String[] args)
  {
    //Instantiate Presentation class that represents PPTX file
    Presentation pres = new Presentation("data/pptx4j/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("data/pptx4j/ChartModified-Aspose.pptx", SaveFormat.Pptx)
    System.out.println("Done");
  }
View Full Code Here

public class AsposeThumbnail
{
  public static void main(String[] args) throws Exception
  {
    //Instantiate a PresentationEx 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 AsposeAddImageToSlide
{
  public static void main(String[] args)
  {
    //Instantiate Presentation class that represents the PPTX
    Presentation pres = new Presentation();

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

    //Instantiate the Image class
    IPPImage imgx = null;

    try{
        imgx = pres.getImages().addImage(new FileInputStream(new File("data/pptx4j/greentick.png")));
    }
    catch(IOException e){}

    //Add Picture Frame with height and width equivalent of Picture
    sld.getShapes().addPictureFrame(ShapeType.Rectangle, 50, 150, imgx.getWidth(), imgx.getHeight(), imgx);

    //Write the PPTX file to disk
    pres.save("data/pptx4j/ImageInSlide-Aspose.pptx", SaveFormat.Pptx);
  }
View Full Code Here

public class AsposeAudioFrame
{
  public static void main(String[] args) throws Exception
  {
    //Instantiate Prsentation class that represents the PPTX
    Presentation pres = new Presentation();
   
    //Get the first slide
    ISlide sld = pres.getSlides().get_Item(0);
   
    //Load the wav sound file to stram
    FileInputStream fstr = new FileInputStream(new File("C:\\logon.wav"));
   
    //Add Audio Frame
    IAudioFrame af = sld.getShapes().addAudioFrameEmbedded(50, 150, 100, 100, fstr);
   
    //Set Play Mode and Volume of the Audio
    af.setPlayMode(AudioPlayModePreset.Auto);
    af.setVolume(AudioVolumeMode.Loud);
   
    //Write the PPTX file to disk
    pres.save("data/AsposeAudio.pptx", SaveFormat.Pptx);
   
    System.out.println("Audio Control Added.");
  }
View Full Code Here

  public static void main(String[] args)
  {
        // 1. Conversion to PDF using default options.

    //Instantiate a Presentation object that represents a PPT file
    Presentation pres = new Presentation("data/presentation.ppt");
   
    //Saving the presentation to PDF document
    pres.save("data/AsposeConvert.pdf", SaveFormat.Pdf);
   
    //Display result of conversion.
    System.out.println("Conversion to PDF performed successfully with default options!");
       
        // 2. Conversion to PDF using custom options.

        //Instantiate the PdfOptions class
        com.aspose.slides.PdfOptions opts = new com.aspose.slides.PdfOptions();

        //Set JPEG Quality
        opts.setJpegQuality((byte)90);

        //Define behavior for meta files
        opts.setSaveMetafilesAsPng(true);

        //Set Text Compression level
        opts.setTextCompression(com.aspose.slides.PdfTextCompression.Flate);

        //Define the PDF standard
        opts.setCompliance(com.aspose.slides.PdfCompliance.Pdf15);

        //Save the presentation to PDF with specified options
        pres.save("data/AsposeConvert2.pdf", SaveFormat.Pdf,opts);

        //Display result of conversion.
        System.out.println("Conversion to PDF performed successfully with custom options!");
  }
View Full Code Here

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

    //Accessing a slide using its index in the slides collection
    ISlide slide = pres.getSlides().get_Item(1);

    //Removing a slide using its reference
    pres.getSlides().remove(slide);
   
    //Removing a slide using its slide index
    pres.getSlides().removeAt(0);

    //Writing the presentation file
    pres.save("data/pptx4j/RemovedSlide-Aspose.pptx",SaveFormat.Pptx);

        //Printing the status
        System.out.println("Slides removed successfully!");
  }
View Full Code Here

    //==================
    //Adding Smart Art
    //==================
   
    //Instantiate Presentation Class
    Presentation pres = new Presentation();
   
    //Get first slide
    ISlide slide = pres.getSlides().get_Item(0);
   
    //Add Smart Art Shape
    ISmartArt smart = slide.getShapes().addSmartArt(0, 0, 400, 400, SmartArtLayoutType.BasicBlockList);
   
    //Saving presentation
    pres.save("data/AsposeSmartArt.pptx", SaveFormat.Pptx);
         
    //=====================
    //Accessing Smart Art
    //=====================
    //Get first slide
    ISlide slide0 = pres.getSlides().get_Item(0);
   
    //Traverse through every shape inside first slide
    for(IShape shape : slide0.getShapes())
    {
        //Check if shape is of SmartArt type
View Full Code Here

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

    //Accessing slides
    for (ISlide slide : pres.getSlides())
    {
      System.out.println(slide.getSlideNumber());     
    }
  }
View Full Code Here

  public static void main(String[] args)
  {
    // ======================================
    // Adding Slide Comments
    // ======================================
    Presentation pres = new Presentation();

    // Adding Empty slide
    pres.getSlides().addEmptySlide(pres.getLayoutSlides().get_Item(0));

    // Adding Author
    ICommentAuthor author = pres.getCommentAuthors().addAuthor("Aspose", "AS");

    // Position of comments
    java.awt.geom.Point2D.Float point = new java.awt.geom.Point2D.Float(0.2f, 0.2f);
    java.util.Date date = new java.util.Date();

    // Adding slide comment for an author on slide 1
    author.getComments().addComment("Hello Mudassir, this is slide comment",
        pres.getSlides().get_Item(0), point, date);

    // Adding slide comment for an author on slide 1
    author.getComments().addComment("Hello Mudassir, this is second slide comment",
        pres.getSlides().get_Item(1), point, date);

    // Accessing ISlide 1
    ISlide slide = pres.getSlides().get_Item(0);

    // if null is passed as an argument then it will bring comments from all
    // authors on selected slide
    IComment[] Comments = slide.getSlideComments(author);

    // Accessing the comment at index 0 for slide 1
    String str = Comments[0].getText();

    pres.save("data/AsposeComments.pptx", SaveFormat.Pptx);

    if (Comments.length > 0)
    {
      // Select comments collection of Author at index 0
      ICommentCollection commentCollection = Comments[0].getAuthor().getComments();

      String comment = commentCollection.get_Item(0).getText();
    }

    // ======================================
    // Accessing Slide Comments
    // ======================================

    // Presentation pres = new Presentation("data/AsposeComments.pptx");
    for (ICommentAuthor author1 : pres.getCommentAuthors())
    {
      for (IComment comment : author1.getComments())
      {
        System.out.println("ISlide :"
          + comment.getSlide().getSlideNumber()
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.