Bookmark destination gang stalking electronic harassment implants

GSEHi.com > computing > problems > Bookmark destination

Problem

I want a bookmark destination of type fit window for every bookmark in all my PDFs.

Solution

I use label colors to classify the PDFs.

There’s a problem with the AppleScript support: if you ask for the number of bookmarks then it returns a number which is 1 too high.

If you choose Fit Window in the dialog then this corresponds to fit page in the AppleScript support.

1. Search problematic PDFs

I give a PDF a blue label to indicate that there’s no problem. If the bookmarks are not shown then it gets a red label. If a bookmark is not fit window then it gets a pink label. If a bookmark has a named destination then it gets a green label. Named destinations cannot be changed on Traditional Mac OS and the PDF will remain uncorrected.

on run
        CheckPDFs()
end run

on CheckPDFs()
        local aW, pb, fp, fw, d, a, aBM, hasChanged, v, i, t
        
        tell application "Acrobat"
                set aW to count of windows
                set pb to pages and bookmarks
                set fp to fit page
        end tell
        repeat with d from 1 to aW
                tell application "Acrobat"
                        set a to file alias of document d
                        set aBM to count bookmarks of document d
                end tell
                set hasChanged to false
                if aBM > 1 then
                        tell application "Acrobat"
                                set v to view mode of document d
                        end tell
                        if v ≠ pb then
                                MarkPDF(a, 2) -- red = bookmarks are not being shown.
                                set hasChanged to true
                        end if
                        repeat with i from 1 to aBM
                                try
                                        tell application "Acrobat"
                                                set t to fit type of bookmark i of document d
                                        end tell
                                        if t ≠ fp then
                                                MarkPDF(a, 3) -- pink = one bookmark is not fit window.
                                                set hasChanged to true
                                                set i to aBM
                                        end if
                                on error
                                        MarkPDF(a, 6) -- green = bookmark is named destination.
                                        set hasChanged to true
                                        set i to aBM
                                end try
                        end repeat
                end if
                if not hasChanged then
                        MarkPDF(a, 4) -- blue = OK.
                end if
        end repeat
end CheckPDFs

on MarkPDF(a, c)
        tell application "Finder"
                activate
                select file a
                set label index of selection to c
        end tell
end MarkPDF


2. Correct problematic PDFs

I give a PDF a blue label to indicate that there’s no problem. If the bookmarks are not shown then it gets a red label. I check this again to prevent that this gets forgotten. All bookmarks are changed to fit page even when they were already correct.

on run
        CheckPDFs()
end run

on CheckPDFs()
        local aW, pb, fp, d, a, aBM, hasChanged, v, i, t
        
        tell application "Acrobat"
                set aW to count of windows
                set pb to pages and bookmarks
                set fp to fit page
        end tell
        repeat with d from 1 to aW
                tell application "Acrobat"
                        set a to file alias of document d
                        set aBM to count bookmarks of document d
                end tell
                set hasChanged to false
                if aBM > 1 then
                        tell application "Acrobat"
                                set v to view mode of document d
                        end tell
                        if v ≠ pb then
                                MarkPDF(a, 2)
                                set hasChanged to true
                        end if
                        repeat with i from 1 to aBM
                                tell application "Acrobat"
                                        set fit type of bookmark i of document d to fp
                                end tell
                        end repeat
                end if
                if not hasChanged then
                        MarkPDF(a, 4)
                end if
        end repeat
end CheckPDFs

on MarkPDF(a, c)
        tell application "Finder"
                activate
                select file a
                set label index of selection to c
        end tell
end MarkPDF


3. Special bookmarks

If a bookmark has an URL then the script will stop with an error. Suppose that you saw in the event log that there was a problem with bookmark 4075. With the following script you can find the text of that bookmark.

on run
        tell application "Acrobat"
                set b to bookmark 4075 of document 1
                set n to name of b
        end tell
end run

Then you can change the bookmark destination manually.

© 2012-2018 Cliff Huylebroeck