淺談Java設(shè)置PPT幻燈片背景——純色、漸變、圖片背景
PPT幻燈片生成時(shí),系統(tǒng)默認(rèn)是無色背景填充,幻燈片設(shè)計(jì)需要手動(dòng)設(shè)置背景效果,可設(shè)置顏色填充或者圖片背景填充。本文將對(duì)此介紹具體實(shí)現(xiàn)方法。
Jar文件導(dǎo)入方法(參考):
步驟1:在Java程序中可新建一個(gè)文件夾命名為Lib,并將下載包中的jar文件復(fù)制到新建的文件夾下。
步驟2:復(fù)制文件后,添加到引用類庫:選中這個(gè)jar文件,點(diǎn)擊鼠標(biāo)右鍵,選擇“Build Path” – “Add to Build Path”。完成引用。
Java示例1:設(shè)置背景顏色
1.純色背景
import com.spire.presentation.*;import com.spire.presentation.drawing.*;public class BackgroundColor { public static void main(String[] args) throws Exception { String inputFile = "sample.pptx"; String outputFile = "output/setBackgroundColor.pptx"; Presentation ppt = new Presentation(); ppt.loadFromFile(inputFile); ppt.getSlides().get(0).getSlideBackground().setType(BackgroundType.CUSTOM); //設(shè)置文檔的背景填充模式為純色填充,設(shè)置顏色 ppt.getSlides().get(0).getSlideBackground().getFill().setFillType(FillFormatType.SOLID); ppt.getSlides().get(0).getSlideBackground().getFill().getSolidColor().setColor(java.awt.Color.PINK); ppt.saveToFile(outputFile, FileFormat.PPTX_2010); ppt.dispose(); } }
純色背景效果:
2.漸變背景
import java.awt.Color;import com.spire.presentation.*;import com.spire.presentation.drawing.*;public class BackgroundColor { public static void main(String[] args) throws Exception { String inputFile = "test.pptx"; String outputFile = "output/setBackgroundColor2.pptx"; Presentation ppt = new Presentation(); ppt.loadFromFile(inputFile); ppt.getSlides().get(0).getSlideBackground().setType(BackgroundType.CUSTOM); //設(shè)置文檔的背景填充模式為漸變填充,并設(shè)置顏色 ppt.getSlides().get(0).getSlideBackground().getFill().setFillType(FillFormatType.GRADIENT); ppt.getSlides().get(0).getSlideBackground().getFill().getGradient().getGradientStops().append(0, Color.white); ppt.getSlides().get(0).getSlideBackground().getFill().getGradient().getGradientStops().append(1,Color.green); ppt.saveToFile(outputFile, FileFormat.PPTX_2010); ppt.dispose(); } }
漸變色背景效果:
Java示例2:圖片背景
import com.spire.presentation.*;import com.spire.presentation.drawing.*;public class ImageBackground { public static void main(String[] args) throws Exception { String inputFile = "Input.pptx"; String imageFile = "1.png"; String outputFile = "output/ImgBackgroundColor.pptx"; Presentation ppt = new Presentation(); ppt.loadFromFile(inputFile); ppt.getSlides().get(0).getSlideBackground().setType(BackgroundType.CUSTOM); //設(shè)置文檔的背景填充模式為圖片填充 ppt.getSlides().get(0).getSlideBackground().getFill().setFillType(FillFormatType.PICTURE); ppt.getSlides().get(0).getSlideBackground().getFill().getPictureFill().setAlignment(RectangleAlignment.NONE); ppt.getSlides().get(0).getSlideBackground().getFill().getPictureFill().setFillType(PictureFillType.STRETCH); ppt.getSlides().get(0).getSlideBackground().getFill().getPictureFill().getPicture().setUrl((new java.io.File(imageFile)).getAbsolutePath()); ppt.saveToFile(outputFile, FileFormat.PPTX_2010); ppt.dispose(); } }
圖片背景效果:
![]() |
以上所述是小編給大家介紹的Java設(shè)置PPT幻燈片背景——純色、漸變、圖片背景詳解整合,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
Spring Boot利用@Async異步調(diào)用:使用Future及定義超時(shí)詳解
這篇文章主要給大家介紹了關(guān)于Spring Boot利用@Async異步調(diào)用:使用Future及定義超時(shí)的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用spring boot具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2018-05-05JPA中@JoinColumn的name和referencedColumnName屬性的區(qū)別及說明
這篇文章主要介紹了JPA中@JoinColumn的name和referencedColumnName屬性的區(qū)別及說明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-05-05java中servlet實(shí)現(xiàn)登錄驗(yàn)證的方法
做web開發(fā),登錄驗(yàn)證是免不了的,今天學(xué)習(xí)了servlet的登錄驗(yàn)證,當(dāng)然是很簡(jiǎn)單的,沒有使用session,request等作用域?qū)ο?,所以還是可以直接通過地址訪問網(wǎng)頁的。2013-05-05java中hashCode方法與equals方法的用法總結(jié)
總的來說,Java中的集合(Collection)有兩類,一類是List,再有一類是Set。前者集合內(nèi)的元素是有序的,元素可以重復(fù);后者元素?zé)o序,但元素不可重復(fù)2013-10-10SpringMVC對(duì)日期類型的轉(zhuǎn)換示例
本篇文章主要介紹了SpringMVC對(duì)日期類型的轉(zhuǎn)換示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-02-02