Will this work with msEdge and Google Chrome for Testing?
Hi,
I'm trying this chromic_pdf on WIndows10 with Google Chrome for Testing as well as msEdge.
I have downloaded a local copy of Chrome for Testing, and stored the Chrome.exe location in my system PATH: C:\Tools\chrome-win64\Chrome.exe
I am unable to load beyond this error:
01:04:41.145 [error] GenServer #PID<0.2959.0> terminating
** (ChromicPDF.Connection.ConnectionLostError) Chrome has stopped or was terminated by an external program.
If this happened while you were printing a PDF, this may be a problem with Chrome itelf.
If this happens at startup and you are running inside a Docker container with a Linux-based
image, please see the "Chrome Sandbox in Docker containers" section of the documentation.
Either way, to see Chrome's error output, configure ChromicPDF with the option
discard_stderr: false
(chromic_pdf 1.15.2) lib/chromic_pdf/pdf/connection/local.ex:53: ChromicPDF.Connection.Local.handle_info/2
(stdlib 5.2.3) gen_server.erl:1095: :gen_server.try_handle_info/3
(stdlib 5.2.3) gen_server.erl:1183: :gen_server.handle_msg/6
(stdlib 5.2.3) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
Last message: {:DOWN, #Reference<0.458662647.298582017.191736>, :port, #Port<0.8>, :normal}
For msEdge (also a Chromium based browser), which comes bundled on windows 10,11 and windows-server 2019+, I tried adding msedge.exe to @default_executables
@default_executables [
"chromium-browser",
"chromium",
"chrome.exe",
"msedge.exe",
"google-chrome",
"/usr/bin/chromium-browser",
"/usr/bin/chromium",
"/usr/bin/google-chrome",
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
"/Applications/Chromium.app/Contents/MacOS/Chromium"
]
Please can you guide on how to troubleshoot the above two scenarios.
Thanks
You can pass in a custom chrome_executable option to specify an alternative chrome path (e.g. in your application.ex as described here):
https://hexdocs.pm/chromic_pdf/ChromicPDF.html#module-custom-command-line-switches
But I doubt that msEdge will work, since we rely on command line options to pass into chrome, which will most likely be different for msEdge. But adding the chrome_executable: "C:\Tools\chrome-win64\Chrome.exe" will most likely work.
One note here is that most contributors to this codebase work with Linux or MacOS, so the Windows support might be somewhat less often tested. But we already heard of users being successful with it.
Thanks for your response.
I have applied chrome_executable: "C:\Tools\chrome-win64\Chrome.exe"
config :demo, :chromic_pdf,
discard_stderr: false,
chrome_executable: "C:/Tools/chrome-win64/Chrome.exe"
it comes up with the same errors:
09:41:25.298 [error] GenServer #PID<0.561.0> terminating
** (ChromicPDF.Connection.ConnectionLostError) Chrome has stopped or was terminated by an external program.
If this happened while you were printing a PDF, this may be a problem with Chrome itelf.
If this happens at startup and you are running inside a Docker container with a Linux-based
image, please see the "Chrome Sandbox in Docker containers" section of the documentation.
Either way, to see Chrome's error output, configure ChromicPDF with the option
discard_stderr: false
(chromic_pdf 1.15.2) lib/chromic_pdf/pdf/connection/local.ex:53: ChromicPDF.Connection.Local.handle_info/2
(stdlib 5.2.3) gen_server.erl:1095: :gen_server.try_handle_info/3
(stdlib 5.2.3) gen_server.erl:1183: :gen_server.handle_msg/6
(stdlib 5.2.3) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
Last message: {:DOWN, #Reference<0.2340099235.2257846276.60362>, :port, #Port<0.7>, :normal}
Have you tried running the downloaded chrome yourself? Does it run?
If you run chromic_pdf, do you see the instance of chrome coming up in the task manager?
The message that you are seeing is chromic_pdf getting a message from the port that the chrome process died.
To me it looks more like chrome crashes and less like it is not found, since I would expect a different error in that case (maybe experiment by setting the chome_executable to something not existing to see if that would return a different error).
Going to close this for now. @CharlesOkwuagwu please re-open if you have further questions.
This simple config launches msEdge
port =
Port.open(
{:spawn_executable, "C:\\Windows\\System32\\cmd.exe"},
[
:binary,
:exit_status,
:stderr_to_stdout,
:hide,
{:args,
[
"/c",
"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe",
"--remote-debugging-port=9222",
"--headless"
]}
]
)