Skip to content

Commit 3eabb80

Browse files
committed
rename method in pdf2txt
1 parent 7c4c232 commit 3eabb80

File tree

5 files changed

+22
-20
lines changed

5 files changed

+22
-20
lines changed

BasicCAT/BasicCAT.b4j

-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ Sub Process_Globals
302302
Type Item (UserField As String, KeyField As String, ValueField() As Byte, IdField As Long, TimeField As Long)
303303
Type Task (TaskName As String, TaskItem As Item, TaskKey As String)
304304
Type Range(firstIndex As Int,lastIndex As Int)
305-
Private previousRange As Range
306305
Private Drag As B4JDragToMe
307306
End Sub
308307

BasicCAT/BasicCAT.b4j.meta

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,4 @@ ModuleClosedNodes7=
182182
ModuleClosedNodes8=
183183
ModuleClosedNodes9=
184184
SelectedBuild=0
185-
VisibleModules=1,2,3,4,5,6,7,8,9,10
185+
VisibleModules=1,2,3,4,5,6,7,8,9,10,35,50,32

BasicCAT/Files/pdf2txt.bjl

0 Bytes
Binary file not shown.

BasicCAT/PDF2TXT.bas

+6-7
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,15 @@ Sub ocrButton_MouseClicked (EventData As MouseEvent)
133133
Return
134134
End If
135135

136-
Label2.Text="Convert pdf to images..."
136+
Label2.Text="Converting pdf to images..."
137137
Dim files As List
138138
wait for (pdfbox.getImage(File.GetFileParent(label1.Text),File.GetName(label1.Text))) complete (result As List)
139139
files=result
140140
Label2.Text="OCRing..."
141141
If IncludePageNumCheckBox.Checked Then
142-
143-
wait for (scanWithPagenum(files,langsParam,PageAffixTextField.Text,offsetTextField.Text)) complete (text As String)
142+
wait for (ocrWithPagenum(files,langsParam,PageAffixTextField.Text,offsetTextField.Text)) complete (text As String)
144143
Else
145-
wait for (scan(files,langsParam)) complete (text As String)
144+
wait for (ocr(files,langsParam)) complete (text As String)
146145
End If
147146
Label2.Text="Completed"
148147
TextArea1.Text=text
@@ -190,7 +189,7 @@ Sub testTesseractPath As ResumableSub
190189
Return exist
191190
End Sub
192191

193-
Sub scanWithPagenum(files As List,langsParam As String,affix As String,offset As Int) As ResumableSub
192+
Sub ocrWithPagenum(files As List,langsParam As String,affix As String,offset As Int) As ResumableSub
194193
Dim dir As String
195194
dir=File.GetFileParent(label1.Text)
196195
Dim pdfFilename As String
@@ -240,7 +239,7 @@ Sub scanWithPagenum(files As List,langsParam As String,affix As String,offset As
240239
Return content
241240
End Sub
242241

243-
Sub scan(files As List,langsParam As String) As ResumableSub
242+
Sub ocr(files As List,langsParam As String) As ResumableSub
244243
Dim dir As String
245244
dir=File.GetFileParent(label1.Text)
246245
Dim pdfFilename As String
@@ -284,4 +283,4 @@ Sub IncludePageNumCheckBox_CheckedChange(Checked As Boolean)
284283
FacingPageCheckBox.Enabled=Checked
285284
PageAffixTextField.Enabled=Checked
286285
offsetTextField.Enabled=Checked
287-
End Sub
286+
End Sub

BasicCAT/pdfbox.bas

+15-11
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,25 @@ Sub getImage(dir As String,filename As String) As ResumableSub
6060
For i=0 To pageNum-1
6161
Log(i)
6262
Sleep(0)
63-
Dim bi As JavaObject
64-
Dim dpi As Float
65-
dpi=150
66-
bi=PDFRenderer.RunMethodJO("renderImageWithDPI",Array(i,dpi))
67-
Dim out As OutputStream
68-
out=File.OpenOutput(dir,i&".jpg",False)
69-
Dim imageIO As JavaObject
70-
imageIO.InitializeStatic("javax.imageio.ImageIO")
71-
imageIO.RunMethod("write",Array(bi,"jpg",out))
72-
out.Close
73-
files.Add(File.Combine(dir,i&".jpg"))
63+
renderImageToFile(PDFRenderer,files,dir,i)
7464
Next
7565
Return files
7666
End Sub
7767

68+
Sub renderImageToFile(PDFRenderer As JavaObject,files As List,dir As String,i As Int)
69+
Dim bi As JavaObject
70+
Dim dpi As Float
71+
dpi=150
72+
bi=PDFRenderer.RunMethodJO("renderImageWithDPI",Array(i,dpi))
73+
Dim out As OutputStream
74+
out=File.OpenOutput(dir,i&".jpg",False)
75+
Dim imageIO As JavaObject
76+
imageIO.InitializeStatic("javax.imageio.ImageIO")
77+
imageIO.RunMethod("write",Array(bi,"jpg",out))
78+
out.Close
79+
files.Add(File.Combine(dir,i&".jpg"))
80+
End Sub
81+
7882
Sub getFile(path As String) As JavaObject
7983
Dim fileJO As JavaObject
8084
fileJO.InitializeNewInstance("java.io.File",Array(path))

0 commit comments

Comments
 (0)