import fitz # = PyMuPDF
doc = fitz.open("test.pdf") # open the PDF
count = doc.embeddedFileCount
print("number of embedded file:", count) # shows number of embedded files
# get decompressed content of data stored by name "my data"
# also possible to use integer between 0 and "count - 1"
buff = doc.embeddedFileGet("my data")
fout = open("test.file", "wb") # open output file
fout.write(buff)
fout.close()
Diff to Previous Revision
--- revision 2 2017-05-04 15:54:58
+++ revision 3 2017-07-11 18:57:54
@@ -4,7 +4,7 @@
print("number of embedded file:", count) # shows number of embedded files
# get decompressed content of data stored by name "my data"
-# also possible to use integer between 0 and "count"
+# also possible to use integer between 0 and "count - 1"
buff = doc.embeddedFileGet("my data")
fout = open("test.file", "wb") # open output file