首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Python中的Adobe Acrobat API

Python中的Adobe Acrobat API
EN

Stack Overflow用户
提问于 2018-07-26 10:51:53
回答 1查看 9.5K关注 0票数 5

系统:

代码语言:javascript
复制
Python 3.6
Windows 10

目标:

使用Adobe Acrobat API使用“另存为”功能将pdf保存为jpeg格式。

注意:就我的目的而言,我不能使用Wand或其他软件包。

资源:

Adobe_API_Documentation

Implementation_Example 1

Error_Handling_Issue

VBA_Example

当前代码:

代码语言:javascript
复制
import winerror
import win32com
from win32com.client.dynamic import Dispatch, ERRORS_BAD_CONTEXT

ERRORS_BAD_CONTEXT.append(winerror.E_NOTIMPL)

my_dir = r"path\\to\\example\\"
my_pdf = "example.pdf"

os.chdir(my_dir)
src = os.path.abspath(my_pdf)

pdDoc = Dispatch("AcroExch.PDDoc")
pdDoc.Open(src)

jsObject = pdDoc.GetJSObject()

jsObject.SaveAs(os.path.abspath('./output_example.jpeg'), "com.adobe.acrobat.jpeg")

问题:

jsObject为空

导致以下回溯:

代码语言:javascript
复制
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-26-9c82c454eb2a> in <module>()
----> 1 jsObject.SaveAs(os.path.abspath('./output_example.jpeg'), "com.adobe.acrobat.jpeg")

AttributeError: 'NoneType' object has no attribute 'SaveAs'

错误文档说明:

代码语言:javascript
复制
GetJSObject
Gets a dual interface to the JavaScript object associated with the PDDoc. This allows automation clients full access to both built-in and user-defined JavaScript methods available in the document. For more information on working with JavaScript, see Developing Applications Using Interapplication Communication.

Syntax
LDispatch* GetJSObject();

Returns
The interface to the JavaScript object if the call succeeded, NULL otherwise.
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51530305

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档