Module: Asposeslidesjava::Background
- Defined in:
- lib/asposeslidesjava/Slides/background.rb
Instance Method Summary collapse
- #initialize ⇒ Object
- #set_background_color_of_master_slide ⇒ Object
- #set_background_color_of_normal_slide ⇒ Object
- #set_image_as_background_color ⇒ Object
Instance Method Details
#initialize ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/asposeslidesjava/Slides/background.rb', line 3 def initialize() # Setting the Background Color of a Master Slide () # Setting the Background Color of a Normal Slide () # Setting the Slide Background to an Image set_image_as_background_color() end |
#set_background_color_of_master_slide ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/asposeslidesjava/Slides/background.rb', line 14 def () data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/' # Instantiate Presentation class that represents the presentation file pres = Rjb::import('com.aspose.slides.Presentation').new # Set the background color of the Master Slide to Forest Green pres.getMasters().get_Item(0).getBackground().setType(Rjb::import('com.aspose.slides.BackgroundType').OwnBackground) pres.getMasters().get_Item(0).getBackground().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid) pres.getMasters().get_Item(0).getBackground().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').GREEN) # Saving the presentation save_format = Rjb::import('com.aspose.slides.SaveFormat') pres.save(data_dir + "MasterBG.pptx", save_format.Pptx) puts "Set background color of master slide, please check the output file." end |
#set_background_color_of_normal_slide ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/asposeslidesjava/Slides/background.rb', line 32 def () data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/' # Instantiate Presentation class that represents the presentation file pres = Rjb::import('com.aspose.slides.Presentation').new # Set the background color of the Normal slide to Blue pres.getSlides().get_Item(0).getBackground().setType(Rjb::import('com.aspose.slides.BackgroundType').OwnBackground) pres.getSlides().get_Item(0).getBackground().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid) pres.getSlides().get_Item(0).getBackground().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').BLUE) # Saving the presentation save_format = Rjb::import('com.aspose.slides.SaveFormat') pres.save(data_dir + "ContentBG.pptx", save_format.Pptx) puts "Set background color of normal slide, please check the output file." end |
#set_image_as_background_color ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/asposeslidesjava/Slides/background.rb', line 50 def set_image_as_background_color() data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/' # Instantiate Presentation class that represents the presentation file pres = Rjb::import('com.aspose.slides.Presentation').new # Set the background with Image pres.getSlides().get_Item(0).getBackground().setType(Rjb::import('com.aspose.slides.BackgroundType').OwnBackground) pres.getSlides().get_Item(0).getBackground().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Picture) pres.getSlides().get_Item(0).getBackground().getFillFormat().getPictureFillFormat().setPictureFillMode(Rjb::import('com.aspose.slides.PictureFillMode').Stretch) # Set the picture imgx = pres.getImages().addImage(Rjb::import('java.io.FileInputStream').new(Rjb::import('java.io.File').new(data_dir + 'night.jpg'))) # Image imgx = pres.getImages().addImage(image); # Add image to presentation's images collection pres.getSlides().get_Item(0).getBackground().getFillFormat().getPictureFillFormat().getPicture().setImage(imgx) # Saving the presentation save_format = Rjb::import('com.aspose.slides.SaveFormat') pres.save(data_dir + "ContentBG_Image.pptx", save_format.Pptx) puts "Set image as background, please check the output file." end |