-
Notifications
You must be signed in to change notification settings - Fork 29
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
Strange MediaBox and CropBox of PDF page #59
Comments
The pdf seems malformed, but we can update pdf-lib to handle this malformation. How did this pdf get generated? |
Solved in @cantoo/pdf-lib: 2.2.0 |
I would still like to know how the pdf has been generated, though. |
Hi @Sharcoux. The PDF I added here is a partial PDF that I created from from another just for reproduce the behavior. According to |
According to the specs,
In your provided pdf, the mediabox inverted the 2 y coordinates, leading to the wrong result. So, I don't know who is the culprit during the file generation, but the file is definitely malformed. |
I have seen this issue and have looked into it. PDF specs,
Looking, 7.9.5 Rectangles
I understand that it does not have to be [lower left, upper right], although that is not common. I thought it would be easy to modify the values obtained, I have noticed this but have not been able to confirm it yet. |
Ok. Well, anyway, from version 2.2.1, both will be supported, so I think I'll just close this. Thanks for the clarification. |
What were you trying to do?
I'm trying to get the page boxes information to centralize an image.
How did you attempt to do it?
I tried to get information from
getMediaBox()
orgetCropBox()
methods fromPDFPage
object to calculate the page center position.What actually happened?
I got strange informations about the page boxes. In some cases, height and width of a page is a negative value.
What did you expect to happen?
Get the correct information about the page boxes.
How can we reproduce the issue?
I added a comment in an old issue about the MediaBox and CropBox. I added the PDF that I tested and a piece of code.
Note: I understood later that height and width are used to calculate
xEnd
andyEnd
of PDF page, but even if I calculate the end point I don't get the same information.Version
2.2.0
What environment are you running pdf-lib in?
Node
Checklist
Additional Notes
I did test in both versions and I got the same results:
pdf-lib
: 1.17.1@cantoo/pdf-lib
: 2.2.0The text was updated successfully, but these errors were encountered: