Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from Byaidu:main #30

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,14 @@ pdf2zh example.pdf -t 1

<h2 id="todo">TODO</h2>

- [ ] Parse layout with [PaddleX (17 cls)](https://github.com/PaddlePaddle/PaddleX/blob/17cc27ac3842e7880ca4aad92358d3ef8555429a/paddlex/repo_apis/PaddleDetection_api/object_det/official_categories.py#L81), [PaperMage (27 cls)](https://github.com/allenai/papermage/blob/9cd4bb48cbedab45d0f7a455711438f1632abebe/README.md?plain=1#L102), [SAM2](https://github.com/facebookresearch/sam2)
- [ ] Parse layout with [PaddleX](https://github.com/PaddlePaddle/PaddleX/blob/17cc27ac3842e7880ca4aad92358d3ef8555429a/paddlex/repo_apis/PaddleDetection_api/object_det/official_categories.py#L81), [PaperMage](https://github.com/allenai/papermage/blob/9cd4bb48cbedab45d0f7a455711438f1632abebe/README.md?plain=1#L102), [SAM2](https://github.com/facebookresearch/sam2)

- [ ] Fix page rotation, table of contents, format of list

- [ ] Fix pixel formula in old paper

- [ ] Support multiple language with [Noto Font](https://fonts.google.com/noto), [Ubuntu Font](https://design.ubuntu.com/font)

<h2 id="acknowledgement">Acknowledgements</h2>

- Document merging: [PyMuPDF](https://github.com/pymupdf/PyMuPDF)
Expand Down
4 changes: 2 additions & 2 deletions pdf2zh/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,10 @@ def vflag(font, char): # 匹配公式(和角标)字体
pstk[-1][5] = child.font
sstk[-1] += child.get_text()
else: # 公式入栈
if ( # 根据公式右侧的文字修正公式的纵向偏移
if ( # 根据公式左侧的文字修正公式的纵向偏移
not vstk # 1. 当前字符是公式的第一个字符
and cls == xt_cls # 2. 当前字符与前一个字符属于同一段落
and child.x0 > xt.x0 # 3. 当前字符在前一个字符右侧
and child.x0 > xt.x0 # 3. 前一个字符在公式左侧
):
vfix = child.y0 - xt.y0
vstk.append(child)
Expand Down