Hi, I've written a this applescript taking code from lots of places over the web, that allows me to extract all the pages of a PDF ebook with DRM, and save them as images files. The bad things about this sBooks is that is has so many restriccions that it almost makes it unusable like: have to "Authorize" each computer (which need to be conected to the internet), can print only 20 pages per month, can't open file in Linux and so on.
So I wrote this Script that basically what it does is: it opens the PDF file using Acrobat Reader and takes a screenshot of every and saves them in a Image Files, so then I can do what every I want with "My Book". I could have done this manually but since and new to macs I thought I would be a good opetunity to write my first appliscript.
It looks like this:
/////////////////////////////////////////////////////////
(*
Set Acrobat Reader as default app to open file
*)
set PDF to choose file
display dialog "Number of pages to be converted:" default answer 1
copy the result as list to {numberPages}
set picFolder to choose folder
tell application "Finder" to open PDF
delay 20
tell application "System Events"
keystroke "l" using command down --fullscreen mode
delay 5
keystroke "-" using {shift down, command down} --turn page counter clockwise
delay 5
end tell
--property N : 0
set N to 0
set nPic to 0
repeat while nPic < numberPages --number of pages
set N to N + 1
set picPath to ((POSIX path of picFolder) & "Picture_" & N & ".png") as string
do shell script "screencapture -tjpg " & quoted form of picPath
set nPic to nPic + 1
tell application "System Events" to key code 124 using command down --right arrow
delay 1
end repeat
tell application "System Events" to keystroke "q" using command down
set dialogResult to display dialog "Convertion Done, want to view files?"
if button returned of dialogResult is "OK" then
tell application "Finder"
open folder picFolder
end tell
end if
/////////////////////////////////////////////////////////
So, I've got this to work almost as I wanted, but to make the process of converting the DRMed eBook into a image PDF simpler, I made an automator workflow that rotates each screenshots, crops it( to eliminate the black space in the image) and puts all them into a single PDF file.
I have tested the script and the workflow separately and they both work, but when I insert the Script into the workflow (to make just one app) as the first step, I got an error when I run the workflow, it says that there is a problem with the script.
The work flow looks like this:
/////////////////////////////////////////////////////////
"Script" (workflow gets stock here)
"As for finder items"
"Copy finder items" (in case I mess it up)
"Rotate images"
"Crop image"
"New PDF from files"
/////////////////////////////////////////////////////////
Can anyone give me a hand with this one? I want to put this script and the workflow to work together.
Man, that's the longest post I've ever written!
So I wrote this Script that basically what it does is: it opens the PDF file using Acrobat Reader and takes a screenshot of every and saves them in a Image Files, so then I can do what every I want with "My Book". I could have done this manually but since and new to macs I thought I would be a good opetunity to write my first appliscript.
It looks like this:
/////////////////////////////////////////////////////////
(*
Set Acrobat Reader as default app to open file
*)
set PDF to choose file
display dialog "Number of pages to be converted:" default answer 1
copy the result as list to {numberPages}
set picFolder to choose folder
tell application "Finder" to open PDF
delay 20
tell application "System Events"
keystroke "l" using command down --fullscreen mode
delay 5
keystroke "-" using {shift down, command down} --turn page counter clockwise
delay 5
end tell
--property N : 0
set N to 0
set nPic to 0
repeat while nPic < numberPages --number of pages
set N to N + 1
set picPath to ((POSIX path of picFolder) & "Picture_" & N & ".png") as string
do shell script "screencapture -tjpg " & quoted form of picPath
set nPic to nPic + 1
tell application "System Events" to key code 124 using command down --right arrow
delay 1
end repeat
tell application "System Events" to keystroke "q" using command down
set dialogResult to display dialog "Convertion Done, want to view files?"
if button returned of dialogResult is "OK" then
tell application "Finder"
open folder picFolder
end tell
end if
/////////////////////////////////////////////////////////
So, I've got this to work almost as I wanted, but to make the process of converting the DRMed eBook into a image PDF simpler, I made an automator workflow that rotates each screenshots, crops it( to eliminate the black space in the image) and puts all them into a single PDF file.
I have tested the script and the workflow separately and they both work, but when I insert the Script into the workflow (to make just one app) as the first step, I got an error when I run the workflow, it says that there is a problem with the script.
The work flow looks like this:
/////////////////////////////////////////////////////////
"Script" (workflow gets stock here)
"As for finder items"
"Copy finder items" (in case I mess it up)
"Rotate images"
"Crop image"
"New PDF from files"
/////////////////////////////////////////////////////////
Can anyone give me a hand with this one? I want to put this script and the workflow to work together.
Man, that's the longest post I've ever written!