Public API and Backwards Incompatible Changes in Aspose.Slides for PHP via Java 15.1.0

Public API Changes

Fonts substitutions functinality has been added

The possibility to replace fonts globally across the presentation and temporary for rendering has been added.

New method getFontsManager() of Presentation class has been introduced. FontsManager class has following members:

IFontSubstRuleCollection getFontSubstRuleList() method

This is the collection of IFontSubstRule instances used to substitute fonts during rendering. IFontSubstRule has getSourceFont() and getDestFont() methods implementing IFontData interface and getReplaceFontCondition() method allowing to choose the condition of replacement (“WhenInaccessible” or “Always”).

IFontData[] getFonts() method can be used to retrieve all fonts used in the current presentation.

replaceFont(…) methods can be used to persistently replace a font in a presentation. 

The following example shows how to replace a font in a presentation:

  $pres = new Presentation("PresContainsArialFont.pptx");
  $sourceFont = new FontData("Arial");
  $destFont = new FontData("Times New Roman");
  $pres->getFontsManager()->replaceFont($sourceFont, $destFont);
  $pres->save("PresContainsTimesNoewRomanFont.pptx", SaveFormat::Pptx);

Another example, shows font substitution for rendering when it is inaccessible:

  $pres = new Presentation("PresContainsSomeRareFontFont.pptx");
  $sourceFont = new FontData("SomeRareFont");
  $destFont = new FontData("Arial");
  $fontSubstRule = new FontSubstRule($sourceFont, $destFont, FontSubstCondition->WhenInaccessible);
  $fontSubstRuleCollection = new FontSubstRuleCollection();
  $fontSubstRuleCollection->add($fontSubstRule);
  $pres->getFontsManager()->setFontSubstRuleList($fontSubstRuleCollection);
  # Arial font will be used instead of SomeRareFont when inaccessible
  $pres->getSlides()->get_Item(0)->getThumbnail(1, 1);