python - SimpleIDML 如何将 IDML 转换为 PDF?

标签 python pdf-generation indesign-server idml

我是 INDD CC 服务器的新手。我已经实现了 Indesign serverWindows 上运行。我需要将 IDML 转换为 PDF 但遇到问题。

我用过SimpleIDML Python library to manipulate Adobe(r) IDML(r) files.

我的示例脚本是 I2P.py

from simple_idml.indesign import indesign


idml_file = "/home/user/Project/EPS/media/test/2-idml/test001.idml"
indd_file = "/home/user/Project/EPS/media/test/InDesigndocument/test001.indd"
url_path = "http://192.168.1.1:12345/"
client_dir = "/home/user/Project/EPS/media/source"
server_dir = "/home/user/Project/EPS/media/server"

response = indesign.save_as(indd_file, [{
                                "fmt": "pdf",
                                "params": {"colorSpace": "CMYK"},
                            }],
                            url_path,
                            client_dir,
                            server_dir)[0]
with open("my_file.pdf", "w+") as f:
    f.write(response)

在文档中:

response = indesign.save_as("/path_to_file.indd", [{
                                "fmt": "pdf",
                                "params": {"colorSpace": "CMYK"},
                            }],
                            "http://url-to-indesign-server:port",
                            "/path/to/client/workdir",
                            "/path/to/indesign-server/workdir")[0]

当我运行 I2P 脚本时抛出错误:

Traceback (most recent call last):
  File "ItoP.py", line 12, in <module>
    server_path)[0]
  File "/home/user/eps2_env/local/lib/python2.7/site-packages/simple_idml/indesign/indesign.py", line 71, in new_func
    logger, logger_extra)
  File "/home/user/eps2_env/local/lib/python2.7/site-packages/simple_idml/indesign/indesign.py", line 180, in save_as
    responses = map(lambda fmt: _save_as(fmt), dst_formats_params)
  File "/home/user/eps2_env/local/lib/python2.7/site-packages/simple_idml/indesign/indesign.py", line 180, in <lambda>
    responses = map(lambda fmt: _save_as(fmt), dst_formats_params)
  File "/home/user/eps2_env/local/lib/python2.7/site-packages/simple_idml/indesign/indesign.py", line 149, in _save_as
    response = cl.service.RunScript(params)
  File "/home/user/eps2_env/local/lib/python2.7/site-packages/suds/client.py", line 542, in __call__
    return client.invoke(args, kwargs)
  File "/home/user/eps2_env/local/lib/python2.7/site-packages/suds/client.py", line 602, in invoke
    result = self.send(soapenv)
  File "/home/user/eps2_env/local/lib/python2.7/site-packages/suds/client.py", line 649, in send
    result = self.failed(binding, e)
  File "/home/user/eps2_env/local/lib/python2.7/site-packages/suds/client.py", line 702, in failed
    r, p = binding.get_fault(reply)
  File "/home/user/eps2_env/local/lib/python2.7/site-packages/suds/bindings/binding.py", line 265, in get_fault
    raise WebFault(p, faultroot)
suds.WebFault: Server raised fault: 'The specified script file can not be found: /home/user/Project/EPS/media/server/tmp9LVUWj/save_as.jsx' 

手动我可以在服务器目录中看到动态创建的目录tmp9LVUWj。服务器路径预计在同一时间。

无法弄清楚如何在代码中设置 indesign-server/workdir 和 access 以及如何解决?我在这上面花了很多时间,但找不到帮助或示例代码。

或者是否有其他 python 包可以将 IDML 转换为 PDF。

提前致谢

最佳答案

你写的,

Manually I can see dynamically created dir tmp9LVUWj inside server dir.

没错,但这不是错误。它声明在该目录中 找不到名为 save_as.jsx 的 JSX 文件。这实际上是您打算放置在那里的 JSX 文件的名称,还是现在驻留在那里的文件的名称?

关于python - SimpleIDML 如何将 IDML 转换为 PDF?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37479362/

相关文章:

ruby-on-rails - Rails 2 -- 基于服务器操作系统将参数传递给 wicked_pdf

python - 在 python 中计算 numpy 的欧氏距离

hyperlink - wkhtmltopdf 内部链接

python - Tensorflow 重新训练.py tensorflow.python.framework.errors_impl.FailedPreconditionError

php - 使用 pdftk 在 PHP 中批量生成基于模板的 pdf

c# - 通过 COM 使用 C# 进行 InDesign Server 开发

java - 采用 C# 或 Java 的 Adob​​e In-Design

javascript - 在 InDesign 中旋转元素的值

python - 如何使用 autouse 全局定义补丁?

python - 如何在每次系统启动时使用 crontab 正确运行 Python 脚本