Forum moved here!

Home / Sumatra integration

Ramirez22

Hello.
First, of course, many thanks for this great job. I use it every days and it’s very pleasant.

I try to develop a software (on windows system, in WINDEV language) for make an EDM (for pleasure) with search motor, SQL database … and integrated PDF viewer.

At this time, all work perfectly except the viewer.
I tryed activeX from another PDF reader (Acrobat, Foxit, Xchange) but some are not convenient, some are too expensive for a simple leisure developpement.

So is it possible to integrate (easily) Sumatra in a third part app?
I need only the viewer part, no menu or tool bar.

Thanks for help.
Regards

GitHubRulesOK

I am not the developer, however he will almost certainly need some more info about intended usage.

Personal use in EDM fits with licensing
However deployment to others requires consideration of the licence requirements

SumatraPDF has a number of refinements ideal for use in a “kiosk” mode and you can switch off the menu, tabs and toolbar so that it appears as simply a framed window that can be driven in the background by an EDM either by DDE or CLI to a given page and scroll to given destinations.

Ramirez22

Hello.

Thanks for answer. That’s exactly what I looking for : use in a “kiosk” mode. But I don’t know how integrate Sumatra in my app.

With ActiveX, it’s easy : my developing tool can import and dialog with activeX and it’s easy to create wiever. I tryed to put thread of Sumatra in my windows handle, but Sumatra stay openand don’t redirect to the window.

I will search again, if I find a way, I will post the solution.

thanks agin for help.

GitHubRulesOK

SumatraPDF will accept command line calls that is the recommended way for integrating with many LaTeX editors

Historically it also runs as a DDE server and accepts DDE topics such as file open etc.

see the documentation for both methods https://www.sumatrapdfreader.org/docs/SumatraPDF-documentation.html

If you generate a window and know its handle number you can try

sumatrapdf.exe -plugin < hWnd > sample.pdf

(where ‘< hWnd >’ is a handle to the application window)

Ramirez22

Wow …
A… I’m a bit confused … One program line and thant work perfectly … amazing !
OK, try to reassemble myself :smile:

Before this last information, I tryed with a lot of unsucces to use User32 dll with a lot of EnumWindows, GetWindowThreadProcessId etc… I spent a lot of time (OK, less than one day :face_with_hand_over_mouth:) to make lot of test. Finally I sucessed after 3 sub procedure, 2 windows and 3 liters of coffee. And you annonce to me that only one line is enought !!!

More seriously, that exactly what I looking for. SumatraPDF is more and more useful for me !

I can “put” Sumatra in a sub-window of my app (with its handle). For those interrested, code line is only (in WINDEV language):
LanceAppli(“sumatrapdf.exe -plugin " + Handle(CFI_FenetreInterne) + " c:\test.pdf”)

The only problem is it’s seem not possible to change window size, but I will search a little more and if it’s not possible, I will lock my app to full screen without resizing possibilities. I have to look too for mask menu bar, ect… but now, I think it’s really near percfection !

Many thanks.

Ramirez22

After many test, I have one more problem with DDE command.
So I have a simple question. Is DDE command possible with portable version of Sumatra and how connect to the server ?
Cause I try but fail to connect.

Thanks for help

GitHubRulesOK

SumatraPDF should be offering a service once it is running as a windowed application thus usually needs to be started first,

I have not tried mixing call methods as I usually simply run CLI from DOS.cmd the -reuse-instance may be needed or set true in settings.txt

*run or start* "" sumatrapdf.exe -params arg1 arg2

Ramirez22

Hello.
I tried to launch SumatraPDF without -plugin argument. With this mode, I can control it with DDE commands. But when I use -plugin [window handle], DDE server looks shutdown : impossible to control it, even if sumatrapdf.exe appears in task manager.
I tried too -reuse-instance. Visually, no problem, I can change PDF and nothing bad occurs. But in task manager, each PDF change create another sumatrapdf.exe process. So memory usage increase.
Finaly, I open new sumatrapdf instance at each PDF document and closed old one. Except flash during process, that’s work good. Problem is now to destroy sumatrapdf process in cas of my app bug.

GitHubRulesOK

@Ramirez22
looking at the code https://github.com/sumatrapdfreader/sumatrapdf/blob/f1d2a138572acf630d3db865f629e1e43142737b/src/SumatraStartup.cpp#L337 it appers that -plugin mode has several limitations including presuming some settings thus may be the least useful unless you fully control any limitations of the working “window”

Thus I have to suggest either CLI or DDE without -plugin may be the easiest way to go

The reuse-instance function works for each file only thus avoiding duplication of a frequently changing file during edit
If changing files a new window or tab is generated for each

The “taskkill /IM sumatrapdf.exe” command will kill any open process if necessary or can be used to close a single window before you open another file