# PDF Parser

## Декодирование стримов

```python
import sys, zlib

def main(fn):
    data = open(fn, 'rb').read()
    i = 0
    first = True
    last = None
    while True:
        i = data.find(b'>>\nstream\n', i)
        if i == -1:
            break
        i += 10
        try:
            last = cdata = zlib.decompress(data[i:])
            if first:
                first = False
            else:
                pass#print cdata
        except:
            pass
    print(last.decode('utf-8'))

if __name__=='__main__':
    main(*sys.argv[1:])
```

## Пример извлечения текста

```python
from pdfreader import SimplePDFViewer 

fd = open('cv3.pdf', "rb") 
viewer = SimplePDFViewer(fd) 
viewer.render() 
"".join(viewer.canvas.strings)

pdfReader = PyPDF2.PdfFileReader(open('file.pdf','rb')) 
pageObj = pdfReader.getPage(0) 
text = pageObj.extractText()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://appsecurity.gitbook.io/devops/ppc/ppc-langs/backend/python/packages/obrabotka-informacii/pdf-parser.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
