Hi,
I have been using this script for a while.
I first started using it on Linux, then got it working on Mac OS Monterey.
I have made some changes and thought I would share it with all of you.
For this terminal command to work, You will need to install HomeBrew.
I understand This may be a little confusing, or scary if you are not familiar 
with using the terminal, but it is not that bad. Just copy and paste some 
commands in the terminal to get things setup, then just run the script, also 
known as the command to convert your file.
I named the script PDF-Converter.command.
I took the .text file and renamed it to .command
After everything is installed, Here is how I use it.
1 I copy the PDF file to the clipboard
2 I open the PDF-Converter.command file or to make it even better, I assigned 
it a VoiceOver commander.
3 The script will ask you to paste the path of the PDF file.
So press command+V then hit the enter key.
When the file is converted, it will tell you to press enter.
The folder containing the file should open.
By default, it is in your user folder/PDF-Converter/PDF.txt.

Please note:
The number sign at the beginning of a line, tells the terminal to ignore that 
line.
I put the number sign on the lines that tells the terminal to play a sound. I 
did this because you will not have the same audio files and locations on your 
Mac, and this would give you an error.
If you want to know more, contact me offline.
mr.robertc...@icloud.com


Code starts below:

#!/bin/sh
#This script depends on installing 3 programs in the terminal on Mac
#1 Homebrew
#2 tesseract was already installed
#3 poppler brew install poppler

# Last edited
#  December 29, 2024 
#afplay /Users/robert/Music/Other/Computer_Magic.m4a
mkdir PDF-Converter 
cd ~/PDF-Converter &&
echo "Paste or Enter the path of the PDF to be converted to text."
read link
mkdir Images &&
pdftoppm -jpeg "$link" -r 300 ~/PDF-Converter/Images/pdf.jpg &&
Say "Please wait while I process your file"
sleep 4 &&
find ~/PDF-Converter/Images/*.jpg -type f >files.txt
sleep 4
Say "Performing OCR on images" &&
tesseract ~/PDF-Converter/files.txt PDF &&
rm -r Images &&
rm files.txt &&
#afplay /Users/robert/Library/Sounds/Computer_Magic-Microsift-1901299923.mp3  &
sleep 4
Say "Your file is ready, press enter to continue"
echo "Your file is ready, Press enter to continue"
read answer
open ~/PDF-Converter
killall Terminal


-- 
The following information is important for all members of the Mac Visionaries 
list.

If you have any questions or concerns about the running of this list, or if you 
feel that a member's post is inappropriate, please contact the owners or 
moderators directly rather than posting on the list itself.

Your Mac Visionaries list moderator is Mark Taylor.  You can reach mark at:  
mk...@ucla.edu and your owner is Cara Quinn - you can reach Cara at 
caraqu...@caraquinn.com

The archives for this list can be searched at:
http://www.mail-archive.com/macvisionaries@googlegroups.com/
--- 
You received this message because you are subscribed to the Google Groups 
"MacVisionaries" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to macvisionaries+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/macvisionaries/9FE80689-229D-455B-B60E-433E03EF8865%40icloud.com.

Reply via email to