在Ned Batchelder的博客上有一篇文章谈到了一点儿如何从PDF中提取JPG图片。代码如下: # Extract jpg's from pdf's. Quick and dirty. import sys pdf = file(sys.argv[ 1 ], "rb" ).read() startmark = "xffxd8" startfix = 0 endmark = "xffxd9" endfix = 2 i = 0 njpg = 0 while True : istream = pdf.find( "stream" , i) if istream < 0 : break istart = pdf.find(startmark, istream, istream+ 20 ) if istart < 0 : i = istream+ 20 continue iend = pdf.find( "endstream" , istart) if iend < 0 : raise Exception( "Didn't find end of stream!" ) if os