返回排行榜

JonathanLink/PDFLayoutTextStripper

Javajonathanlink.ch/PDFLayoutTextStripper.html

Converts a pdf file into a text file while keeping the layout of the original pdf. Useful to extract the content from a table in a pdf file for instance. This is a subclass of PDFTextStripper class (from the Apache PDFBox library).

layouttextjavapdfextractdata-extractionpdfbox
Star 增长趋势
Star
1.6k
Forks
213
周增长
Issues
19
5001k1.5k
2015年12月2019年6月2023年1月2026年7月
制品库Mavengit clone https://github.com/JonathanLink/PDFLayoutTextStripper.git
README

PDFLayoutTextStripper

Converts a PDF file into a text file while keeping the layout of the original PDF. Useful to extract the content from a table or a form in a PDF file. PDFLayoutTextStripper is a subclass of PDFTextStripper class (from the Apache PDFBox library).

Use cases

Data extraction from a table in a PDF file example

Data extraction from a form in a PDF file example

How to install

Maven

<dependency>
  <groupId>io.github.jonathanlink</groupId>
  <artifactId>PDFLayoutTextStripper</artifactId>
  <version>2.2.3</version>
</dependency>

Manual

  1. Install apache pdfbox manually (to get the v2.0.6 click here ) and its two dependencies commons-logging.jar and fontbox

warning: only pdfbox versions from version 2.0.0 upwards are compatible with this version of PDFLayoutTextStripper.java

How to use on Linux/Mac

cd PDFLayoutTextStripper
javac -cp .:/pathto/pdfbox-2.0.6.jar:/pathto/commons-logging-1.2.jar:/pathto/PDFLayoutTextStripper/fontbox-2.0.6.jar *.java
java -cp .:/pathto/pdfbox-2.0.6.jar:/pathto/commons-logging-1.2.jar:/pathto/PDFLayoutTextStripper/fontbox-2.0.6.jar test

How to use on Windows

The same as for Linux (see above) but replace : with ;

Sample code

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.pdfbox.io.RandomAccessFile;
import org.apache.pdfbox.pdfparser.PDFParser;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;

public class test {
	public static void main(String[] args) {
		String string = null;
        try {
            PDFParser pdfParser = new PDFParser(new RandomAccessFile(new File("./samples/bus.pdf"), "r"));
            pdfParser.parse();
            PDDocument pdDocument = new PDDocument(pdfParser.getDocument());
            PDFTextStripper pdfTextStripper = new PDFLayoutTextStripper();
            string = pdfTextStripper.getText(pdDocument);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        };
        System.out.println(string);
	}
}

Contributors

Thanks to

  • Dmytro Zelinskyy for reporting an issue with its correction (v2.2.3)
  • Ho Ting Cheng for reporting an issue (v2.1)
  • James Sullivan for having updated the code to make it work with the latest version of PDFBox (v2.0)
相关仓库
HeroTransitions/Hero

Elegant transition library for iOS & tvOS

SwiftMIT Licenseanimationcustom-transitions
herotransitions.github.io/Hero/
22.5k1.7k
SnapKit/SnapKit

A Swift Autolayout DSL for iOS & OS X

SwiftMIT Licenseautoautolayout
snapkit.github.io/SnapKit/
20.3k2k
nicbarker/clay

High performance UI layout library in C.

Czlib Licenselayoutui
nicbarker.com/clay
17.7k691
charmbracelet/lipgloss

Style definitions for nice terminal layouts 👄

GoGo ModulesMIT Licensetuigo
11.6k380
haltu/muuri

Infinite responsive, sortable, filterable and draggable layouts

JavaScriptnpmMIT Licensegridlayout
muuri.dev
10.9k650
alibaba/vlayout

Project vlayout is a powerfull LayoutManager extension for RecyclerView, it provides a group of layouts for RecyclerView. Make it able to handle a complicate situation when grid, list and other layouts in the same recyclerview.

JavaMavenMIT Licenseandroidrecyclerview-multi-type
tangram.pingguohe.net
10.7k1.8k
NorthwoodsSoftware/GoJS

JavaScript diagramming library for interactive flowcharts, org charts, design tools, planning tools, visual languages.

HTMLOtherhtmldiagram
gojs.net
8.5k2.8k
ColorfulCat/AndroidLibs

:fire:正在成为史上最全分类 Android 开源大全~~~~(长期更新 Star 一下吧)

Apache License 2.0androidlibrary
xcube.cn
8k1.6k
rebassjs/rebass

:atom_symbol: React primitive UI components built with styled-system.

JavaScriptnpmMIT Licensejavascriptreact
rebassjs.org
7.9k634
styled-system/styled-system

⬢ Style props for rapid UI development

JavaScriptnpmMIT Licensereactcss-in-js
styled-system.com
7.9k495
golden-layout/golden-layout

A multi window layout manager for webapps

JavaScriptnpmMIT Licensegolden-layoutjavascript
golden-layout.github.io/golden-layout
6.7k561
zerostaticthemes/square-ui

Collection of beautifully crafted open-source layouts UI built with shadcn/ui.

TypeScriptnpmOtherlayoutshadcn-ui
square.lndev.me
6k664