2015年3月8日

使用 Groovy + PDFBox 移除 PDF 多餘文字

Groovy Script 利用 Java 豐富的 Library 自製 command-line 工具超簡單,這篇以 Apache PDFBox 為例,示範 Groovy 如何利用約 50 行左右簡短程式碼,做到客製化的 PDF 維護工具,用來將 PDF 檔案中礙眼的文字移除 : )

下載 pdftrim 原始碼:

https://gist.github.com/lyhcode/79cad1a5cef2697ba749

使用方法類似 shell script,使用範例:

  • chmod a+x pdftrim
  • ./pdftrim source.pdf target.pdf

這個不知從哪來的 PDF 檔案作為範例,原始文件中右上方的藍色文字很礙眼,準備踢掉⋯
噹噹噹,經過 pdftrim 踢掉後,乾淨許多 : )

學習 Groovy 請參考 CodeData | Groovy 系列技術文章

也歡迎加入 Groovy Taiwan 粉絲專頁



1 則留言:

  1. Merit Casino | The Best and Top Software in the World
    Merit is a Swedish gambling company based in Stockholm. It 메리트카지노 was founded in 우리카지노 쿠폰 2015 and has betway login over 1,000 registered customers. The company is based in Stockholm

    回覆刪除

lyhcode by lyhcode
歡迎轉載,請務必註明出處!