超強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




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