質問編集履歴
5
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
### 質問
|
24
24
|
|
25
|
-
ご指摘のおかげでコードを修正し結合することはできたのですが、PDFが読み込めません。エラーメッセージが出ないので原因がわかりません。結合に失敗する原因を教えていただ
|
25
|
+
ご指摘のおかげでコードを修正し結合することはできたのですが、PDFが読み込めません。エラーメッセージが出ないので原因がわかりません。結合に失敗する原因を教えていただけると助かります。よろしくお願いいたします。
|
26
26
|
|
27
27
|
|
28
28
|
|
4
ご回答により以前のエラーが改善し、不明点が変更になったため
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Python PDFに
|
1
|
+
Python 5ページ写真つきPDF結合に失敗してしまいます。
|
test
CHANGED
@@ -8,9 +8,11 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
+
### 今やろうとしていること
|
12
|
+
|
11
13
|
PDFの容量:900KB
|
12
14
|
|
13
|
-
2ファイル結合しようと思っています。
|
15
|
+
5ページ2ファイル結合しようと思っています。
|
14
16
|
|
15
17
|
|
16
18
|
|
@@ -20,23 +22,13 @@
|
|
20
22
|
|
21
23
|
### 質問
|
22
24
|
|
23
|
-
|
25
|
+
ご指摘のおかげでコードを修正し結合することはできたのですが、PDFが読み込めません。エラーメッセージが出ないので原因がわかりません。結合に失敗する原因を教えていただきたけると助かります。よろしくお願いいたします。
|
24
|
-
|
25
|
-
よろしくお願いいたします。
|
26
|
-
|
27
|
-
Python始めたばかりで見当違いな質問でしたらすみません。
|
28
26
|
|
29
27
|
|
30
28
|
|
31
|
-
### 確認したこと
|
32
|
-
|
33
|
-
unicodeエラーなのか、と思い下記のようにして確認しました。
|
34
29
|
|
35
30
|
|
36
31
|
|
37
|
-
sys.getdefaultencoding()
|
38
|
-
|
39
|
-
'utf-8'
|
40
32
|
|
41
33
|
|
42
34
|
|
@@ -68,7 +60,7 @@
|
|
68
60
|
|
69
61
|
pdf_file_obj = open(filename, 'rb')
|
70
62
|
|
71
|
-
pdf_reader = PyPDF2.PdfFileReader(pdf_file_obj)
|
63
|
+
pdf_reader = PyPDF2.PdfFileReader(pdf_file_obj, strict=False)
|
72
64
|
|
73
65
|
|
74
66
|
|
@@ -87,141 +79,3 @@
|
|
87
79
|
pdf_output.close()
|
88
80
|
|
89
81
|
```
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
### エラーの内容
|
94
|
-
|
95
|
-
```
|
96
|
-
|
97
|
-
Traceback (most recent call last):
|
98
|
-
|
99
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
100
|
-
|
101
|
-
\PyPDF2\generic.py", line 484, in readFromStream
|
102
|
-
|
103
|
-
return NameObject(name.decode('utf-8'))
|
104
|
-
|
105
|
-
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 8: invalid
|
106
|
-
|
107
|
-
start byte
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
During handling of the above exception, another exception occurred:
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
Traceback (most recent call last):
|
116
|
-
|
117
|
-
File "C:\Users\userid123\Desktop\作業\python\pdftest.py", line 19, in <module>
|
118
|
-
|
119
|
-
pdf_writer.write(pdf_output)
|
120
|
-
|
121
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
122
|
-
|
123
|
-
\PyPDF2\pdf.py", line 482, in write
|
124
|
-
|
125
|
-
self._sweepIndirectReferences(externalReferenceMap, self._root)
|
126
|
-
|
127
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
128
|
-
|
129
|
-
\PyPDF2\pdf.py", line 571, in _sweepIndirectReferences
|
130
|
-
|
131
|
-
self._sweepIndirectReferences(externMap, realdata)
|
132
|
-
|
133
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
134
|
-
|
135
|
-
\PyPDF2\pdf.py", line 547, in _sweepIndirectReferences
|
136
|
-
|
137
|
-
value = self._sweepIndirectReferences(externMap, value)
|
138
|
-
|
139
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
140
|
-
|
141
|
-
\PyPDF2\pdf.py", line 571, in _sweepIndirectReferences
|
142
|
-
|
143
|
-
self._sweepIndirectReferences(externMap, realdata)
|
144
|
-
|
145
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
146
|
-
|
147
|
-
\PyPDF2\pdf.py", line 547, in _sweepIndirectReferences
|
148
|
-
|
149
|
-
value = self._sweepIndirectReferences(externMap, value)
|
150
|
-
|
151
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
152
|
-
|
153
|
-
\PyPDF2\pdf.py", line 556, in _sweepIndirectReferences
|
154
|
-
|
155
|
-
value = self._sweepIndirectReferences(externMap, data[i])
|
156
|
-
|
157
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
158
|
-
|
159
|
-
\PyPDF2\pdf.py", line 571, in _sweepIndirectReferences
|
160
|
-
|
161
|
-
self._sweepIndirectReferences(externMap, realdata)
|
162
|
-
|
163
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
164
|
-
|
165
|
-
\PyPDF2\pdf.py", line 547, in _sweepIndirectReferences
|
166
|
-
|
167
|
-
value = self._sweepIndirectReferences(externMap, value)
|
168
|
-
|
169
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
170
|
-
|
171
|
-
\PyPDF2\pdf.py", line 547, in _sweepIndirectReferences
|
172
|
-
|
173
|
-
value = self._sweepIndirectReferences(externMap, value)
|
174
|
-
|
175
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
176
|
-
|
177
|
-
\PyPDF2\pdf.py", line 547, in _sweepIndirectReferences
|
178
|
-
|
179
|
-
value = self._sweepIndirectReferences(externMap, value)
|
180
|
-
|
181
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
182
|
-
|
183
|
-
\PyPDF2\pdf.py", line 577, in _sweepIndirectReferences
|
184
|
-
|
185
|
-
newobj = data.pdf.getObject(data)
|
186
|
-
|
187
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
188
|
-
|
189
|
-
\PyPDF2\pdf.py", line 1611, in getObject
|
190
|
-
|
191
|
-
retval = readObject(self.stream, self)
|
192
|
-
|
193
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
194
|
-
|
195
|
-
\PyPDF2\generic.py", line 66, in readObject
|
196
|
-
|
197
|
-
return DictionaryObject.readFromStream(stream, pdf)
|
198
|
-
|
199
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
200
|
-
|
201
|
-
\PyPDF2\generic.py", line 579, in readFromStream
|
202
|
-
|
203
|
-
value = readObject(stream, pdf)
|
204
|
-
|
205
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
206
|
-
|
207
|
-
\PyPDF2\generic.py", line 60, in readObject
|
208
|
-
|
209
|
-
return NameObject.readFromStream(stream, pdf)
|
210
|
-
|
211
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
212
|
-
|
213
|
-
\PyPDF2\generic.py", line 492, in readFromStream
|
214
|
-
|
215
|
-
raise utils.PdfReadError("Illegal character in Name Object")
|
216
|
-
|
217
|
-
PyPDF2.utils.PdfReadError: Illegal character in Name Object
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
```### 修正して新たに発生したエラー
|
222
|
-
|
223
|
-
```
|
224
|
-
|
225
|
-
PdfReadWarning: Illegal character in Name Object [generic.py:489]
|
226
|
-
|
227
|
-
```
|
3
エラーの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -222,28 +222,6 @@
|
|
222
222
|
|
223
223
|
```
|
224
224
|
|
225
|
-
Traceback (most recent call last):
|
226
|
-
|
227
|
-
File "C:\Users\userid123\Desktop\作業\python\test.py", line 12, in <mo
|
228
|
-
|
229
|
-
dule>
|
230
|
-
|
231
|
-
|
225
|
+
PdfReadWarning: Illegal character in Name Object [generic.py:489]
|
232
|
-
|
233
|
-
|
226
|
+
|
234
|
-
|
235
|
-
\PyPDF2\pdf.py", line 1084, in __init__
|
236
|
-
|
237
|
-
self.read(stream)
|
238
|
-
|
239
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
240
|
-
|
241
|
-
\PyPDF2\pdf.py", line 1689, in read
|
242
|
-
|
243
|
-
stream.seek(-1, 2)
|
244
|
-
|
245
|
-
OSError: [Errno 22] Invalid argument
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
```
|
227
|
+
```
|
2
情報の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,6 +8,12 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
+
PDFの容量:900KB
|
12
|
+
|
13
|
+
2ファイル結合しようと思っています。
|
14
|
+
|
15
|
+
|
16
|
+
|
11
17
|
Python 3.7.3
|
12
18
|
|
13
19
|
Windows7
|
1
エラーの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,6 +8,10 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
+
Python 3.7.3
|
12
|
+
|
13
|
+
Windows7
|
14
|
+
|
11
15
|
### 質問
|
12
16
|
|
13
17
|
PDFに写真が添付されているものを結合しようとしたらエラーが起きました。PDFに写真が添付されているとこのプログラムでは結合することはできないのでしょうか?それと、このエラーの原因を教えて頂きたいです。
|
@@ -208,4 +212,32 @@
|
|
208
212
|
|
209
213
|
|
210
214
|
|
215
|
+
```### 修正して新たに発生したエラー
|
216
|
+
|
211
|
-
```
|
217
|
+
```
|
218
|
+
|
219
|
+
Traceback (most recent call last):
|
220
|
+
|
221
|
+
File "C:\Users\userid123\Desktop\作業\python\test.py", line 12, in <mo
|
222
|
+
|
223
|
+
dule>
|
224
|
+
|
225
|
+
pdf_reader = PyPDF2.PdfFileReader(pdf_file_obj,strict=False)
|
226
|
+
|
227
|
+
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
228
|
+
|
229
|
+
\PyPDF2\pdf.py", line 1084, in __init__
|
230
|
+
|
231
|
+
self.read(stream)
|
232
|
+
|
233
|
+
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\Lib\site-packages
|
234
|
+
|
235
|
+
\PyPDF2\pdf.py", line 1689, in read
|
236
|
+
|
237
|
+
stream.seek(-1, 2)
|
238
|
+
|
239
|
+
OSError: [Errno 22] Invalid argument
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
```
|