您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

BulletsDemo.java 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.examples.hslf;
  16. import java.io.FileOutputStream;
  17. import java.io.IOException;
  18. import org.apache.poi.hslf.usermodel.HSLFSlide;
  19. import org.apache.poi.hslf.usermodel.HSLFSlideShow;
  20. import org.apache.poi.hslf.usermodel.HSLFTextBox;
  21. import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
  22. /**
  23. * How to create a single-level bulleted list
  24. * and change some of the bullet attributes
  25. */
  26. public final class BulletsDemo {
  27. public static void main(String[] args) throws IOException {
  28. try (HSLFSlideShow ppt = new HSLFSlideShow()) {
  29. HSLFSlide slide = ppt.createSlide();
  30. HSLFTextBox shape = new HSLFTextBox();
  31. HSLFTextParagraph rt = shape.getTextParagraphs().get(0);
  32. rt.getTextRuns().get(0).setFontSize(42d);
  33. rt.setBullet(true);
  34. rt.setIndent(0d); //bullet offset
  35. rt.setLeftMargin(50d); //text offset (should be greater than bullet offset)
  36. rt.setBulletChar('\u263A'); //bullet character
  37. shape.setText(
  38. "January\r" +
  39. "February\r" +
  40. "March\r" +
  41. "April");
  42. slide.addShape(shape);
  43. shape.setAnchor(new java.awt.Rectangle(50, 50, 500, 300)); //position of the text box in the slide
  44. slide.addShape(shape);
  45. try (FileOutputStream out = new FileOutputStream("bullets.ppt")) {
  46. ppt.write(out);
  47. }
  48. }
  49. }
  50. }