BSD 3-Clause "New" or "Revised" License

项目介绍

dotemacs/pdfboxing 是一个托管在 GitHub 上的开源项目,主要使用 Clojure 编写,采用 BSD 3-Clause "New" or "Revised" License 许可证,目前获得 187 个 Star、37 次 Fork。

仓库全名
dotemacs/pdfboxing
开源许可证
BSD 3-Clause "New" or "Revised" License
Star 数
187
Fork 数
37
未关闭 Issue
4

README 摘要

pdfboxing Clojure PDF manipulation library & wrapper for PDFBox. Usage Extract text Merge multiple PDFs Merge multiple images into single PDF You can use either merge-images-from-path for providing images in form of vector of string paths or merge-images-from-byte-array to provide them as a vector of byte arrays. Each image will be inserted into its own page. Split a PDF into mutliple PDDocuments List of PDDocument…

完整内容见 GitHub 原始 README 或本页 。

常见问题

pdfboxing 用什么语言开发?

主要使用 Clojure 编写,采用 BSD 3-Clause "New" or "Revised" License 许可证,目前有 187 个 Star。

pdfboxing 可以免费商用吗?

仓库采用 BSD 3-Clause "New" or "Revised" License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 pdfboxing 的源码?

可以直接克隆仓库:git clone https://github.com/dotemacs/pdfboxing.git,默认分支为 master;安装与运行步骤见仓库 README。

pdfboxing 最近还在维护吗?

仓库最近一次更新为 2024年12月16日,当前有 4 个未关闭 Issue;Star 数为 187,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

Nice wrapper of PDFBox in Clojure

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
266
价值分
123
活跃状态
活跃

语言占比

Clojure
HTML

README

pdfboxing

Clojure PDF manipulation library & wrapper for PDFBox.

  • "Clojure CLI"
  • "Leiningen version"
  • "Continuous Integration status"
  • License
  • Dependencies Status
  • Downloads

Usage

Extract text

(require '[pdfboxing.text :as text])
(text/extract "test/pdfs/hello.pdf")

Merge multiple PDFs

(require '[pdfboxing.merge :as pdf])
(pdf/merge-pdfs :input ["test/pdfs/clojure-1.pdf" "test/pdfs/clojure-2.pdf"] :output "foo.pdf")

Merge multiple images into single PDF

You can use either merge-images-from-path for providing images in form of vector of string paths or merge-images-from-byte-array to provide them as a vector of byte arrays. Each image will be inserted into its own page.

(require '[pdfboxing.merge :as pdf])
(pdf/merge-images-from-path ["image1.png" "image2.png"] "output.pdf")

Split a PDF into mutliple PDDocuments

 (require '[pdfboxing.split :as pdf])

List of PDDocument pages 1 through 8

 (pdf/split-pdf :input "test/pdfs/multi-page.pdf" :start 1 :end 8)

Splits the PDF into single pages as a list of PDDocument

 (pdf/split-pdf :input "test/pdfs/multi-page.pdf")

Splits the PDF in half and writes them to disk as multi-page-1.pdf and multi-page-2.pdf

 (pdf/split-pdf-at :input "test/pdfs/multi-page.pdf")

Splits into two PDFs, the first having 5 pages and second has rest

 (pdf/split-pdf-at :input "test/pdfs/multi-page.pdf" :split 5)

List form fields of a PDF

To list fields and values:

(require '[pdfboxing.form :as form])
(form/get-fields "test/pdfs/interactiveform.pdf")
{"Emergency_Phone" "", "ZIP" "", "COLLEGE NO DEGREE" "", ...}

Fill in PDF forms

To fill in form’s field supply a hash map with field names and desired values. It will create a copy of fillable.pdf as new.pdf with the fields filled in:

(require '[pdfboxing.form :as form])
(form/set-fields "test/pdfs/fillable.pdf" "test/pdfs/new.pdf" {"Text10" "My first name"})

Rename form fields of a PDF

To rename PDF form fields, supply a hash map where the keys are the current names and the values new names:

(require '[pdfboxing.form :as form])
(form/rename-fields "test/pdfs/interactiveform.pdf" "test/pdfs/addr1.pdf" {"Address_1" "NewAddr"})

Get page count of a PDF document

(require '[pdfboxing.info :as info])
(info/page-number "test/pdfs/interactiveform.pdf")

Get info about a PDF document

Such as title, author, subject, keywords, creator & producer

(require '[pdfboxing.info :as info])
(info/about-doc "test/pdfs/interactiveform.pdf")

Draw lines on a PDF document

Supply a PDF document, a name for the output PDF document, the coordinates where the line should be drawn along with the page number on which the line should be drawn

(require '[pdfboxing.draw :as draw])
(draw/draw-line :input-pdf "test/pdfs/clojure-1.pdf"
                :output-pdf "ninja.pdf"
                :coordinates {:page-number 0
                              :x 0
                              :y 160
                              :x1 650
                              :y1 160})

Convert a PDF document to a very simple HTML document

Supply a PDF document’s name, a simple HTML is created in the root folder

(require '[pdfboxing.tools :as tools])
(tools/pdf-to-html "myFile.pdf")

Compatibility with PDFBox’s PDDocuments

The following functions referenced above have direct compatibility with PDFBox’s internal PDDocument type:

  • text/extract
  • pdf/split-pdf
  • form/get-fields
  • form/set-fields
  • form/rename-fields
  • info/page-number
  • draw/draw-line

This allows you to substitute each filepath (of each function’s input) referenced above with a PDDocument type. This is helpful for example in the case that you were to want to split a PDF up by pages and then extract the text from only the 3rd page:

(require '[pdfboxing.text :as text])
(require '[pdfboxing.split :as split])
(-> (split/split-pdf :input "test/pdfs/multi-page.pdf")
    (nth 2)
    text/extract)

评论

暂无评论