-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
229 lines (214 loc) · 7.32 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<!DOCTYPE html>
<html>
<head>
<title>
PDF to Text - pdftotext.github.io
</title>
<meta name=viewport content="width=device-width,initial-scale=1">
<link href=bootstrap.min.css rel=stylesheet>
<link href=material.min.css rel=stylesheet>
<link href=material-wfont.min.css rel=stylesheet>
<link href=ripples.min.css rel=stylesheet>
<link href=ladda-themeless.min.css rel=stylesheet>
<script src=pdf.min.js></script>
<style>
html {
position: relative;
min-height: 100%;
}
body {
margin: 0 0 70px;
}
footer {
position: absolute;
left: 0;
bottom: 0;
height: 30px;
width: 100%;
}
.well {
margin-top: 40px;
}
.btn {
margin: 40px 0 0;
}
.btn-file {
position: relative;
overflow: hidden;
}
.btn-file input[type=file] {
position: absolute;
top: 0;
right: 0;
min-width: 100%;
min-height: 100%;
font-size: 100px;
text-align: right;
opacity: 0;
outline: none;
background: white;
cursor: inherit;
display: block;
}
.header-panel {
background: #009587 url(header.jpg) no-repeat center center;
background-size: cover;
height: 244px;
}
</style>
</head>
<body>
<script src=FileSaver.min.js></script>
<script src=spin.min.js></script>
<script src=ladda.min.js></script>
<div class=header-panel>
</div>
<div class=container>
<div style=text-align:center>
<span
class="btn btn-primary btn-file ladda-button"
data-style=expand-left
>
Convert PDF to text
<input
type=file
id=file
name=file
accept=application/pdf
/>
</span>
<a href class="btn btn-info hide" id=download-btn>
Download as TXT
</a>
</div>
<div class=row>
<div
id=output
class="col-xs-12 well"
style=font-family:monospace;display:none
>
</div>
<div
id=error
class="col-xs-12"
style=font-style:italic;display:none;text-align:center;margin-top:40px
>
</div>
</div>
<div class=row>
<div class="col-sm-offset-3 col-sm-6 well">
<p>
<strong>pdf</strong>to<strong>text</strong>.github.io
is the best online service for easily extracting
text from your PDF files.
Conversion from PDF to TXT is really fast
thanks to our in-browser conversion architecture.
</p>
<p>
Your PDF files are never uploaded to the Internet,
so even private PDF files are safe to convert with this service.
The conversion is done locally in your browser –
you can even convert when you are offline!
</p>
<p>
There is no need for any registration or sign-up,
and the service will always be free to use.
</p>
</div>
</div>
</div>
<footer>
<div class=container>
<div class=pull-right>
A free service by <a href=http://arkt.is>Sigve Sebastian Farstad</a>
</div>
<h1 style=font-size:inherit;margin:inherit>
<a href=http://pdftotext.github.io style=color:rgba(0,0,0,.84)>
<strong>pdf</strong>to<strong>text</strong>.github.io
</a>
</h1>
</div>
</footer>
<script>
(function() {
var currentFilename = '';
var laddaButton = Ladda.create(document.querySelector( '.btn-file' ));
document.querySelector('#file').addEventListener('change', function(e) {
var fileReader = new FileReader();
fileReader.onload = function(e) {
PDFJS.getDocument(e.target.result).then(function(pdf) {
var items = [];
var pagesRemaining = pdf.pdfInfo.numPages;
for(var i = 1; i <= pdf.pdfInfo.numPages; i++) {
pdf.getPage(i).then(function(page) {
page.getTextContent().then(function(textContent) {
var previousHeight = NaN;
var currentString = [];
for(var j = 0; j < textContent.items.length; j++) {
var item = textContent.items[j];
if(item.transform[5] != previousHeight) {
previousHeight = item.transform[5];
items.push({item: item, str: currentString.join('')});
currentString = [item.str];
} else {
currentString.push(item.str);
}
}
pagesRemaining--;
if(pagesRemaining == 0) {
var outputContainer = document.querySelector('#output');
var errorContainer = document.querySelector('#error');
outputContainer.style.display = 'none';
errorContainer.style.display = 'none';
document.querySelector('#download-btn')
.classList.add('hide');
if(items.length) {
outputContainer.style.display = 'block';
document.querySelector('#download-btn')
.classList.remove('hide');
outputContainer.innerHTML = '';
items.forEach(function(item) {
var div = document.createElement('div');
div.textContent = item.str;
outputContainer.appendChild(div);
});
ga('send', 'event', 'conversion', 'success');
} else {
errorContainer.textContent = 'No text found in PDF.';
errorContainer.style.display = 'block';
ga('send', 'event', 'conversion', 'no text found');
}
laddaButton.stop();
}
});
});
}
});
};
if(e.target.files && e.target.files[0]) {
laddaButton.start();
ga('send', 'event', 'button', 'click', 'convert pdf to text');
fileReader.readAsArrayBuffer(e.target.files[0]);
currentFilename = e.target.files[0].name;
}
});
document.querySelector('#download-btn')
.addEventListener('click', function(e) {
e.preventDefault();
ga('send', 'event', 'button', 'click', 'download button');
var blob = new Blob([document.querySelector('#output').textContent],
{type: "text/plain;charset=utf-8"});
saveAs(blob, currentFilename + ".txt");
});
})();
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-57967705-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>