Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Step1.java 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * ====================================================================
  3. * Licensed to the Apache Software Foundation (ASF) under one or more
  4. * contributor license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright ownership.
  6. * The ASF licenses this file to You under the Apache License, Version 2.0
  7. * (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. * ====================================================================
  18. */
  19. package org.apache.poi.xslf.usermodel.tutorial;
  20. import org.apache.poi.xslf.usermodel.XMLSlideShow;
  21. import org.apache.poi.xslf.usermodel.XSLFShape;
  22. import org.apache.poi.xslf.usermodel.XSLFSlide;
  23. import org.apache.poi.xslf.usermodel.XSLFTextParagraph;
  24. import org.apache.poi.xslf.usermodel.XSLFTextRun;
  25. import org.apache.poi.xslf.usermodel.XSLFTextShape;
  26. import java.io.FileInputStream;
  27. /**
  28. * Reading a .pptx presentation and printing basic shape properties
  29. *
  30. * @author Yegor Kozlov
  31. */
  32. public class Step1 {
  33. public static void main(String[] args) throws Exception {
  34. if(args.length == 0) {
  35. System.out.println("Input file is required");
  36. return;
  37. }
  38. XMLSlideShow ppt = new XMLSlideShow(new FileInputStream(args[0]));
  39. for(XSLFSlide slide : ppt.getSlides()){
  40. System.out.println("Title: " + slide.getTitle());
  41. for(XSLFShape shape : slide.getShapes()){
  42. if(shape instanceof XSLFTextShape) {
  43. XSLFTextShape tsh = (XSLFTextShape)shape;
  44. for(XSLFTextParagraph p : tsh){
  45. System.out.println("Paragraph level: " + p.getLevel());
  46. for(XSLFTextRun r : p){
  47. System.out.println(r.getText());
  48. System.out.println(" bold: " + r.isBold());
  49. System.out.println(" italic: " + r.isItalic());
  50. System.out.println(" underline: " + r.isUnderline());
  51. System.out.println(" font.family: " + r.getFontFamily());
  52. System.out.println(" font.size: " + r.getFontSize());
  53. System.out.println(" font.color: " + r.getFontColor());
  54. }
  55. }
  56. }
  57. }
  58. }
  59. }
  60. }