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

exception "PdfReader not opened with owner password" #85

Open
VladimirAlexiev opened this issue Nov 1, 2024 · 2 comments
Open

exception "PdfReader not opened with owner password" #85

VladimirAlexiev opened this issue Nov 1, 2024 · 2 comments
Labels

Comments

@VladimirAlexiev
Copy link

VladimirAlexiev commented Nov 1, 2024

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: PdfReader not opened with owner password
        at com.itextpdf.text.pdf.PdfReaderInstance.getImportedPage(PdfReaderInstance.java:80)
        at com.itextpdf.text.pdf.PdfCopy.getImportedPageImpl(PdfCopy.java:388)
        at com.itextpdf.text.pdf.PdfCopy.getImportedPage(PdfCopy.java:255)
        at at.laborg.briss.utils.DocumentCropper.copyToMultiplePages(DocumentCropper.java:100)
        at at.laborg.briss.utils.DocumentCropper.crop(DocumentCropper.java:62)
        at at.laborg.briss.BrissSwingGUI.savePDF(BrissSwingGUI.java:370)
        at at.laborg.briss.BrissSwingGUI.lambda$showSaveFileDialog$9(BrissSwingGUI.java:335)
        at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
        at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Note: I thought the culprit are annotations added by SumatraPDF, but it also happens on the original file

Versions:

  • briss 2.0 alpha5
  • Windows 10,
  • cygwin,
  • openjdk version "22" 2024-03-19
    OpenJDK Runtime Environment Temurin-22+36 (build 22+36)
    OpenJDK 64-Bit Server VM Temurin-22+36 (build 22+36, mixed mode, sharing)
@cleydyr
Copy link
Collaborator

cleydyr commented Nov 2, 2024

From Wikipedia:

The standard security provided by PDF consists of two different methods and two different passwords: a user password, which encrypts the file and prevents opening, and an owner password, which specifies operations that should be restricted even when the document is decrypted, which can include modifying, printing, or copying text and graphics out of the document, or adding or modifying text notes and AcroForm fields. The user password encrypts the file, while the owner password does not, instead relying on client software to respect these restrictions. An owner password can easily be removed by software, including some free online services.[33] Thus, the use restrictions that a document author places on a PDF document are not secure, and cannot be assured once the file is distributed; this warning is displayed when applying such restrictions using Adobe Acrobat software to create or edit PDF files.

So, even though the file doesn't have a user password (which we currently cover) it does have an owner password. The library we use allows the use of the unethicalReading flag to ignore owner permissions. But that name has been effective in making me think twice before adding it to our code as a workaround.

Thoughts, @mbaeuerle?

@VladimirAlexiev
Copy link
Author

Imho cropping cannot be considered unethical

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants