上下文
例如
outputStream = open("destination.pdf", "wb")
key = '/Annots'
uri = '/URI'
ank = '/A'
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
cwd = os.getcwd()
for x in range(existing_pdf.getNumPages()):
page = existing_pdf.getPage(x)
page_object = page.getObject()
if key in page_object:
ann = page_object[key]
for a in ann:
u = a.getObject()
if uri in u[ank]:
test = u[ank][uri]
test1 = u[ank].keys()
u[TextStringObject(ank)][TextStringObject(uri)] = TextStringObject(f"file:./foo1.pdf")
output.addPage(page)
# finally, write "output" to a real file
output.write(outputStream)
outputStream.close()
上述内容不起作用,即foo1.pdf未正确链接。 如果我添加“file://{CWD}/foo1.pdf”,它会工作。 有没有办法只使用相对路径?
在阅读了pdf结构和文档之后,我能够写下以下内容,并且它按照预期工作
相关问题 更多 >
编程相关推荐