Module: Asposeslidesjava::ManageFont

Defined in:
lib/asposeslidesjava/Text/managefont.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



3
4
5
6
# File 'lib/asposeslidesjava/Text/managefont.rb', line 3

def initialize()
    # Replacing Fonts Explicitly Inside Presentation
    replace_font()
end

#replace_fontObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/asposeslidesjava/Text/managefont.rb', line 8

def replace_font()    
    data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Text/'
            
    # Create an instance of Presentation class
    pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'input.pptx')

    # Load source font to be replaced
    source_font = Rjb::import('com.aspose.slides.FontData').new("Arial")
        
    # Load the replacing font
    dest_font = Rjb::import('com.aspose.slides.FontData').new("Times New Roman")
        
    # Replace the fonts
    fonts_manager = Rjb::import('com.aspose.slides.FontsManager')
    pres.fonts_manager.replaceFont(source_font, dest_font)

    # Write the presentation as a PPTX file 
    pres.save(data_dir + "ReplaceFont.pptx", Rjb::import('com.aspose.slides.SaveFormat').Pptx)

    puts "Replaced font, please check the output file."
end