sumatrapdf icon indicating copy to clipboard operation
sumatrapdf copied to clipboard

Is it possible to provide command line arguments like "-line" later?

Open tyf2018 opened this issue 2 years ago • 1 comments

I searched the PDF with PowerGREP5 and added SumatraPDF-64.exe as an external editor. When calling SumatraPDF-64.exe to open the target pdf file, I want to jump directly to the line containing the search keyword.

The -page command works fine, but I want to jump to the current line. Is it possible to provide command line arguments like "-line" later?

Best regards.

tyf2018 avatar Aug 28 '22 04:08 tyf2018

Not as such, Although PDF has "lines" of letters, the internals do not store words or lines like a word processor, so the address of each letter or line grouping is defined in cartesian XY co-ordinates (origin lower left) e.g. part way down a line may start at 36.000, 504.000 etc which if units are default is 1/2" in and 7" up

SumatraPDF is multi format rendering and thus uses an image origin of upper left pixel, thus even if you knew the co-ord it needs Y reversal (height-Y)

So getting the XY start and end is not easy (mutool might help) but that then needs further calculation per variable page height. Not impossible in an external app like the command line, but not trivial without custom math.

For simplicity SumatraPDF uses "scroll" or "search" either via CMD or DDE

-scroll <x,y> : Scrolls to the given coordinates for the first indicated file. Combine with -reuse-instance if the document is already open.

Scroll can only function in some cases, such as zoom in first and/or with continuous view, however search first word on page can be variable too, as $tringLiterals may not be what they appear to be.

Using Chrome or Edge ensure your Browser window is narrow (say half a standard screen width) then try https://africau.edu/images/default/sample.pdf#page=2&zoom=200,200,130 it should be focused on the text "page 1" image

So in FireFox NOT Chrome we can use https://africau.edu/images/default/sample.pdf#page=2&search=%22page%201%22 image

in SumatraPDF we can try similar (SumatraPDF can read https....PDF but only from internal file open or internal links, not command line)

curl -O https://africau.edu/images/default/sample.pdf && sumatrapdf -page 2 -search "page 1" "sample.pdf"

image

GitHubRulesOK avatar Aug 28 '22 10:08 GitHubRulesOK

PDF files do not have a concept of lines

kjk avatar Oct 07 '22 19:10 kjk