超强pdf操作功能包pymupdf

这是一篇pymupdf实例,操作方法是pymupdf的作者jorj.x.mckie 提供的。

实例是这样的:别跟我说乱码问题,如果有是自己程序有问题,给我留言我给你回复:[email protected]

比如我要把pdf中某些区域原样(有各种图文)拷贝。

First you can use for keywords on a page via page.searchFor(“text”, …). This will give you a list of rectangles where the text can be found. Using this for several different keywords allows you to calculate a rectangle “rect” that you want to be displayed in a new document page.

首先找到关键词,定位需要拷贝的内容:也就是rect的定点参数,左上角,和右下角。

然后用showpage将内容拷贝到新的pdf文档中即可。

说实话大牛的职业态度确实赞。

 

Then, on “newpage” in you new document “newdoc”, do this: newpage.showPDFpage(newrect, doc, pno, clip= rect, …),

Where:

  • newrect is the rectangle of the new page where the stuff should appear
  • doc is the old document
  • pno is the page number of the old document*s page
  • rect is your calculated area to show




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章