Apply filter to all pages of pdf

This area contains the messages from the old Yahoo gcmac group after the port.
Post Reply
Robert Weaver
Posts: 0
Joined: Sun Jul 19, 2015 11:06 pm

Apply filter to all pages of pdf

Post by Robert Weaver »

Hello. I have scanned a 200 page document from an office copier to a pdf file. I now need to apply the Despeckle filter to all of the pages in the pdf file. I can't find a way of doing this, except to manually apply the filter to each page and then save the file each time. Is there an automatic way to have the filter applied to all pages?
Brian Christmas
Posts: 0
Joined: Thu Nov 18, 2010 10:02 pm

Re: Apply filter to all pages of pdf

Post by Brian Christmas »

G’day From the land of Oz, Robert.I’d use Applescript to automate the process.You’ll have to amend the number of pages in the start of the script, as Thorstens crew have gradually removed the ability of Applescript to work well with documents, and it no longer seems possible to get the number of pages of a document (errors), or window (always returns 1).Also, the window reference numbers alter. They really have made a hash of Applescript.Good luck, and post if it does not work.RegardsSantaset countOfPages to 10tell application "GraphicConverter 9" activate tell current application to delay 1 if ((name of document 1) ends with ".pdf") then # say (count of pages of window 1) as text repeat with eachPage from 1 to countOfPages # count of pages of window 1 tell application "System Events" to tell process "GraphicConverter 9" click menu item "Despeckle…" of menu 1 of menu bar item "Effect" of menu bar 1 delay 0.1 keystroke return delay 0.2 set tempName to name of (window 1) as text if tempName does not contain "Tools" then click button 2 of group 1 of window 1 --< '1' seems to sometimes revert to 'Tools' window else click button 2 of group 1 of window 2 end if try keystroke return end try end tell end repeat tell application "System Events" to tell process "GraphicConverter 9" keystroke "p" using command down delay 0.2 keystroke return end tell end ifend tellOn 20 Jul 2015, at 6:04 am, Robert Weaver electronbunker@ymail.com [gcmac] <gcmac@yahoogroups.com> wrote:Hello.I have scanned a 200 page document from an office copier to a pdf file. I now need to apply the Despeckle filter to all of the pages in the pdf file. I can't find a way of doing this, except to manually apply the filter to each page and then save the file each time. Is there an automatic way to have the filter applied to all pages?
thorstenlemke
Posts: 0
Joined: Fri Dec 30, 2016 12:00 pm

Re: Apply filter to all pages of pdf

Post by thorstenlemke »

Dear Robert,sorry, that is not possible, yet.I add that to the todo list.Thorsten Hello.I have scanned a 200 page document from an office copier to a pdf file. I now need to apply the Despeckle filter to all of the pages in the pdf file. I can't find a way of doing this, except to manually apply the filter to each page and then save the file each time. Is there an automatic way to have the filter applied to all pages?
Brian Christmas
Posts: 0
Joined: Thu Nov 18, 2010 10:02 pm

Re: Apply filter to all pages of pdf

Post by Brian Christmas »

G’day again, Robert.Thanks to some help from the Applescript Users Group, particularly Shane Stanley and Yvan Koenig, here’s a more complete script that will automatically count the pages of a user selected .pdf file, despeckle each page, and save each (or at least, it should). I haven’t a ‘speckled’ .pdf to test it on, only a 10 page non-scanned document.RegardsSantause framework "Foundation"use framework "Quartz"use scripting additionsproperty countOfPages : 10my processFile()on processFile() tell application "System Events" set aFile to choose file with prompt "Please choose a .pdf file." of type {"pdf"} without invisibles end tell set posixPath to POSIX path of aFile set anNSURL to current application's class "NSURL"'s fileURLWithPath:posixPath set thePDFDoc to current application's PDFDocument's alloc()'s initWithURL:anNSURL set my countOfPages to thePDFDoc's pageCount() tell application "GraphicConverter 9" activate silentopen aFile tell current application to delay 1 if ((name of document 1) ends with ".pdf") then # say (count of pages of window 1) as text repeat with eachPage from 1 to my countOfPages # count of pages of window 1 tell application "System Events" to tell process "GraphicConverter 9" click menu item "Despeckle…" of menu 1 of menu bar item "Effect" of menu bar 1 delay 0.1 keystroke return delay 0.2 set tempName to name of (window 1) as text if tempName does not contain "Tools" then click button 2 of group 1 of window 1 --< '1' seems to sometimes revert to 'Tools' window else click button 2 of group 1 of window 2 end if # Click the 'Save' button of save changes dialog try keystroke return end try end tell end repeat # Now, save last page tell application "System Events" to tell process "GraphicConverter 9" keystroke "s" using command down try keystroke return end try end tell end if end tellend processFileOn 20 Jul 2015, at 6:04 am, Robert Weaver electronbunker@ymail.com [gcmac] <gcmac@yahoogroups.com> wrote:Hello.I have scanned a 200 page document from an office copier to a pdf file. I now need to apply the Despeckle filter to all of the pages in the pdf file. I can't find a way of doing this, except to manually apply the filter to each page and then save the file each time. Is there an automatic way to have the filter applied to all pages?
rsw00001
Posts: 0
Joined: Mon Jul 20, 2015 9:50 pm

Re: Apply filter to all pages of pdf

Post by rsw00001 »

Thanks for confirming that. I was afraid that I had missed something somewhere.
rsw00001
Posts: 0
Joined: Mon Jul 20, 2015 9:50 pm

Re: Apply filter to all pages of pdf

Post by rsw00001 »

Thank you for going to all the trouble Brian. I'll give this a test as soon as I have a chance.I've done a lot of programming in a lot of different languages (including ones with such arcane syntax and structure as LISP and Forth). But I have never been able to get past the vagueness of Applescript, which forces me to leave it as a last resort. So, I really appreciate this.I've been wondering if Apple intends to continue supporting Applescript. I haven't heard much about it in recent years. And now, a lot of applications can be controlled from the command line in the terminal, making it possible to script them with various Unix automation utilities.
thorstenlemke
Posts: 0
Joined: Fri Dec 30, 2016 12:00 pm

Re: Apply filter to all pages of pdf

Post by thorstenlemke »

Attachments :Dear Robert,sorry for the delay.I added now Despeckle as batch action.So, you can process all pages in convert&modify.http://www.lemkesoft.org/beta.htmlThorsten Hello.I have scanned a 200 page document from an office copier to a pdf file. I now need to apply the Despeckle filter to all of the pages in the pdf file. I can't find a way of doing this, except to manually apply the filter to each page and then save the file each time. Is there an automatic way to have the filter applied to all pages?__.
Post Reply