sumatrapdfreader / sumatrapdf

SumatraPDF reader
http://www.sumatrapdfreader.org
GNU General Public License v3.0
13.36k stars 1.7k forks source link

Get the position in the page #4497

Open H5820121 opened 2 weeks ago

H5820121 commented 2 weeks ago

I want to do an extension (in AHK language) for SumatraPDF, temporary bookmarks for the active PDF doc, and the extension will be enabled through the ExternalViewers, for this I need my extension to receive besides the page number also the position in the page, so that the bookmark also will include the position in the page (and so the extension can later also restore the position in the document by SumatraPDF.exe -scroll <x,y>). Is there any way to get the position in the page through the ExternalViewers?

GitHubRulesOK commented 2 weeks ago

no only page number but ahk has mousse screen reader used by others perhaps via measure "m" dialog

kjk commented 2 weeks ago

I would rather add it to Sumatra via commands, but you would have to explain what and why.

We already have CmdNavigateBack and CmdNavigateForward.

I could e.g. add CmdNavigateMark or CmdNavigateRemeber that adds navigation point.

And maybe a way to navigate navigation history with interface similar to command palette.

Or maybe I should improve the UI for bookmarks to allow more use cases.

H5820121 commented 2 weeks ago

@kjk "We already have CmdNavigateBackCmdNavigateForward" The "CmdNavigateBackCmdNavigateForward" command restores ALL the pages that I've been there even pages that I have no interest in returning to, but with my extension I can mark only the important pages to which I would like to return. And I'd also like to be able to go back not only to the same page but also (when the document is on Zoom) whether it's at the bottom of the page or in the middle or at the top of the page or on the right or left side, for this I need my extension to receive (through the ExternalViewers) besides the page number also the position in the page, so that the bookmark that created by my extension will also include the position in the page (and so the extension can later restore also the position in the document by SumatraPDF.exe -scroll <x,y>) Thanks!

‫בתאריך יום א׳, 25 באוג׳ 2024 ב-13:01 מאת ‪Krzysztof Kowalczyk‬‏ <‪ @.***‬‏>:‬

I would rather add it to Sumatra via commands, but you would have to explain what and why.

We already have CmdNavigateBack and CmdNavigateForward.

I could e.g. add CmdNavigateMark or CmdNavigateRemeber that adds navigation point.

And maybe a way to navigate navigation history with interface similar to command palette.

Or maybe I should improve the UI for bookmarks to allow more use cases.

— Reply to this email directly, view it on GitHub https://github.com/sumatrapdfreader/sumatrapdf/issues/4497#issuecomment-2308759864, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZFMFTBPQPXTRF5SRAS7LD3ZTGTQJAVCNFSM6AAAAABNCIFQYOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBYG42TSOBWGQ . You are receiving this because you authored the thread.Message ID: @.***>

GitHubRulesOK commented 2 weeks ago

@H5820121 this was done in the past by Nod5 for bookmarks and annotations so time has changed with added features and thus now abandonware, but look at their offerings to see what they did. Your request is a duplicate of your and his requests.

One of the major problems is that mouse is only for screen NOT always source page co-ordinates as PDF has inbuilt /UserUnits and other formats use different page scaling see https://github.com/sumatrapdfreader/sumatrapdf/issues/884

related https://github.com/sumatrapdfreader/sumatrapdf/issues/1411 https://github.com/sumatrapdfreader/sumatrapdf/issues/4397

H5820121 commented 2 weeks ago

@GitHubRulesOK "One of the major problems is that mouse is NOT always source page co-ordinates…" I have no interest in the position of the mouse, I just want to get the position of the page (when the active PDF doc is on zoom) so the temporary bookmark that created by my extension will also include the x y position of the page so that later my extension can return to the same page and position, NOT in another application but in SumatraPDF ITSELF by "SumatraPDF.exe -page -scroll <storedX,storedY>". And as mentioned, the "CmdNavigateBackCmdNavigateForward" restores ALL the pages that I've been there even pages that I have no interest in returning to, but with my extension I can mark only the important pages to which I would like to return.

‫בתאריך יום א׳, 25 באוג׳ 2024 ב-16:56 מאת ‪GitHubRulesOK‬‏ <‪ @.***‬‏>:‬

@H5820121 https://github.com/H5820121 this was done in the past by Nod5 for bookmarks and annotations so time has changed with added features and thus now abandonware, but look at their offerings to see what they did your request is a duplicate of your and his requests.

One of the major problems is that mouse is NOT always source page co-ordinates as PDF has inbuilt /UserUnits and other formats use different page scaling see #884 https://github.com/sumatrapdfreader/sumatrapdf/issues/884

related #1411 https://github.com/sumatrapdfreader/sumatrapdf/issues/1411

4397 https://github.com/sumatrapdfreader/sumatrapdf/issues/4397

— Reply to this email directly, view it on GitHub https://github.com/sumatrapdfreader/sumatrapdf/issues/4497#issuecomment-2308857490, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZFMFTAY6LXJMBCAA4FACCLZTHPAZAVCNFSM6AAAAABNCIFQYOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBYHA2TONBZGA . You are receiving this because you were mentioned.Message ID: @.***>

GitHubRulesOK commented 2 weeks ago

The core of the request is "the position of the page (when the active PDF doc is on zoom) " but exactly what is meant by that?

What I see is the page is potentially rotated or scaled by a viewport, at that point in time, on that device, with a variable frame. Thus highly variable for processing multiple values.

Whilst that viewport has a top left corner which is presumably your target, that is not the placement of a page, it is generally based in other PDF viewers by an origin at lower left (but never guaranteed as its just a default by convention) . MuPDF uses an imaging co-ordinate system for rendering thus the page datum is in their system top left. Thus always needs translation from image scaling into PDF co-ordinates, and complicated by multiple other factors related to scale units rotation transformations etc.

Certainly doable by somebody who has all the time to resolve all the calculations but is not a native output from a PDF reader usually a PDF editor will provide such functions. Thus Tracker XEDIT will provide such feedback for placing bookmarks etc.

H5820121 commented 2 weeks ago

@GitHubRulesOK "MuPDF uses an imaging co-ordinate system for rendering thus the page datum is in their system top left" Let it be so, for the purpose of my extension it does not matter because, as I said, I need it not for the purpose of another application, but for the need to later restore it in MuPDF itself.

‫בתאריך יום א׳, 25 באוג׳ 2024 ב-19:13 מאת ‪GitHubRulesOK‬‏ <‪ @.***‬‏>:‬

The core of the request is "the position of the page (when the active PDF doc is on zoom) " but exactly what is meant by that?

What I see is the page is potentially rotated or scaled by a viewport, at that point in time, on that device, with a variable frame. Thus highly variable for processing multiple values.

Whilst that viewport has a top left corner which is presumably your target, that is not the placement of a page, it is generally based in other PDF viewers by an origin at lower left. MuPDF uses an imaging co-ordinate system for rendering thus the page datum is in their system top left. Thus always needs translation from image scaling into PDF co-ordinates.

Certainly doable by somebody who has all the time to resolve all the calculations but is not a native output from a PDF reader usually a PDF editor will provide such functions. Thus Tracker XEDIT will provide such feedback for placing bookmarks etc.

— Reply to this email directly, view it on GitHub https://github.com/sumatrapdfreader/sumatrapdf/issues/4497#issuecomment-2308910155, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZFMFTGQ7WPIYZRL6ZRGL5TZTH7AXAVCNFSM6AAAAABNCIFQYOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBYHEYTAMJVGU . You are receiving this because you were mentioned.Message ID: @.***>