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

原文档内容和翻译结果重叠,是否存在屏蔽原文档内容选项 #446

Open
tomatolike-self opened this issue Jan 9, 2025 · 12 comments
Assignees
Labels
enhancement New feature or request Low priority

Comments

@tomatolike-self
Copy link

问题描述

我在使用 pdf2zh 时遇到了一些问题:

  • 设备信息: Mac M1
  • Python 版本: Python 3.12.7
  • pdf2zh 版本: pdf2zh v1.8.8
image

翻译文档时出现了 原文档内容和翻译结果重叠 的现象,导致阅读体验较差

是否存在类似 pdf2zh example.pdf -f xxx 的功能,能够将翻译页面中的原文档内容屏蔽,单纯只保留翻译结果?

测试文档

Chankin - jou.roalof ggcloar materials.pdf

@tomatolike-self
Copy link
Author

#444 中提到新版本已经有这一功能了,等新版发布吧

@hellofinch
Copy link
Contributor

你这个是扫描件,需要OCR,暂时处理不了。
#19
: )

@tomatolike-self
Copy link
Author

好吧,但是我看翻译页面其实是有翻译后结果的,而且原文档是支持选中文字的。
image
我想的是能不能存在一个选项,能够在翻译页面关闭原文档的图像画面,以免重叠
之前提到的 #444 中说下版本会出现一个新的关闭选项,所以之前关掉了这个issue,但今天看似乎和我这里不是一个需求?

@tomatolike-self
Copy link
Author

另外翻译页面中pdf的文字层其实已经是中文翻译结果了
image
原文档的内容似乎是直接作为背景图给贴上去了?

@hellofinch
Copy link
Contributor

这个PDF是个扫描件,你能复制不是PDF本身能复制,是你的阅读器让你能复制。
原始的内容不是我们不想去,是它去不了。
所以,等OCR功能吧。
: )

@awwaawwa
Copy link
Collaborator

@hellofinch 其实我们应该是能去掉这个图片内容的hhhhhhh

等我把手上事情做一做之后来看一看这个需求,请耐心等待,感谢。

@hellofinch
Copy link
Contributor

我之前试着删过,没删掉。。。。

@awwaawwa
Copy link
Collaborator

这是我在新后端上移除ops_base后的测试效果。ps 空白区域有字,只是由于bug显示为空白。
CleanShot 2025-01-12 at 03 03 54@2x

@Byaidu Byaidu added the enhancement New feature or request label Jan 19, 2025
@liuyun16
Copy link

liuyun16 commented Feb 12, 2025

C. Campbell et al_Surface Science Reports_1997 _Ultrathin metal films and particles on oxide surfaces structural, electronic and chemisorptive prop-mono.pdf

@hellofinch 背景图在ops_base里。理论上把这个删了,就只剩下翻译输出的文字+公式了。 https://github.com/Byaidu/PDFMathTranslate/blob/f30133e040a85633c708ccbdc8ad9a6db75ed763/pdf2zh/pdfinterp.py#L267C1-L268C1

https://github.com/Byaidu/PDFMathTranslate/blob/f30133e040a85633c708ccbdc8ad9a6db75ed763/pdf2zh/pdfinterp.py#L273C18-L273C26

强,非常期待这个更新!我发现这是老一点的pdf文档的通病。可能年代久远的pdf文件,底层都是图像层而非文字层。我这里也发现了90年代,elsiview的文档都是这个原文图像没有删除。

我也附上了我的翻译了一页的结构,在上述pdf的第五页。可以看到重影。

@awwaawwa awwaawwa self-assigned this Feb 12, 2025
@awwaawwa
Copy link
Collaborator

@liuyun16 慢慢蹲吧,这个优先级比较低。得先做其他的。

@aik2mlj
Copy link

aik2mlj commented Feb 15, 2025

一个权宜的方法:在翻译得到文字/图像重叠的pdf后,用其他工具删除图像层。
https://chatgpt.com/share/67b11a1c-9ecc-800e-9810-fd61a1d84044

我在linux下测试了使用ghostscript,可以得到不错的结果:

gs -o output.pdf -sDEVICE=pdfwrite -dFILTERIMAGE input.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Low priority
Projects
None yet
Development

No branches or pull requests

6 participants