【问题标题】:Java Aspose Slides find and replace text cannot keep text styleJava Aspose Slides 查找和替换文本无法保持文本样式
【发布时间】:2023-02-01 21:56:40
【问题描述】:

我正在使用:Aspose.Slides lib 来读取 PPT 和 PPTX 文件。

当我用另一个文本替换文本时,字体大小被破坏了。 起源:

替换文字后:

public void asposeTranslate(String fileName) throws IOException {
        Locale.setDefault(new Locale("en-us"));
        // Load presentation
        Presentation pres = new Presentation(URL + "/" + fileName);
        
        // Loop through each slide
        for (ISlide slide : pres.getSlides()) {
            // Get all text frames in the slide
            ITextFrame[] tf = SlideUtil.getAllTextBoxes(slide);

            for (int i = 0; i < tf.length; i++) {

                for (IParagraph para : tf[i].getParagraphs()) {
                    
                    for (IPortion port : para.getPortions()) {
                        String originText = port.getText();
                        String newText = translateText(originTexmakes); // method make a new text
                        port.setText(newText); // replace with new text
                    }
                }
            }
        }
        pres.save(URL + "/new_" + fileName, SaveFormat.Pptx);
    }

我从博客上读到的:https://blog.aspose.com/slides/find-and-replace-text-in-powerpoint-using-java/#API-to-Find-and-Replace-Text-in-PowerPoint

替换新文本后,如何保留旧文本的所有样式?

我用了aspose-slides-21.7

谢谢,

【问题讨论】:

    标签: java powerpoint aspose aspose-slides


    【解决方案1】:

    您可以在Aspose.Slides forum 上发布问题,提供示例演示并获得帮助。我在 Aspose 担任支持开发人员。

    【讨论】:

      猜你喜欢
      • 2011-08-20
      • 1970-01-01
      • 1970-01-01
      • 2011-11-24
      • 2021-10-25
      • 2020-08-23
      • 2014-12-30
      • 1970-01-01
      • 2014-07-05
      相关资源
      最近更新 更多