Support Go To Page +/- Relative

Support Go To Page +/- Relative

Request:
The Go To Page function should support simple relative operators such as + and -.

  • +20 should move forward 20 pages.
  • -15 should move backward 15 pages.
  • Minus amount below range of first page should go to first page.
  • Plus amount above range of last page should go to last page.

Welcome @_joe

Thanks for your suggestions. While I can’t promise implementation, be assured they have been noted by development for future consideration. Cheers!

Although it’s possible I’m wondering in which use cases would this be useful?

In my case, I read mostly technical manuals. I’m often jumping pages a lot with the spacebar.

If I want to move 2 pages forward because one is intentionally blank, for example, there’s no guarantee how many spacebar keys that takes due to zoom level, and I don’t end up at the top of the desired page.

If I could do a Cmd+Opt+Shift+P then type +2 in the box, that would be clean, easy and very useful.

You could try this script.

-- Go to PDF page +/- relative

tell application id "DNtp"
	try
		if not (exists think window 1) then return
		
		set theRecord to content record of think window 1
		if theRecord = missing value then return
		
		set theRecord_Type to (type of theRecord) as string
		if theRecord_Type is in {"PDF document", "«constant ****pdf »"} then
			activate
			set thePageOffset to display name editor "Go to PDF page +/- relative"
			set theCurrentPage to (current page of think window 1) + 1
			set theDestinationPage to theCurrentPage + thePageOffset
			set theRecord_PageCount to page count of theRecord
			
			if theDestinationPage < 0 then
				set theDestinationPage to 1
			else if theDestinationPage > theRecord_PageCount then
				set theDestinationPage to theRecord_PageCount
			end if
			
			do shell script "open " & quoted form of ((reference URL of theRecord) & "?page=" & (theDestinationPage - 1))
		end if
		
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
		return
	end try
end tell

Seems it would be useful if current page could be also set :slight_smile:

1 Like

And that will make the script much simpler (requires of course the next release):

tell application id "DNtp"
	try
		if not (exists think window 1) then return
		set theWindow to think window 1
		set theRecord to content record of theWindow
		if theRecord is not missing value and type of theRecord is PDF document then
			set thePageOffset to display name editor "Go to PDF page +/- relative"
			set current page of theWindow to (current page of theWindow) + (thePageOffset as integer)
		end if
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
	end try
end tell
2 Likes