Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module 'pypdfium2' has no attribute 'FPDF_LoadDocument' #217

Closed
awied opened this issue Apr 29, 2023 · 4 comments
Closed

module 'pypdfium2' has no attribute 'FPDF_LoadDocument' #217

awied opened this issue Apr 29, 2023 · 4 comments
Labels
invalid This doesn't seem right

Comments

@awied
Copy link

awied commented Apr 29, 2023

I'm using version 4.8.0.
How to reproduce:

import pypdfium2 as pdfium
doc = pdfium.FPDF_LoadDocument(THE_FILEPATH, None)

--> AttributeError: module 'pypdfium2' has no attribute 'FPDF_LoadDocument'

Observation: this works with version 3.21.1 but seems to be broken starting with version 4.0.0

@mara004
Copy link
Member

mara004 commented Apr 29, 2023

Not broken. Deliberate change. Read the docs.

@mara004 mara004 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 29, 2023
@mara004 mara004 added the invalid This doesn't seem right label Apr 29, 2023
@mara004
Copy link
Member

mara004 commented Apr 29, 2023

Quoting changelog for v4:

The raw API is now isolated in a separate namespace (pypdfium2.raw). Moreover, the raw API bindings do not implicitly encode strings anymore (pypdfium2 is now built with a patched version of ctypesgen by default).

Also worth a read:
https://pypdfium2.readthedocs.io/en/latest/python_api.html#api-layers

@mara004
Copy link
Member

mara004 commented Apr 30, 2023

Your example could be rewritten like this

import pypdfium2.raw as pdfium_c
doc = pdfium_c.FPDF_LoadDocument((THE_FILEPATH+"\x00").encode("utf-8"), None)

However, I encourage using our helper class PdfDocument for document loading.

(Edit: added null terminator, to be safe)

@mara004
Copy link
Member

mara004 commented May 6, 2023

Oh, actually the Readme was highly unclear about this, I forgot to update. I'll push a commit shortly.
I prefer to work with RTD; keeping the Readme in sync has become a bit of a nuisance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants