Compare commits
4 Commits
38cf112230
...
72bc06e695
Author | SHA1 | Date |
---|---|---|
CocoMaster-AI | 72bc06e695 | |
CocoMaster-AI | 2cc16f3cc9 | |
CocoMaster-AI | 0c848acc0c | |
Anthony Stirling | 2fff3083ae |
|
@ -19,6 +19,16 @@ public class TextFinder extends PDFTextStripper {
|
|||
private final boolean wholeWordSearch;
|
||||
private final List<PDFText> textOccurrences = new ArrayList<>();
|
||||
|
||||
private class MatchInfo {
|
||||
int startIndex;
|
||||
int matchLength;
|
||||
|
||||
MatchInfo(int startIndex, int matchLength) {
|
||||
this.startIndex = startIndex;
|
||||
this.matchLength = matchLength;
|
||||
}
|
||||
}
|
||||
|
||||
public TextFinder(String searchText, boolean useRegex, boolean wholeWordSearch)
|
||||
throws IOException {
|
||||
this.searchText = searchText.toLowerCase();
|
||||
|
@ -27,36 +37,37 @@ public class TextFinder extends PDFTextStripper {
|
|||
setSortByPosition(true);
|
||||
}
|
||||
|
||||
private List<Integer> findOccurrencesInText(String searchText, String content) {
|
||||
List<Integer> indexes = new ArrayList<>();
|
||||
private List<MatchInfo> findOccurrencesInText(String searchText, String content) {
|
||||
List<MatchInfo> matches = new ArrayList<>();
|
||||
|
||||
Pattern pattern;
|
||||
|
||||
if (useRegex) {
|
||||
// Use regex-based search
|
||||
pattern =
|
||||
wholeWordSearch
|
||||
? Pattern.compile("(\\b|_|\\.)" + searchText + "(\\b|_|\\.)")
|
||||
? Pattern.compile("\\b" + searchText + "\\b")
|
||||
: Pattern.compile(searchText);
|
||||
} else {
|
||||
// Use normal text search
|
||||
pattern =
|
||||
wholeWordSearch
|
||||
? Pattern.compile(
|
||||
"(\\b|_|\\.)" + Pattern.quote(searchText) + "(\\b|_|\\.)")
|
||||
? Pattern.compile("\\b" + Pattern.quote(searchText) + "\\b")
|
||||
: Pattern.compile(Pattern.quote(searchText));
|
||||
}
|
||||
|
||||
Matcher matcher = pattern.matcher(content);
|
||||
while (matcher.find()) {
|
||||
indexes.add(matcher.start());
|
||||
matches.add(new MatchInfo(matcher.start(), matcher.end() - matcher.start()));
|
||||
}
|
||||
return indexes;
|
||||
return matches;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeString(String text, List<TextPosition> textPositions) {
|
||||
for (Integer index : findOccurrencesInText(searchText, text.toLowerCase())) {
|
||||
if (index + searchText.length() <= textPositions.size()) {
|
||||
for (MatchInfo match : findOccurrencesInText(searchText, text.toLowerCase())) {
|
||||
int index = match.startIndex;
|
||||
if (index + match.matchLength <= textPositions.size()) {
|
||||
// Initial values based on the first character
|
||||
TextPosition first = textPositions.get(index);
|
||||
float minX = first.getX();
|
||||
|
@ -65,7 +76,7 @@ public class TextFinder extends PDFTextStripper {
|
|||
float maxY = first.getY() + first.getHeight();
|
||||
|
||||
// Loop over the rest of the characters and adjust bounding box values
|
||||
for (int i = index; i < index + searchText.length(); i++) {
|
||||
for (int i = index; i < index + match.matchLength; i++) {
|
||||
TextPosition position = textPositions.get(i);
|
||||
minX = Math.min(minX, position.getX());
|
||||
minY = Math.min(minY, position.getY());
|
||||
|
|
|
@ -11,10 +11,10 @@ imgPrompt=画像を選択
|
|||
genericSubmit=送信
|
||||
processTimeWarning=警告:この処理はファイルサイズによって1分程度かかることがあります
|
||||
pageOrderPrompt=ページ順序 (ページ番号をカンマ区切り又は2n+1のような関数で入力):
|
||||
pageSelectionPrompt=Custom Page Selection (Enter a comma-separated list of page numbers 1,5,6 or Functions like 2n+1) :
|
||||
pageSelectionPrompt=カスタムページ選択(ページ番号1、5、6または2n + 1などの関数のコンマ区切りリストを入力します):
|
||||
goToPage=移動
|
||||
true=True
|
||||
false=False
|
||||
true=真
|
||||
false=偽
|
||||
unknown=不明
|
||||
save=保存
|
||||
saveToBrowser=ブラウザへ保存
|
||||
|
@ -63,7 +63,7 @@ deleteUsernameExistsMessage=そのユーザー名は存在しないため削除
|
|||
# Pipeline #
|
||||
###############
|
||||
pipeline.header=パイプラインメニュー (Alpha)
|
||||
pipeline.uploadButton=Upload Custom
|
||||
pipeline.uploadButton=カスタムのアップロード
|
||||
pipeline.configureButton=設定
|
||||
pipeline.defaultOption=カスタム
|
||||
pipeline.submitButton=送信
|
||||
|
@ -75,7 +75,7 @@ pipelineOptions.header=パイプライン設定
|
|||
pipelineOptions.pipelineNameLabel=パイプライン名
|
||||
pipelineOptions.saveSettings=動作設定の保存
|
||||
pipelineOptions.pipelineNamePrompt=ここにパイプライン名を入力
|
||||
pipelineOptions.selectOperation=Select Operation
|
||||
pipelineOptions.selectOperation=動作の選択
|
||||
pipelineOptions.addOperationButton=動作の追加
|
||||
pipelineOptions.pipelineHeader=パイプライン:
|
||||
pipelineOptions.saveButton=ダウンロード
|
||||
|
@ -166,7 +166,7 @@ home.desc=PDFのあらゆるニーズに対応するローカルホスティン
|
|||
home.searchBar=機能検索...
|
||||
|
||||
|
||||
home.viewPdf.title=View PDF
|
||||
home.viewPdf.title=PDFを表示
|
||||
home.viewPdf.desc=表示、注釈、テキストや画像の追加
|
||||
viewPdf.tags=view,read,annotate,text,image
|
||||
|
||||
|
@ -540,7 +540,7 @@ addPageNumbers.selectText.5=番号をつけるページ
|
|||
addPageNumbers.selectText.6=カスタムテキスト
|
||||
addPageNumbers.customTextDesc=カスタムテキスト
|
||||
addPageNumbers.numberPagesDesc=番号をつけるページ、デフォルトは'all'、 1-5 や 2,5,9 など
|
||||
addPageNumbers.customNumberDesc=デフォルトは{n}、'{n} / {total} ページ'、'テキスト-{n}'、'{filename}-{n}など
|
||||
addPageNumbers.customNumberDesc=デフォルトは{n}、'{n} / {total} ページ'、'テキスト-{n}'、'{filename}-{n}など'
|
||||
addPageNumbers.submit=ページ番号の追加
|
||||
|
||||
|
||||
|
@ -763,8 +763,8 @@ multiTool.title=PDFマルチツール
|
|||
multiTool.header=PDFマルチツール
|
||||
|
||||
#view pdf
|
||||
viewPdf.title=View PDF
|
||||
viewPdf.header=View PDF
|
||||
viewPdf.title=PDFを表示
|
||||
viewPdf.header=PDFを表示
|
||||
|
||||
#pageRemover
|
||||
pageRemover.title=ページ削除
|
||||
|
|
Loading…
Reference in New Issue