Jump to content

Alfred PDF Tools – Optimize, encrypt and manipulate PDF files


Recommended Posts

10 hours ago, xilopaint said:

 

This has been implemented in the latest version of the workflow.

Thanks. This would be great. I will test it. For some reason, the download from Github is very slow. Also would like to request for auto updater to be included in workflow

Link to comment
6 minutes ago, pankajsz said:

Thanks. This would be great. I will test it. For some reason, the download from Github is very slow. Also would like to request for auto updater to be included in workflow

 

xilopaint, tested the new release on macos 12.4 and Alfred 5.0.1 [2067]. I am getting the following error message. Pls check and advise

 

16:08:37.233] Alfred PDF Tools[File Action] Passing output '(

    "/Users/xyz/Downloads/File1.pdf",

    "/Users/xyz/Downloads/File2.pdf"

)' to Arg and Vars

[16:08:37.234] Alfred PDF Tools[Arg and Vars] Processing complete

[16:08:37.236] Alfred PDF Tools[Arg and Vars] Passing output '' to Keyword

[16:08:39.841] Alfred PDF Tools[Keyword] Processing complete

[16:08:39.846] Alfred PDF Tools[Keyword] Passing output 'File3' to Run Script

[16:08:39.891] ERROR: Alfred PDF Tools[Run Script] Traceback (most recent call last):

  File "/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.C1A40A08-CC24-4914-BDB8-B6921D00AB5E/alfred_pdf_tools.py", line 48, in <module>

    from PyPDF2 import PdfReader, PdfWriter, PdfMerger, PageRange, PageObject, errors

  File "/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.C1A40A08-CC24-4914-BDB8-B6921D00AB5E/PyPDF2/__init__.py", line 10, in <module>

    from ._encryption import PasswordType

  File "/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.C1A40A08-CC24-4914-BDB8-B6921D00AB5E/PyPDF2/_encryption.py", line 60, in <module>

    from Crypto.Cipher import AES, ARC4  # type: ignore[import]

  File "/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.C1A40A08-CC24-4914-BDB8-B6921D00AB5E/Crypto/Cipher/__init__.py", line 27, in <module>

    from Crypto.Cipher._mode_ecb import _create_ecb_cipher

  File "/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.C1A40A08-CC24-4914-BDB8-B6921D00AB5E/Crypto/Cipher/_mode_ecb.py", line 35, in <module>

    raw_ecb_lib = load_pycryptodome_raw_lib("Crypto.Cipher._raw_ecb", """

  File "/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.C1A40A08-CC24-4914-BDB8-B6921D00AB5E/Crypto/Util/_raw_api.py", line 309, in load_pycryptodome_raw_lib

    raise OSError("Cannot load native module '%s': %s" % (name, ", ".join(attempts)))

OSError: Cannot load native module 'Crypto.Cipher._raw_ecb': Not found '_raw_ecb.cpython-39-darwin.so', Cannot load '_raw_ecb.abi3.so': dlopen(/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.C1A40A08-CC24-4914-BDB8-B6921D00AB5E/Crypto/Util/../Cipher/_raw_ecb.abi3.so, 0x0006): tried: '/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.C1A40A08-CC24-4914-BDB8-B6921D00AB5E/Crypto/Util/../Cipher/_raw_ecb.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.C1A40A08-CC24-4914-BDB8-B6921D00AB5E/Crypto/Cipher/_raw_ecb.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), Not found '_raw_ecb.so' alf  

Link to comment
4 hours ago, pankajsz said:

Also would like to request for auto updater to be included in workflow

 

It's already included.

 

Any chance you have moved from an Intel Mac to an ARM Mac? Or maybe syncing Alfred between machines with both architectures? What Python version are you running?

 

I would advise you to delete the workflow and install it again. If it doesn't work I will need the input files that you can send me via PM.

Edited by xilopaint
Link to comment
12 hours ago, xilopaint said:

 

It's already included.

 

Any chance you have moved from an Intel Mac to an ARM Mac? Or maybe syncing Alfred between machines with both architectures? What Python version are you running?

 

No, I am using ARM machine and don't sync between machines. Python 2.7.1.8 installed at /opt/homebrew/bin/python

 

12 hours ago, xilopaint said:

 

I would advise you to delete the workflow and install it again. If it doesn't work I will need the input files that you can send me via PM.

Tried, the same error message. The files are just sample pdf files. I reverted back to Alfred PDF 3.0.0 for now and it works fine. Perhaps somebody else can try new version 4.1.1 and report their observation. 

Link to comment
On 8/1/2022 at 9:16 AM, pankajsz said:

 

No, I am using ARM machine and don't sync between machines. Python 2.7.1.8 installed at /opt/homebrew/bin/python

 

Tried, the same error message. The files are just sample pdf files. I reverted back to Alfred PDF 3.0.0 for now and it works fine. Perhaps somebody else can try new version 4.1.1 and report their observation. 

@xilopaint or others - any further feedback on this? 

Link to comment
10 hours ago, xilopaint said:

 

I can't debug the issue if you don't provide the files.

I can share the same but the problem persists with any files. I think it is not related to files. So was hoping to have feedback from another person. I will try on another machine and then revert later today.

Link to comment
On 8/4/2022 at 10:51 AM, pankajsz said:

I can share the same but the problem persists with any files. I think it is not related to files. So was hoping to have feedback from another person. I will try on another machine and then revert later today.

Same error on another machine as posted earlier. Not related to files as far as I understand. reverted to the Old version v3.0 which works well. 

Link to comment
11 minutes ago, xilopaint said:

 

Update (v4.2)

 

• New !diagnostic keyword.

Tried v4.2. I get error following error message for merge and other actions such as encrypt. Let me know if there are pre-requisite that I am missing. Can't interpret the message below. I am using macos 12.4, Alfred 5.0.1 [2067] on m1 max. would really like to use this workflow.

 

 

[06:16:19.102] Alfred PDF Tools[File Action] Processing complete

[06:16:19.103] Alfred PDF Tools[File Action] Passing output '(

    "/Users/xyz\U0259rbaycan Filial\U0131 \U018fsasnam\U0259.pdf",

    "/Users/xyz\U0259rbaycan Filial\U0131 S\U0327\U0259had\U0259tnam\U0259 .pdf"

)' to Arg and Vars

[06:16:19.104] Alfred PDF Tools[Arg and Vars] Processing complete

[06:16:19.104] Alfred PDF Tools[Arg and Vars] Passing output '' to Keyword

[06:16:22.419] Alfred PDF Tools[Keyword] Processing complete

[06:16:22.419] Alfred PDF Tools[Keyword] Passing output 'New' to Run Script

[06:16:22.556] ERROR: Alfred PDF Tools[Run Script] Traceback (most recent call last):

  File "/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.F5626124-7D80-45A1-A349-E413ADB69042/alfred_pdf_tools.py", line 48, in <module>

    from PyPDF2 import PdfReader, PdfWriter, PdfMerger, PageRange, PageObject, errors

  File "/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.F5626124-7D80-45A1-A349-E413ADB69042/PyPDF2/__init__.py", line 10, in <module>

    from ._encryption import PasswordType

  File "/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.F5626124-7D80-45A1-A349-E413ADB69042/PyPDF2/_encryption.py", line 60, in <module>

    from Crypto.Cipher import AES, ARC4  # type: ignore[import]

  File "/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.F5626124-7D80-45A1-A349-E413ADB69042/Crypto/Cipher/__init__.py", line 27, in <module>

    from Crypto.Cipher._mode_ecb import _create_ecb_cipher

  File "/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.F5626124-7D80-45A1-A349-E413ADB69042/Crypto/Cipher/_mode_ecb.py", line 35, in <module>

    raw_ecb_lib = load_pycryptodome_raw_lib("Crypto.Cipher._raw_ecb", """

  File "/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.F5626124-7D80-45A1-A349-E413ADB69042/Crypto/Util/_raw_api.py", line 309, in load_pycryptodome_raw_lib

    raise OSError("Cannot load native module '%s': %s" % (name, ", ".join(attempts)))

OSError: Cannot load native module 'Crypto.Cipher._raw_ecb': Not found '_raw_ecb.cpython-39-darwin.so', Cannot load '_raw_ecb.abi3.so': dlopen(/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.F5626124-7D80-45A1-A349-E413ADB69042/Crypto/Util/../Cipher/_raw_ecb.abi3.so, 0x0006): tried: '/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.F5626124-7D80-45A1-A349-E413ADB69042/Crypto/Util/../Cipher/_raw_ecb.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.F5626124-7D80-45A1-A349-E413ADB69042/Crypto/Cipher/_raw_ecb.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), Not found '_raw_ecb.so'

Link to comment
7 hours ago, pankajsz said:

Tried v4.2. I get error following error message for merge and other actions such as encrypt. Let me know if there are pre-requisite that I am missing. Can't interpret the message below. I am using macos 12.4, Alfred 5.0.1 [2067] on m1 max. would really like to use this workflow.

 

I told you two times before that you should send me the files.


Now, you should also paste the output of the new !diagnostic keyword.

Edited by xilopaint
Link to comment

Hey, same errors here on M1 Pro / with arm64.

I'm sure you have already noticed the incompatible dependency:

 

12 hours ago, pankajsz said:

/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.F5626124-7D80-45A1-A349-E413ADB69042/Crypto/Util/../Cipher/_raw_ecb.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/Users/xyz/Downloads/Alfred.alfredpreferences/workflows/user.workflow.F5626124-7D80-45A1-A349-E413ADB69042/Crypto/Cipher/_raw_ecb.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), Not found '_raw_ecb.so'

 

❯ file $(which python3)
/opt/homebrew/bin/python3: Mach-O 64-bit executable arm64


/usr/bin/env python3 links fine:


Python 3.9.13 (main, May 24 2022, 21:13:51)
[Clang 13.1.6 (clang-1316.0.21.2)] on darwin


### Workflow version
4.2
### Alfred version
5.0.1
### Python version
3.9.13
### PyCryptodome version
3.15.0
### macOS version
12.4
### Architecture
arm64

Link to comment
38 minutes ago, zeitlings said:

Hey, same errors here on M1 Pro / with arm64.

I'm sure you have already noticed the incompatible dependency

 

It seems to be related to this PyCryptodome issue.


Curiously, I did some tests with @giovanni a couple months ago and he managed to get it working on his ARM Mac. Maybe he was using Rosetta?


I don’t have an ARM Mac, btw.

Edited by xilopaint
Link to comment
32 minutes ago, xilopaint said:

 

It seems to be related to this PyCryptodome issue.


Curiously, I did some tests with @giovanni a couple months ago and he managed to get it working on his ARM Mac. Maybe he was using Rosetta?


I don’t have an ARM Mac, btw.

Is it a new component used in new version? The link above says "Pycryptodome cannot be loaded on M1 macs"

 

Alfred PDF older version v3.0 works fine on my ARM Mac. 

Link to comment
On 8/10/2022 at 3:43 PM, pankajsz said:

thanks @xilopaint The merge worked well with v4.2 and I am happy to get bookmarks of individual files! 

 

Could you please download this PDF file and run the Decrypt file action on it? The password is asdfzxcv.

 

In the process you should be prompted to install PyCryptodome. You can accept it.

Edited by xilopaint
Link to comment

I was about to check back in to tell you that I tested v4.02 after reading pankajsz' comment and that it worked fine.

Testing v4.2 now. Cropping does work. Or better, did work. I now tried to decrypt your encb.pdf and was prompted to  pip install PyCryptodome, which I did. Now I get the previous incompatible architecture panic whatever I'm trying to do (progress, split, deskew,...).

 

Btw., before I tried the decrypt I tested the deskew for a minute and  the performance was irritatingly sub par. Is this a rosetta thing (Activity Monitor indicates the corresponding process to be of kind "Intel") or is it also kind of slow on x86_64?

 

Anyways, at least it's pretty safe to assume that pycrptodome is the culprit.

 

[21:34:19.337] ERROR: Alfred PDF Tools[Script Filter] Code 1: Traceback (most recent call last):
...
File "/Users/zeitlings/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.809C4DC3-843E-403D-8955-9DEF46A73157/Crypto/Util/_raw_api.py", line 309, in load_pycryptodome_raw_lib
    raise OSError("Cannot load native module '%s': %s" % (name, ", ".join(attempts)))
OSError: Cannot load native module 'Crypto.Cipher._raw_ecb': Not found '_raw_ecb.cpython-39-darwin.so', Not found '_raw_ecb.abi3.so', Cannot load '_raw_ecb.so': dlopen(/Users/zeitlings/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.809C4DC3-843E-403D-8955-9DEF46A73157/Crypto/Util/../Cipher/_raw_ecb.so, 0x0006): tried: '/Users/zeitlings/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.809C4DC3-843E-403D-8955-9DEF46A73157/Crypto/Util/../Cipher/_raw_ecb.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/Users/zeitlings/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.809C4DC3-843E-403D-8955-9DEF46A73157/Crypto/Cipher/_raw_ecb.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))

Link to comment
5 minutes ago, zeitlings said:

Testing v4.2 now. Cropping does work. Or better, did work. I now tried to decrypt your encb.pdf and was prompted to  pip install PyCryptodome, which I did. Now I get the previous incompatible architecture panic whatever I'm trying to do (progress, split, deskew,...).

 

Did you delete your previous installation of the workflow before downloading and install it again?

Link to comment
5 hours ago, zeitlings said:

Nope, I "updated" it on import what seems to replace whatever was there before – at least with regard to the files. I imported the same workflow again and the Crypto stuff got wiped. Now most of the functionality is restored. 

 

It confirms the issue is related to pip not installing PyCryptodome binaries for the ARM architecture. I can’t do anything about it, since it’s a PyCryptodome issue that seems to have already been reported.

 

In any case, the workflow will only prompt you to install PyCryptodome if you try to decrypt a PDF file encrypted with AES or RC4 standards.

 

I'm still curious to know what @giovanni did to get it to work on his ARM Mac.

Edited by xilopaint
Link to comment
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...