【发布时间】:2019-03-20 13:32:12
【问题描述】:
我想将 PDF 文件作为文本(postscript)读取,在文件结构中添加新对象并将最终输出保存为新 PDF,但如果我只是复制 PDF PostScript 内容并将其粘贴到新创建的PDF 文件(其中encoding='ansi'),该文件不起作用。
我确信这可能是编码问题,但我不确定在处理原始 PostScript 内容后我应该怎么做才能获得有效的 PDF 文件格式。
这是我无法使用的一段代码:
pdf_file = open('Input.pdf', 'r', encoding='ansi').read()
pdf_file_bytes = bytearray(pdf_file, 'ansi')
pdf_file = open('Output_bytes.pdf', 'wb').write(pdf_file_bytes)
正如我所说,输出的 PDF 无效!
【问题讨论】:
-
这看起来很像this question...
标签: pdf ansi pdf-manipulation