Skip to content

Commit

Permalink
Adjust structure
Browse files Browse the repository at this point in the history
  • Loading branch information
hwding committed Aug 25, 2017
1 parent 7213e9d commit 6ab6df4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ We strongly recommend this for your convenience.
```
# For single file processing
➜ unstamp -i "C Recipes.pdf" -o "C Recipes.unstamped.pdf" -k www.allitebooks.com
➜ unstamp -i "RoR.pdf" -o "RoR.unstamped.pdf" -k 图灵社区会员
➜ unstamp -i RoR.pdf -o RoR.unstamped.pdf -k 图灵社区会员
# Or
➜ unstamp -i "C Recipes.pdf" -d -k www.allitebooks.com
➜ unstamp -i "RoR.pdf" -d -k 图灵社区会员
➜ unstamp -i RoR.pdf -d -k 图灵社区会员
# For massive files processing
➜ unstamp -I pdfs/ -O unstampedPdfs/ -r -k www.allitebooks.com
➜ unstamp -I pdfs/ -O unstampedPdfs/ -r -k 图灵社区会员 www.allitebooks.com
# Or
➜ unstamp -I pdfs/ -d -r -k www.allitebooks.com
➜ unstamp -I pdfs/ -d -r -k 图灵社区会员 www.allitebooks.com
```

### As a JAR
Expand All @@ -65,28 +65,28 @@ Get the JAR in [releases](https://github.com/hwding/pdf-unstamper/releases).
```
# For single file processing
➜ java -jar pdf-unstamper.jar -i "C Recipes.pdf" -o "C Recipes.unstamped.pdf" -k www.allitebooks.com
➜ java -jar pdf-unstamper.jar -i "RoR.pdf" -o "RoR.unstamped.pdf" -k 图灵社区会员
➜ java -jar pdf-unstamper.jar -i RoR.pdf -o RoR.unstamped.pdf -k 图灵社区会员
# Or
➜ java -jar pdf-unstamper.jar -i "C Recipes.pdf" -d -k www.allitebooks.com
➜ java -jar pdf-unstamper.jar -i "RoR.pdf" -d -k 图灵社区会员
➜ java -jar pdf-unstamper.jar -i RoR.pdf -d -k 图灵社区会员
# For massive files processing
➜ java -jar pdf-unstamper.jar -I pdfs/ -O unstampedPdfs/ -r -k www.allitebooks.com
➜ java -jar pdf-unstamper.jar -I pdfs/ -O unstampedPdfs/ -r -k 图灵社区会员 www.allitebooks.com
# Or
➜ java -jar pdf-unstamper.jar -I pdfs/ -d -r -k www.allitebooks.com
➜ java -jar pdf-unstamper.jar -I pdfs/ -d -r -k 图灵社区会员 www.allitebooks.com
```
## Structure
```
unstamper
src/com/amastigote/unstamper
├── core
│   └── Processor.java
│   ├── Processor.java
│   └── TextStampRecognizer.java
├── io
│   └── IOHandler.java
├── log
│   └── GeneralLogger.java
├── Main.java
└── util
├── OptionManager.java
├── TaskRunner.java
└── TextStampUtil.java
└── TaskRunner.java
```
3 changes: 1 addition & 2 deletions src/com/amastigote/unstamper/core/Processor.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package com.amastigote.unstamper.core;

import com.amastigote.unstamper.log.GeneralLogger;
import com.amastigote.unstamper.util.TextStampUtil;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.cos.COSString;
import org.apache.pdfbox.pdfparser.PDFStreamParser;
Expand Down Expand Up @@ -54,7 +53,7 @@ public static void process(File file, String[] strings) {
/* END */
for (Object o : objects) {
if (o instanceof COSString) {
if (TextStampUtil.recognize(strings, ((COSString) o).getBytes(), pdFonts))
if (TextStampRecognizer.recognize(strings, ((COSString) o).getBytes(), pdFonts))
((COSString) o).setValue(new byte[0]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
MAIL | m@amastigote.com
GITH | github.com/hwding
*/
package com.amastigote.unstamper.util;
package com.amastigote.unstamper.core;

import org.apache.pdfbox.pdmodel.font.PDFont;

import java.io.IOException;
import java.util.Set;

public class TextStampUtil {
class TextStampRecognizer {

private static boolean recognizeWithFont(
String[] keywords,
Expand Down Expand Up @@ -43,9 +43,9 @@ private static boolean recognizePlain(
return false;
}

public static boolean recognize(String[] keywords,
byte[] inputText,
Set<PDFont> pdFonts) {
static boolean recognize(String[] keywords,
byte[] inputText,
Set<PDFont> pdFonts) {
return recognizePlain(keywords, inputText) ||
recognizeWithFont(keywords, inputText, pdFonts);
}
Expand Down

0 comments on commit 6ab6df4

Please sign in to comment.