Lutze
Lutze

Reputation: 11

How can I open a pdf in Edge like in Internet-Explorer with args search tag from command line?

@echo off START /max iexplore.exe http://stwfue/svn/y//4cs-gw/51_integration/product_systems/ecad/CP4/tags/cp4_v01_t05/result/pdf/Y_4CS-GW_SP4.pdf#search=Fensterkomparator

Upvotes: 1

Views: 3112

Answers (2)

K J
K J

Reputation: 11841

Edge PDF reader is not Acrobat so only a subset of Adobe URLs appear to be available. That situation is currently changing and may even get worse as Chromium PDF Viewer based on Foxit code is in progress towards a newer "Powered by Acrobat" (Lite) variant. The new Edge Acrobat plug-in currently seems to ignore many of the older Explorer ActiveX commands.

The old Acrobat version 8 list of options for Internet Explorer URL "#fragments" is currently easiest found at https://pdfobject.com/pdf/pdf_open_parameters_acro8.pdf

As a side comment, my Acrobat Reader will accept #page or #nameddest but not #search because of my security settings to block actions.

"#search=wordList Opens the Search UI and performs a search for the specified word list in the document."

The correct default to call Edge is something like this, so for 32bit without the (x86)

"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" "file:///C:/users/name/downloads/PDFOpenParameters.pdf#zoom=200&nameddest=Resources"

Note the order here in Edge is zoom first but the nameddest is on page 3 which is respected HOWEVER the destination is not showing ! But If I reverse order the zoom is not actioned, yet again your mileage may vary.

enter image description here

Each viewer may handle a different range of actions so Chrome/Edge does NOT currently "search" but Mozilla/Firefox/PDF.JS does.

[Update]

SumatraPDF could in the past be scripted to search via vbs, but that is no longer needed in latest 3.4 Pre-release as -search has been added to command line options, and can be mixed with others for example:-

curl -o sample.pdf https://africau.edu/images/default/sample.pdf & SumatraPDF.exe -zoom "fit width" -page 1 -search "continued from page 1" "sample.pdf"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3028  100  3028    0     0   3028      0  0:00:01 --:--:--  0:00:01  4723

enter image description here

Answer

For Edge You can do something with "sendkeys" in a VB or JScript to open file as an app and run a search using F3, however since there is no indication of the code application I leave that part to individual use case. However Arguments for Parameters can be easily added in VBS. My own preference is to use a sendkeys.exe that uses arguments a different way.

To show how this answers the question let us presume we have curled this page down as Y_4CS-GW_SP4.PDF then wish to do the desired search.

Set objShell = CreateObject("WScript.Shell")

EdgePath = """C:\Program Files\Microsoft\Edge\Application\msedge.exe"""
pdfFile = """ --app=C:\Users\lez\Downloads\Y_4CS-GW_SP4.pdf"""
command = EdgePath & " " & pdfFile
msgbox command
objShell.Run command, 1, False

' Wait for Adobe Edge Reader to open
WScript.Sleep 1000

objShell.AppActivate("pdfFile")

WScript.Sleep 1000
' Open in search mode
objShell.SendKeys("{F3}")
WScript.Sleep 500
objShell.SendKeys("fensterkomparator")

Result enter image description here

Upvotes: 1

Yu Zhou
Yu Zhou

Reputation: 12981

Edge now uses the chromium engine and you can find an open issue on chromium project:

Issue 792647: Implement "search" PDF Open Parameter in PDF Viewer

"search" parameter is not implemented in Edge/Chrome PDF viewer, so you can't use it in Edge.

I suggest that you can star the issue to add a vote. Besides, you can raise a feature request about adding "search" parameter by pressing Alt+Shift+I in Edge. Edge team will check the feedback and improve the product continuously. Thanks for your understanding.

Upvotes: 1

Related Questions