python code : en pdf translate zh pdf,but translate result not write pdf
Asked
Active
Viewed 143 times
1 Answers
0
The returned object of response.document_translation.byte_stream_outputs
is <class 'proto.marshal.collections.repeated.Repeated'>
which means it is a list. You need to loop through the bytes_stream
object then write it to file.
See code snippet below for the implementation:
bytes_stream = response.document_translation.byte_stream_outputs
f = open('2_after.pdf', 'wb')
for data in bytes_stream:
f.write(data)
f.close()

Ricco D
- 6,873
- 1
- 8
- 18