pdf实际裁剪

编程入门 行业动态 更新时间:2024-10-28 15:23:04
本文介绍了pdf实际裁剪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要使用linux shell裁剪pdf文档,然后提取该裁剪的pdf中的文本.

I need to crop a pdf document using the linux shell and then extract the text just in that cropped pdf.

我的想法是使用pdfcrop linux工具裁剪pdf,然后使用txt2pdf文本提取器工具提取裁剪区域中的文本,但是我意识到我正在考虑图像,并且当我尝试这样做的结果与对原始pdf而非未经裁剪的pdf的结果相同.

My idea was to crop a pdf using pdfcrop linux tool and then use a txt2pdf text extractor tool to extract the text just in the cropped area, but i've realized that i'm thinking on images, and when i try to do this the result is the same than doing it over the original, not cropped, pdf.

我想这是一个分层问题.由于pdf格式适用于图层,因此如果我不裁剪"所有图层,结果将包括我不想要的所有图层的所有信息.

I guess it's a layer problem. As the pdf format works with layers, if i don't "crop" all the layers, the result is gonna include all the information from all the layers, which i don't want.

如果有人对我如何在pdf中进行真正的所有图层裁剪"有所了解,我将非常感激.如果可能,或者我应该开始考虑其他解决方案.

I would appreciate so much if someone has any idea of how i could do a real "all layers cropping" in a pdf. If its possible or if i should start thinking on another solution.

TY

推荐答案

它不是分层的,它的事实是,裁剪PDF通常只需要简单地设置CropBox,而不会更改PDF的实际内容(除了CropBox).大多数文本提取代码将忽略CropBox并提取所有文本....

Its not layers, its the fact that cropping a PDF usually involves simply setting the CropBox, which doesn't alter the actual contents of the PDF (other than the CropBox) at all. Most text extraction code will ignore the CropBox and extract all the text....

您可以稍作努力,使用Ghostscript生成真正裁剪的PDF(尽管请注意,部分裁剪的字形仍将包括在内),然后从中提取文本.但这很丑.

You could, with some effort, use Ghostscript to produce a genuinely cropped PDF (though note that partially cropped glyphs will still be included) and then extract the text from that. But that's pretty ugly.

或者,Ghostscript和MuPDF都可以提取带有坐标信息的文本,这可能足以满足您的需求.

Alternatively Ghostscript and MuPDF can both extract text with co-ordinate information, which may be enough for your needs.

更多推荐

pdf实际裁剪

本文发布于:2023-10-30 00:10:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1541177.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:pdf

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!