public static void main(String[] args) {

    // The path to the documents directory.
    String dataDir = Utils.getDataDir(SettingCustomRotationAngleForTextframe.class);

    Presentation pres = new Presentation();

    IChart chart =
        pres.getSlides()
            .get_Item(0)
            .getShapes()
            .addChart(ChartType.ClusteredColumn, 50, 50, 500, 300);

    IChartSeries series = chart.getChartData().getSeries().get_Item(0);

    series.getLabels().getDefaultDataLabelFormat().setShowCategoryName(true);
    series
        .getLabels()
        .getDefaultDataLabelFormat()
        .getTextFormat()
        .getTextBlockFormat()
        .setRotationAngle(65);

    chart.hasTitle();
    chart
        .getChartTitle()
        .addTextFrameForOverriding("Custom title")
        .getTextFrameFormat()
        .setRotationAngle(-30);

    pres.save(dataDir + "out.pptx", SaveFormat.Pptx);
  }
  public static void main(String[] args) {

    // The path to the documents directory.
    String dataDir = Utils.getDataDir(HidingTheShapesFromSlide.class);
    Presentation presentation1 = new Presentation();
    ISlide slide = presentation1.getSlides().get_Item(0);
    for (int i = 0; i < slide.getShapes().size(); i++) {
      IAutoShape ashp = (IAutoShape) slide.getShapes().get_Item(i);
      ashp.setHidden(true);
    }
    presentation1.save(dataDir + "sample_output.pptx", SaveFormat.Pptx);
  }
コード例 #3
0
  public static void main(String[] args) throws Exception {
    // The path to the documents directory.
    String dataDir = Utils.getDataDir(AsposeOpenandSave.class);

    // Instantiate a PresentationEx object that represents a PPTX file
    Presentation pres = new Presentation(dataDir + "presentation.ppt");

    // Add the title slide
    ISlide slide = pres.getSlides().addEmptySlide(pres.getLayoutSlides().get_Item(0));

    // Save the presentation
    pres.save(dataDir + "EditedPPT_Aspose_Out.ppt", SaveFormat.Ppt);

    System.out.println("Presentation Edited and Saved.");
  }
  public static void main(String[] args) {

    // The path to the documents directory.
    String dataDir = Utils.getDataDir(AddingCustomErrorBarValueForChart.class);

    // 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(dataDir + "ErrorBarsCustomValues.pptx", SaveFormat.Pptx);
  }
コード例 #5
0
  public static final void main(String[] args) {

    // The path to the documents directory.
    String dataDir = Utils.getDataDir(CreateAPresentation.class);

    // 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(dataDir + "HelloWorld.pptx", com.aspose.slides.SaveFormat.Pptx);
  }
コード例 #6
0
  public static void main(String[] args) throws IOException {
    // load the presentation with embedded "Calibri" font in it
    Presentation pres = new Presentation(dataDir + "Pres.pptx");
    try {
      // render the presentation containing the text frame with the text using embedded "Calibri"
      // font
      ImageIO.write(
          pres.getSlides().get_Item(0).getThumbnail(new Dimension(960, 720)),
          "PNG",
          new File(dataDir + "pres-1.png"));

      IFontsManager fontsManager = pres.getFontsManager();

      // get all embedded fonts
      IFontData[] embeddedFonts = fontsManager.getEmbeddedFonts();

      // find "Calibri" font
      IFontData calibriEmbeddedFont = null;
      for (int i = 0; i < embeddedFonts.length; i++) {
        System.out.println("" + embeddedFonts[i].getFontName());
        if ("Calibri".equals(embeddedFonts[i].getFontName())) {
          calibriEmbeddedFont = embeddedFonts[i];
          break;
        }
      }

      // remove "Calibri" font
      fontsManager.removeEmbeddedFont(calibriEmbeddedFont);

      // render the presentation after removing the "FunSized" font resulting in a font replacement
      // from "FunSized" to an existing one
      ImageIO.write(
          pres.getSlides().get_Item(0).getThumbnail(new Dimension(960, 720)),
          "PNG",
          new File(dataDir + "pres-2.png"));

      // save the presentation without embedded "Calibri" font
      pres.save(dataDir + "WithoutEmbeddedFont_out.ppt", SaveFormat.Ppt);
    } finally {
      if (pres != null) pres.dispose();
    }
  }
コード例 #7
0
  public static void main(String[] args) {

    // The path to the documents directory.
    String dataDir = Utils.getDataDir(UpdatingExistingChart.class);

    // Instantiate Presentation class that represents PPTX file
    Presentation pres = new Presentation(dataDir + "ExistingChart.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(dataDir + "AsposeChartModified.pptx", SaveFormat.Pptx);
  }
コード例 #8
0
  public static void main(String[] args) throws Exception {
    // The path to the documents directory.
    String dataDir = Utils.getDataDir(ScatteredChart.class);
    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(dataDir + "AsposeScatterChart.pptx", SaveFormat.Pptx);
  }