renoyuan / easyofd

use python parse OFD file: finished ofd2img ofd2pdf pdf2ofd img2ofd ;(纯 python的ofd解析与pdf转换)
Apache License 2.0
168 stars 25 forks source link

ofd(包含的是图片)转pdf,生成的格式不对,无法打开 #7

Closed ydh10002023 closed 6 months ago

ydh10002023 commented 6 months ago
input = "1.ofd"
output = "new_1.pdf"
with open(input, "rb") as f:
    ofdb64 = str(base64.b64encode(f.read()), "utf-8")
ofd = OFD()
ofd.read(ofdb64)
pdf_bytes = ofd.to_pdf()
with open(output,"wb") as f:
    f.write(pdf_bytes)
renoyuan commented 6 months ago

文件提供下?

ydh10002023 commented 6 months ago

@renoyuan 你好,这个是输入文件,谢谢 test.ofd.zip

renoyuan commented 6 months ago

看了下里面图片是 bmp 格式,已兼容。