Jump to content

Alfred PDF Tools – Optimize, encrypt and manipulate PDF files


Recommended Posts

18 minutes ago, 2pilvic said:

The flow stopped working for me and I don't know what could have happened. I reinstalled macOs and it hasn't worked since. The mistake is:

 

ERROR: Alfred PDF Tools[Run Script] xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

 

The /Library/Developer/CommandLineTools/usr/ folder only contains the “share” and “lib” folders

I'd appreciate your help

 

You just need to install Command Line Tools. Run this command in Terminal:

 

xcode-select --install

Link to comment
17 hours ago, xilopaint said:

Could you explain further how the feature would work and why you need it? Would the text file be a simple .txt file?

It is extraction of pdf bookmarks into text and excel file with same filename with bookmark as suffix. I posted Python code for it in a separate thread and have been able to make it work via Alfred. When I am reading large technical pdf document, I extract bookmark into excel, allocate time to topics, exercises and then work on the document. I also take some notes if needed in excel file.

Link to comment
14 hours ago, TomBenz said:

It is extraction of pdf bookmarks into text and excel file with same filename with bookmark as suffix. I posted Python code for it in a separate thread and have been able to make it work via Alfred. When I am reading large technical pdf document, I extract bookmark into excel, allocate time to topics, exercises and then work on the document. I also take some notes if needed in excel file.

 

Where's the code?

Link to comment
7 hours ago, xilopaint said:

 

Where's the code?

import sys

query = sys.argv[1]
sys.stdout.write(query)
print(query)
filename = query
# -*- coding: utf-8 -*-
"""
Created on Mon Jan  2 13:45:57 2023

@author: khale
"""
#Extract bookmark from PDF and export to excel
# openpyxl and PyMuPDF are needed
from openpyxl import Workbook
import fitz
import os
import subprocess, platform
doc = fitz.open(filename)
toc = doc.get_toc()
if len(toc) >0 :
    wb = Workbook()
    ws = wb.active
    ws.title = "Bookmarks"
    ws.cell(1,1).value= "Bookmark"
    ws.cell(1,2).value= "Pages"
    for i in range(0, len(toc)):
        ws.cell(i+2,1).value =toc[1]
        ws.cell(i+2,2).value =toc[2]
    Bookmark_filename = filename[:-4] +" BookMark.xlsx"
    wb.save(Bookmark_filename)
    #Open excel
    #os.system(f'start excel.exe "{Bookmark_filename}"')
    if platform.system() == 'Darwin':  # macOS
            subprocess.call(('open', Bookmark_filename))
    elif platform.system() == 'Windows':  # Windows
            os.startfile(Bookmark_filename)
    else:  # linux variants
            subprocess.call(('xdg-open', Bookmark_filename))
else:
    #No bookmark in the PDF
    print("no Bookbark was found")

Link to comment
  • 2 months later...

@xilopaint Hi. I runed optimize command and get the failed notification. Can you please check and help me to fix:

Info:

  • Workflow version
    • 4.2
  • Alfred version
    • 5.0.6
  • Python version
    • 3.11.2
  • PyCryptodome version
    • Not Installed
  • macOS version
    • 13.3
  • Architecture
    • i386

 

Debug:

[16:56:19.805] Alfred PDF Tools[File Action] Processing complete

[16:56:19.809] Alfred PDF Tools[File Action] Passing output '/Users/chumido/Dropbox/Mac/Downloads/Tài liệu kết nối APi TMDT (5).pdf' to Arg and Vars

[16:56:19.810] Alfred PDF Tools[Arg and Vars] Processing complete

[16:56:19.811] Alfred PDF Tools[Arg and Vars] Passing output '' to Keyword

[16:56:25.339] Alfred PDF Tools[Keyword] Processing complete

[16:56:25.344] Alfred PDF Tools[Keyword] Passing output '50' to Replace

[16:56:25.346] Alfred PDF Tools[Replace] Processing complete

[16:56:25.347] Alfred PDF Tools[Replace] Passing output '50' to Run Script

[16:56:25.962] STDERR: Alfred PDF Tools[Run Script] .

16:56:25 workflow.py:2278 DEBUG    ---------- Alfred PDF Tools (4.2.0) ----------

16:56:25 workflow.py:1681 DEBUG    reading settings from /Users/chumido/Library/Application Support/Alfred/Workflow Data/com.xilopaint.alfredapp.pdftools/settings.json

16:56:25 workflow.py:2683 DEBUG    update check not due

16:56:25 workflow.py:1904 DEBUG    loading cached data: /Users/chumido/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/com.xilopaint.alfredapp.pdftools/__workflow_latest_version.pickle

16:56:25 workflow.py:2609 DEBUG    set last run version: 4.2.0

16:56:25 workflow.py:2322 DEBUG    ---------- finished in 0.299s ----------

Edited by chumido
Link to comment
2 minutes ago, chumido said:

 

It did not show in system setting when i runed command. just a notification said failed. Maybe i miss something?

 

Delete the workflow, install it again and run the Optimize File Action in your file.

Edited by xilopaint
Link to comment
  • 4 weeks later...
  • 2 weeks later...
  • 1 month 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...