# PyCall trouble

**URL:** <https://discourse.julialang.org/t/pycall-trouble/79255>\
**Category:** New to Julia\
**Tags:** pycall\
**Created:** [April 9, 2022, 11:23am UTC](https://discourse.julialang.org/t/pycall-trouble/79255 "2022-04-09T11:23:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dodoplus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dodoplus/32/30148_2.png) [@dodoplus](https://discourse.julialang.org/u/dodoplus)\
**Post date:** [April 9, 2022, 11:23am UTC](https://discourse.julialang.org/t/pycall-trouble/79255/1 "2022-04-09T11:23:53Z")

</div>

Hi,

I want to read text out of a PDF. I know there’s PDFIO, but unfortunately it seems to crash on some PDFs.

So: I’d like to use Python’s PyPDF2. However, I ran into a different problem…

In Python I can read a page thus:

```python
import PyPDF2
doc=PyPDF2.pdf.PdfFileReader("x.pdf")
p = doc.getPage(1)
type(p)
# PyPDF2.pdf.PageObject

```

But I don’t get a PageObject with PyCall:

```julia
using PyCall
pypdf = pyimport("PyPDF2")
doc = pypdf.pdf.PdfFileReader("x.pdf")
p = p2.getPage(1)
typeof(p)
# Dict{Any, Any} 

```

Obviously, I can’t then do something like:

```julia
p.extractText()

```

What am I missing?

Thanks,

DD

---

<div class="post-metadata">

**Author:** ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)\
**Post date:** [April 9, 2022, 11:39am UTC](https://discourse.julialang.org/t/pycall-trouble/79255/2 "2022-04-09T11:39:31Z")

</div>

Yeah PyCall converts any returned Python objects to Julia ones. Presumably a PageObject is a dict-like thing so gets converted to a Dict.

You can do `pycall(doc.getPage, PyObject, 2)` to keep it as a Python object.

(Aside, there’s also PythonCall which doesn’t do this automatic conversion.)
