def ascii85decode(data):
    """
    In ASCII85 encoding, every four bytes are encoded with five ASCII
    letters, using 85 different types of characters (as 256**4 < 85**5).
    When the length of the original bytes is not a multiple of 4, a special
    rule is used for round up.

    The Adobe's ASCII85 implementation is slightly different from
    its original in handling the last characters.

    The sample string is taken from:
      http://en.wikipedia.org/w/index.php?title=Ascii85

    >>> ascii85decode(b'9jqo^BlbD-BleB1DJ+*+F(f,q')
    b'Man is distinguished'
    >>> ascii85decode(b'E,9)oF*2M7/c~>')
    b'pleasure.'
    """
    n = b = 0
    out = b''
    for c in data:
        if 33 <= c and c <= 117: # b'!' <= c and c <= b'u'
            n += 1
            b = b*85+(c-33)
            if n == 5:
                out += struct.pack('>L', b)
                n = b = 0
        elif c == 122: # b'z'
            assert n == 0
            out += b'\0\0\0\0'
        elif c == 126: # b'~'
            if n:
                for _ in range(5-n):
                    b = b*85+84
                out += struct.pack('>L', b)[:n-1]
            break
    return out

    In ASCII85 encoding, every four bytes are encoded with five ASCII
    letters, using 85 different types of characters (as 256**4 < 85**5).
    When the length of the original bytes is not a multiple of 4, a special
    rule is used for round up.

    The Adobe's ASCII85 implementation is slightly different from
    its original in handling the last characters.

    The sample string is taken from:
      http://en.wikipedia.org/w/index.php?title=Ascii85

    >>> ascii85decode(b'9jqo^BlbD-BleB1DJ+*+F(f,q')
    b'Man is distinguished'
    >>> ascii85decode(b'E,9)oF*2M7/c~>')
    b'pleasure.'
    
pdfminer/ascii85.py