dsofile 页数错误

发布于 2024-09-24 09:17:22 字数 625 浏览 0 评论 0原文

我正在使用 dsofile.dll 从 Word 文档获取页数,此时我需要的只是页数,并且此时仅需要 Word 文档。

对于某些文档,页数返回为 0(或者通常可能无效?),因此我需要一个解决方案或不同的方法。

文字自动化是最后的手段,因为它被认为是不安全的,否则会使服务器过载。

有什么想法吗?

代码:

<%
dim dso : Set dso = Server.createObject("DSOFile.OleDocumentProperties")
dso.open(wordFilePath)
response.write dso.summaryProperties.pageCount
dso.close()
set dso = nothing
%>

编辑1:仍然没有进展,尝试文字自动化遇到了很多问题,可以在此处看到:Server Word 自动化权限(一些答案和一些问题),非常欢迎回答:)

I am using dsofile.dll to get pagecount from word documents, all I need at this point is pagecount and only Word documents at this time.

For some documents the pagecount returns as 0 (or invalid in general maybe?) and therefore I'm in need of a solution or a different approach.

Word automation is a last resort as it is considered unsafe and will otherwise overload the server.

Any ideas ?

CODE:

<%
dim dso : Set dso = Server.createObject("DSOFile.OleDocumentProperties")
dso.open(wordFilePath)
response.write dso.summaryProperties.pageCount
dso.close()
set dso = nothing
%>

EDIT1: Still no progress, trying word automation came up with loads of problems which can be seen here: Server Word automation permissions (some answers and some questions), answers are most welcome :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一口甜 2024-10-01 09:17:22

我相信这将取决于在保存文档之前是否对其进行了分页。如果文档已关闭自动分页,我认为 PAGES 元数据属性 get 未设置(以及其他几个文档属性),我猜测,这就是 dsofile.dll 库用于检索页数的内容。简而言之,这不太可靠。我知道准确获取页数的唯一方法是在 Word 中加载文档,强制分页,然后读取页面属性。

I believe that's going to depend on whether pagination has been performed for the doc before it was saved. If the doc has autopaginate turned off, I don't think the PAGES metadata property get's set (along with several other doc properties), which is, I'm guessing, what that dsofile.dll library is using to retrieve the page count. In short, that's not terribly reliable. About the only way I know to accurately get a page count is load the doc in word, force pagination, and then read the pages property.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文