Data extraction from /Filter /FlateDecode PDF stream in PHP

后端 未结 4 1216
离开以前
离开以前 2020-12-22 20:17

I can not decrypt the data from the stream like:

    56 0 obj 
    << /Length 1242 /Filter /FlateDecode >>
    stream
    x]êΩnƒ Ñ{ûbÀKq¬æ\\âê¢..         


        
4条回答
  •  梦毁少年i
    2020-12-22 20:53

    Long overdue, but someone might find it helpful. In this case: << /Length 1242 /Filter /FlateDecode >> all you need is to pass the isolated binary string (so basically everything between "stream" and "endstream") to zlib.decompress:

    import zlib
    stream = b"êΩnƒ Ñ{ûbÀKq¬æ\âê"  # binary stream here
    data = zlib.decompress(stream) # Here you have your clean decompressed stream
    

    However, if you have/DecodeParms in your PDF object thing become complicated. You will need the /Predictor value and columns number. Better use PyPDF2 for this.

提交回复
热议问题