Skip to content

Commit

Permalink
修复签章解析导致的异常
Browse files Browse the repository at this point in the history
  • Loading branch information
renoyuan committed Jul 18, 2024
1 parent 299d1f1 commit 1139ef4
Show file tree
Hide file tree
Showing 81 changed files with 15 additions and 627 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ https://github.com/renoyuan/easyofd/wiki/FAQ

2 gui 工具 ,之前提供过一个开箱即用的gui工具 v0.1.0.1版本后就没有更新过了,有时间会更新下。

3 功能上 对于pfd2ofd 和 ofd 生成 可能会
3 功能上 对于pfd2ofd 和 ofd 生成 可能会有一些优化

4 需求收集,若有其他相关easyofd 的需求和建议可以git 上给我提,有意思的需求我会考虑尝试。

Expand Down
2 changes: 1 addition & 1 deletion easyofd/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .ofd import OFD
__version__ = "0.3.1"
__version__ = "0.3.2"
__all__ = ["OFD"]
4 changes: 2 additions & 2 deletions easyofd/draw/draw_ofd.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def build_content_res(self, pil_img_list=None, pdf_info_list=None, id_obj: CurId
if pil_img_list:
for idx, pil_img in enumerate(pil_img_list):
# print(pil_img)
print(idx, pil_img[1], pil_img[2])
# print(idx, pil_img[1], pil_img[2])
PhysicalBox = f"0 0 {pil_img[1]} {pil_img[2]}"
ImageObject = [{
"@ID": 0,
Expand All @@ -126,7 +126,7 @@ def build_content_res(self, pil_img_list=None, pdf_info_list=None, id_obj: CurId
conten = ContentTemplate(PhysicalBox=PhysicalBox, ImageObject=ImageObject,

CGTransform=[],PathObject=[],TextObject=[], id_obj=id_obj)
print(conten)
# print(conten)
content_res_list.append(conten)
elif pdf_info_list: # 写入读取后的pdf 结果 # todo 图片id 需要关联得提前定义或者有其他方式反向对齐

Expand Down
14 changes: 9 additions & 5 deletions easyofd/parser_ofd/ofd_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,18 @@ def img2data(self,imglist):
# 获得xml 对象
def get_xml_obj(self, label):
assert label
# print(self.file_tree.keys())
for abs_p in self.file_tree:
# 统一符号,避免win linux 路径冲突

abs_p_compare = abs_p.replace("\\","-").replace("/","-")
label_compare = label.replace("\\","-").replace("/","-")
abs_p_compare = abs_p.replace("\\\\","-").replace("//","-").replace("\\","-").replace("/","-")
label_compare = label.replace("\\\\","-").replace("//","-").replace("\\","-").replace("/","-")
if label_compare in abs_p_compare:
# logger.info(f"{label} {abs_p}")
return self.file_tree[abs_p]
logger.info("ofd file path is not")
return ""


def jb22png(self, img_d:dict):
"""
Expand Down Expand Up @@ -238,16 +242,16 @@ def parser(self, ):
prefix = BaseLoc.split("/")[0]
signatures_info = SignatureFileParser(signature_xml_obj)(prefix=prefix)
# print(signatures_info)

print("signatures_info",signatures_info)
PageRef = signatures_info.get("PageRef")
Boundary = signatures_info.get("Boundary")
SignedValue = signatures_info.get("SignedValue")
sing_page_no = page_id_map.get(PageRef)
# print("self.file_tree",self.file_tree.keys)
# print(page_id_map,PageRef)
# print(SignedValue, self.get_xml_obj(SignedValue))
with open("b64.txt","w") as f:
f.write(self.get_xml_obj(SignedValue))
# with open("b64.txt","w") as f:
# f.write(self.get_xml_obj(SignedValue))
if signatures_page_id.get(sing_page_no):
signatures_page_id[sing_page_no].append(
{
Expand Down
4 changes: 2 additions & 2 deletions test/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def test_pdf2(file_path):


if __name__ == "__main__":
file_path = r"1111.ofd"
file_path = r"E:\download\MyPython\ceshi.pdf"
file_path = r"1.ofd"
# file_path = r"E:\download\MyPython\ceshi.pdf"
if sys.argv[1] =="ofd2":
test_ofd2(file_path)
elif sys.argv[1] =="pdf2":
Expand Down
49 changes: 0 additions & 49 deletions test/test/Doc_0/Document.xml

This file was deleted.

149 changes: 0 additions & 149 deletions test/test/Doc_0/DocumentRes.xml

This file was deleted.

11 changes: 0 additions & 11 deletions test/test/Doc_0/Pages/Page_0/Content.xml

This file was deleted.

11 changes: 0 additions & 11 deletions test/test/Doc_0/Pages/Page_1/Content.xml

This file was deleted.

11 changes: 0 additions & 11 deletions test/test/Doc_0/Pages/Page_10/Content.xml

This file was deleted.

11 changes: 0 additions & 11 deletions test/test/Doc_0/Pages/Page_11/Content.xml

This file was deleted.

11 changes: 0 additions & 11 deletions test/test/Doc_0/Pages/Page_12/Content.xml

This file was deleted.

11 changes: 0 additions & 11 deletions test/test/Doc_0/Pages/Page_13/Content.xml

This file was deleted.

11 changes: 0 additions & 11 deletions test/test/Doc_0/Pages/Page_14/Content.xml

This file was deleted.

11 changes: 0 additions & 11 deletions test/test/Doc_0/Pages/Page_15/Content.xml

This file was deleted.

Loading

0 comments on commit 1139ef4

Please sign in to comment.