Как добавить верхний и нижний колонтитул в презентацию
Выпущен новый
Aspose.Slides для Java API , который теперь поддерживает возможность создания документов PowerPoint с нуля и редактирования существующих.
Поддержка устаревшего кода
Для использования устаревшего кода, разработанного с помощью Aspose.Slides для Java версиях ранее 13.x, вам нужно внести некоторые небольшие изменения в свой код, и он будет работать как раньше. Все классы, которые были в старом Aspose.Slides для Java в пространствах имен Aspose.Slide и Aspose.Slides.Pptx теперь объединены в одно пространство имен Aspose.Slides. Пожалуйста, ознакомьтесь со следующим простым фрагментом кода для добавления верхнего и нижнего колонтитула в презентацию в устаревшем API Aspose.Slides и следуйте шагам, описывающим, как мигрировать на новый объединенный API.
Устаревший подход Aspose.Slides для Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PresentationEx sourcePres = new PresentationEx();
//Setting Header Footer visibility properties
sourcePres.setUpdateSlideNumberFields(true);
//Update the Date Time Fields
sourcePres.setUpdateDateTimeFields(true);
//Show date time placeholder
sourcePres.getHeaderFooterManager().isDateTimeVisible(true);
//Show the footer place holder
sourcePres.getHeaderFooterManager().isFooterVisible(true);
//Show Slide Number
sourcePres.getHeaderFooterManager().isSlideNumberVisible(true);
//Set the header footer visibility on Title Slide
sourcePres.getHeaderFooterManager().setVisibilityOnTitleSlide(true);
//Write the presentation to the disk
sourcePres.save("NewSource.pptx",SaveFormat.Pptx);
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Create the presentation
Presentation pres = new Presentation();
//Get first slide
Slide sld = pres.getSlideByPosition(0);
//Access the Header / Footer of the slide
HeaderFooter hf = sld.getHeaderFooter();
//Set Page Number Visibility
hf.setPageNumberVisible(true);
//Set Footer Visibility
hf.setFooterVisible(true);
//Set Header Visibility
hf.setHeaderVisible(true);
//Set Date Time Visibility
hf.setDateTimeVisible(true);
//Set Date Time format
hf.setDateTimeFormat(DateTimeFormat.DateTime_dMMMMyyyy);
//Set Header Text
hf.setHeaderText("Header Text");
//Set Footer Text
hf.setFooterText("Footer Text");
//Write the presentation to the disk
pres.save("HeadFoot.ppt",SaveFormat.Ppt);
Новый подход Aspose.Slides для Java 13.x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Presentation sourcePres = new Presentation();
//Setting Header Footer visibility properties
sourcePres.UpdateSlideNumberFields = true;
//Update the Date Time Fields
sourcePres.UpdateDateTimeFields = true;
//Show date time placeholder
sourcePres.HeaderFooterManager.IsDateTimeVisible = true;
//Show the footer place holder
sourcePres.HeaderFooterManager.IsFooterVisible = true;
//Show Slide Number
sourcePres.HeaderFooterManager.IsSlideNumberVisible = true;
//Set the header footer visibility on Title Slide
sourcePres.HeaderFooterManager.SetVisibilityOnTitleSlide(true);
//Write the presentation to the disk
sourcePres.save("NewSource.pptx",SaveFormat.Pptx);