-
Notifications
You must be signed in to change notification settings - Fork 943
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
Pack the permissions (the /P entry) as unsigned long, fix #186 #352
Conversation
I did some research and your solution looks spot-on to me. However, the 5 tests for this PR are failing indicating that changing this breaks other this. Could you have a look and this? Also, make sure to add a line to the CHANGELOG.md. |
The cause of the errors is probably that |
Yeah sorry, I really didn't think self.p could be negative, will look into it |
Great! I am also trying to figure this out right now. I found a paragraph in the PDF reference that is quite helpful (right above Table 3.20):
|
I guess you need to convert the signed value (e.g. I cannot find anything in pdfminer.six that already implements this algorithm, so I guess you should do it yourself. There is some pseudocode on the wikipedia. |
You can just add 1<<32 if it's negative, and it works for all samples, but it's not the cleanest solution (should be parsed as unsigned in the first place) Edit: I think we should just add 1<<32 and leave it like this, it seems to be coherent with the reference I'm currently testing it on a few pdfs in my downloads folder, will push commits in an hour |
It is preferable to implement the two's complement method instead of some approximation. I know it is more fuzz than you care about, but that way we follow the PDF reference exactly. And implementing things exactly like the PDF reference saves a lot of fuzz in the future. I just noticed that the pseudo-code on wikipedia is actually Python. You can put this function in pdfminer.six/pdfminer/pdfdocument.py Line 310 in b27d3d0
|
It's not an approximation, it's how two's complement is defined, see the wikipedia article |
Ah, I did not get that! Than it's fine. |
@Recursing could you review it once more and see if I made some dumb mistake? |
Looks fine to me, really thanks for everything! In |
Thanks for all the effort! |
Hey folks, facing a similar issue, can anybody help?
Here is the file Python : 3.7.10 |
Description
Fixes #186, by treating the /P entry as a four byte unsigned integer
How Has This Been Tested?
Tested the pdf in the issue
Checklist