【问题标题】:How to read word each page?如何阅读每页的单词?
【发布时间】:2023-03-31 12:34:01
【问题描述】:

我知道 doc.Save() 函数将所有页面保存在一个 HTML 文件中。 doc.RenderToScale() 函数将每个页面保存到独立的图像文件中。 但我想在独立的 HTML 文件中读取或保存每个页面,我不知道,你能帮帮我吗?

【问题讨论】:

    标签: aspose aspose.words


    【解决方案1】:

    您可以使用以下代码示例将每个页面转换为 HTML 或 Aspose.Words 支持的任何其他格式。

    String srcDoc = Common.DATA_DIR + "src.docx";
    String dstDoc = Common.DATA_DIR + "dst {PAGE_NO}.html";
    
    Document doc = new Document(srcDoc);
    LayoutCollector layoutCollector = new LayoutCollector(doc);
    // This will build layout model and collect necessary information.
    doc.updatePageLayout();
    
    // Split nodes in the document into separate pages.
    DocumentPageSplitter splitter = new DocumentPageSplitter(layoutCollector);
    
    // Save each page to disk as separate documents.
    for (int page = 1; page <= doc.getPageCount(); page++)
    {
        Document pageDoc = splitter.getDocumentOfPage(page);
        pageDoc.save(dstDoc.replace("{PAGE_NO}", page+""));
    }
    

    这取决于其他 3 个类,您可以在 this zip file 中找到它们。

    我与 Aspose 合作,担任开发人员宣传员。

    【讨论】:

      猜你喜欢
      • 2012-03-15
      • 2021-01-29
      • 1970-01-01
      • 2016-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多