国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開(kāi)發(fā) > Java > 正文

淺談Java設(shè)置PPT幻燈片背景——純色、漸變、圖片背景

2024-07-14 08:43:53
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

PPT幻燈片生成時(shí),系統(tǒng)默認(rèn)是無(wú)色背景填充,幻燈片設(shè)計(jì)需要手動(dòng)設(shè)置背景效果,可設(shè)置顏色填充或者圖片背景填充。本文將對(duì)此介紹具體實(shí)現(xiàn)方法。

Jar文件導(dǎo)入方法(參考):

步驟1:在Java程序中可新建一個(gè)文件夾命名為L(zhǎng)ib,并將下載包中的jar文件復(fù)制到新建的文件夾下。

Java,PPT,幻燈片,背景

步驟2:復(fù)制文件后,添加到引用類(lèi)庫(kù):選中這個(gè)jar文件,點(diǎn)擊鼠標(biāo)右鍵,選擇“Build Path” – “Add to Build Path”。完成引用。

Java,PPT,幻燈片,背景

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(); }}

純色背景效果:

Java,PPT,幻燈片,背景

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,PPT,幻燈片,背景

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,PPT,幻燈片,背景
 

 

以上所述是小編給大家介紹的Java設(shè)置PPT幻燈片背景——純色、漸變、圖片背景詳解整合,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)VeVb武林網(wǎng)網(wǎng)站的支持!


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到JAVA教程頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 革吉县| 汶川县| 红原县| 盘山县| 五台县| 辽阳县| 黑水县| 深泽县| 霍林郭勒市| 资源县| 霍城县| 张家港市| 子长县| 洛宁县| 莱芜市| 团风县| 华容县| 若尔盖县| 荔波县| 富川| 将乐县| 梅河口市| 扎兰屯市| 孙吴县| 田林县| 阿尔山市| 云安县| 麻栗坡县| 长春市| 晋江市| 井冈山市| 广南县| 盐边县| 龙岩市| 林口县| 天镇县| 肇州县| 肥西县| 鹰潭市| 揭阳市| 沐川县|