69 |
return m; |
return m; |
70 |
} |
} |
71 |
|
|
72 |
|
class PageFiles { |
73 |
|
int xreso, yreso; |
74 |
|
String[] filenames; |
75 |
|
} |
76 |
|
|
77 |
public SingleImage getSingleImage(ImageSpan img, PoolManager poolManager) { |
public SingleImage getSingleImage(ImageSpan img, PoolManager poolManager) { |
78 |
PageImageSpan span = (PageImageSpan)img; |
PageImageSpan span = (PageImageSpan)img; |
79 |
int page = span.getPageIndex(); |
int page = span.getPageIndex(); |
85 |
if(singleImage == null) { |
if(singleImage == null) { |
86 |
|
|
87 |
try { |
try { |
88 |
String[] pageFiles = getPageFiles(sb); |
int[] res = new int[2]; |
89 |
|
PageFiles pageFiles = getPageFiles(sb); |
90 |
singleImage = new SingleImage( |
singleImage = new SingleImage( |
91 |
sb.getID(), |
sb.getID(), |
92 |
page, |
page, |
93 |
pageFiles[page], |
pageFiles.filenames[page], |
94 |
RESOLUTION, |
pageFiles.xreso, |
95 |
|
pageFiles.yreso, |
96 |
poolManager |
poolManager |
97 |
); |
); |
98 |
} catch(Exception e) { |
} catch(Exception e) { |
103 |
return singleImage; |
return singleImage; |
104 |
} |
} |
105 |
|
|
106 |
private String[] getPageFiles(ScrollBlock pages) |
private PageFiles getPageFiles(ScrollBlock pages) |
107 |
throws FileNotFoundException { |
throws FileNotFoundException { |
108 |
String[] f = (String[]) block2pagefiles.get(pages); |
PageFiles f = (PageFiles) block2pagefiles.get(pages); |
109 |
if(f == null) { |
if(f == null) { |
110 |
f = makePageFiles(pages); |
f = makePageFiles(pages); |
111 |
block2pagefiles.put(pages, f); |
block2pagefiles.put(pages, f); |
115 |
|
|
116 |
PythonInterpreter interp; |
PythonInterpreter interp; |
117 |
|
|
118 |
private synchronized String[] makePageFiles(ScrollBlock pages) |
private synchronized PageFiles makePageFiles(ScrollBlock pages) |
119 |
throws java.io.FileNotFoundException { |
throws java.io.FileNotFoundException { |
120 |
String ct = pages.getContentType(); |
String ct = pages.getContentType(); |
121 |
if(! (ct.equals("application/pdf") || |
if(! (ct.equals("application/pdf") || |
152 |
tmppaths[i] = new File(tmp(), "tmp"+base).getPath(); |
tmppaths[i] = new File(tmp(), "tmp"+base).getPath(); |
153 |
if(!f.exists()) exist = false; |
if(!f.exists()) exist = false; |
154 |
} |
} |
155 |
if(exist) return paths; |
|
156 |
|
PageFiles res = new PageFiles(); |
157 |
|
res.xreso = xreso; |
158 |
|
res.yreso = yreso; |
159 |
|
res.filenames = paths; |
160 |
|
|
161 |
|
if(exist) return res; |
162 |
|
|
163 |
// Need to make them. |
// Need to make them. |
164 |
// |
// |
190 |
(new File(tmppaths[i])).delete(); |
(new File(tmppaths[i])).delete(); |
191 |
} |
} |
192 |
|
|
193 |
return paths; |
return res; |
194 |
} |
} |
195 |
|
|
196 |
|
|