Aspose.Words doc转pdf 内容出现丢失,页码跳页,排版混乱问题 您所在的位置:网站首页 word转换为pdf后没有大纲了 Aspose.Words doc转pdf 内容出现丢失,页码跳页,排版混乱问题

Aspose.Words doc转pdf 内容出现丢失,页码跳页,排版混乱问题

2023-09-19 03:00| 来源: 网络整理| 查看: 265

简介: Aspose.Words 是一个商业.NET 类库,可以使得应用程序处理大量的文件任务。Aspose.Words 支持 Doc,Docx,RTF,HTML,OpenDocument,PDF,XPS,EPUB 和其他格式。使用 Aspose.Words 可以在不使用 Microsoft.Word 的情况下生成、修改、转换和打印文档。 排版错位(页码跳页): 在使用中发现 apose 对 word 文档转换 PDF 操作中会出现将单页分成两页的情况。仔细分析后发现是因为 word 文档在编辑的时候是采用的多页编辑。页面效果是单页,可是在 apose 将 word 文档转为 pdf 后就变成了两页。所以要新生成一个 word 文档并保留原 word 文档的样式,问题解决。

try { long old = System.currentTimeMillis(); File file = new File(targetFile); FileOutputStream os = new FileOutputStream(file); Document doc = new Document(sourcerFile); Document document = new Document();//新建一个空白pdf文档 document.removeAllChildren(); document.appendDocument(doc, ImportFormatMode.USE_DESTINATION_STYLES);//保留样式 document.save(os, SaveFormat.PDF);//全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, EPUB, XPS, SWF 相互转换 os.close(); long now = System.currentTimeMillis(); System.out.println("共耗时:" + ((now - old) / 1000.0) + "秒"); //转化用时 } catch (Exception e) { e.printStackTrace(); }

数据丢失: 在使用中发现 apose 对 word 文档转换 PDF 操作中会出现将页签数据丢失的情况。将问题反复重现后发现是因为 word 文档的样式无法保存。所以要新生成一个 word 文档并保留原 word 文档的样式,问题解决。

try { long old = System.currentTimeMillis(); File file = new File(targetFile); FileOutputStream os = new FileOutputStream(file); Document doc = new Document(sourcerFile); Document document = new Document();//新建一个空白pdf文档 document.removeAllChildren(); document.appendDocument(doc, ImportFormatMode.USE_DESTINATION_STYLES);//保留样式 document.save(os, SaveFormat.PDF);//全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, EPUB, XPS, SWF 相互转换 os.close(); long now = System.currentTimeMillis(); System.out.println("共耗时:" + ((now - old) / 1000.0) + "秒"); //转化用时 } catch (Exception e) { e.printStackTrace(); }


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有