Hopding / pdf-lib

Create and modify PDF documents in any JavaScript environment
https://pdf-lib.js.org
MIT License
6.6k stars 635 forks source link

Outside SetCropBox content is maintained when cloning (not sure if it's a bug) #1563

Open fabioespinosa opened 7 months ago

fabioespinosa commented 7 months ago

What were you trying to do?

I am trying to blurr the second half of the first page. I successfully do so by inserting a blurred image using drawImage. However I see that this results in just an overlay on top and you can still select the text below it if you drag, copy and paste it elsewhere.

My usecase requires me to permanently delete the content that is underneath drawImage.

Usecase: I have a website for users to sell documents. I need to provide some previews for other users to see them before they buy them.

How did you attempt to do it?

I attempted to use page.setCropBox(0, 0, width, height/2) then cloning the page and then restoring page.setCropBox(0, 0, width, height) again. However the content is maintained.

I attempted to use page.setSize(width, height/2) and doing the same procedure, but the content is maintained as well.

I can't find a way to permanently delete a part of the pdf 🤔

What actually happened?

Content is maintained and there seems to be no "destructive" irreversible crop 🤔

What did you expect to happen?

I expect to find a way to irreversibly crop part of a page.

How can we reproduce the issue?

using the methods above on all PDFs

Version

1.17.1

What environment are you running pdf-lib in?

Node

Checklist

Additional Notes

THANKS, awesome library!!