# ofd2img **Repository Path**: jiamn/ofd2img ## Basic Information - **Project Name**: ofd2img - **Description**: 将ofd文档转为图片。 https://github.com/geniusnut/ofd2img 国内https://gitee.com/yuhongjiang/ofd2img比上边少些,所以从国外倒过来。 这是我这个fork的唯一站点。241115 - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-11-15 - **Last Updated**: 2024-11-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #2411191016 解决了ofd内置图片后缀是png,实际是jpg格式,导致cairo报out of memory错误。 就是2411161000那个错误。 ========================================================= #241118 解决了内置jpg图片,先转成png再按原来规则处理进surface ========================================================= #2411171927 12036 ofd v1.1版本发票 1 发票章圈是黑的 (2411181100, 但是发现早期的发票纳税人号码那里红字黑字叠加了) 2 发票底色不对 3 发票里上边和下边转圈的字体位置不对 (2411181017 基本OK,先移动再变换matrix) ================================= #2411161000 Tag: ImageObject, Attr: {'ID': '7', 'Boundary': '0 0.2399 210.0580 296.7990', 'CTM': '210.058 0 0 296.799 0 0', 'ResourceID': '8'}, Text: None Traceback (most recent call last): File "/home/iosec/ofd2img/core/document.py", line 196, in cairo_draw CAIRO_TAGS[node.tag](cr, node) File "/home/iosec/ofd2img/core/surface.py", line 315, in cairo_image img_surface = get_res_image(resource_id).get_cairo_surface() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/iosec/ofd2img/core/resources.py", line 100, in get_cairo_surface return cairo.ImageSurface.create_from_png(self.png_location) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ core.resources.cairo.MemoryError: out of memory ================================================= # 241115 create download from https://github.com/geniusnut/ofd2img.git https://gitee.com/yuhongjiang/ofd2img 有点旧 base: deepin 23 && python 3.12.4 openeuler 24.03LTS && python 3.11.6 初步目标: 1 尝试解决12306 SignedValue.dat, DocType="OFD" Version="1.1"? 2 解析文件时生成的临时文件夹结束时自动删除(done: 2411160927, ofd2img1.py) 3 指定目录生成。(done: 2411161012, ofd2img1.py) 4 最大利用本机上安装的字库。 ============================================== # ofd2img ## Prerequisite 1. Install [PyGobject](https://pygobject.readthedocs.io/en/latest/). `https://pygobject.readthedocs.io/en/latest/getting_started.html#windows-getting-started` 2. Install [Jbig2Dec](https://github.com/ArtifexSoftware/jbig2dec) 不要用brew install (brew info jbig2dec)的那个,好像只支持转出为pbm,不支持png。 自己安装下。 ```bash git clone https://github.com/ArtifexSoftware/jbig2dec cd jbig2dec ./autogen && make && make install jbig2dec -o image_80.png Doc_0/Res/image_80.jb2 ``` ## Usage 安装好对应的依赖,调用OFDFile.draw_document会生成发票的PNG图片。 ```python from core.document import OFDFile doc = OFDFile('test.ofd') doc.draw_document() # check test_Doc_0_Page_0.png under folder ``` # Need Help? 有任何问题请提Issue或者联系 **geniusnut@gmail.com**。 # Issues 发票签章位置Hardcode。