indesign在python中是什么意思_InDesign用于搜索和代表的python脚本

我想使用python脚本来查找和替换InDesign文件中的一些文本,然后将其保存为pdf。在

我设法使用python打开indesign并将其保存为pdf,但是我不知道如何搜索文本并将其替换为脚本第一部分生成的随机字符串。在

以下是我目前所得到的:import win32com.client

import random

import string

def id_generator(size=6, chars=string.ascii_uppercase + string.digits):

return ''.join(random.choice(chars) for _ in range(size))

voucher=id_generator()

app = win32com.client.Dispatch('InDesign.Application.CC.2018')

myFile = r'C:\Users\some_file.indd'

myDocument = app.Open(myFile)

myPDFFile = r'C:\Users\some_file.pdf'

directory = os.path.dirname(myPDFFile)

idPDFType = 1952403524

# 1=[High Quality Print], 2=[PDF/X-1a:2001] etc..

myPDFPreset = app.PDFExportPresets.Item(1)

try:

if not os.path.exists(directory):

os.makedirs(directory)

if os.path.exists(directory):

myDocument.Export(idPDFType, myPDFFile, False, myPDFPreset)

except Exception as e:

print('Export to PDF failed: ' + str(e))

myDocument.Close()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值