GUI : PDF reader

Is there a way to view (read) a PDF using SC GUI classes (Window, view, container, etc) ? I did not find any information in help files nor scdocs, scsynth, and mailing list.

Btw, I am currently using SC to send D-bus messages to multiple Zathura PDF viewers and want someday to integrate all this in a SC GUI.

~zathura.add(\dbGotoPage → {
arg pid, page;
var pipe, cmd;
page = (page - 1);
// pid.postln;
cmd = (
“dbus-send --type="method_call" --dest=org.pwmt.zathura.PID-”
++ pid ++
" /org/pwmt/zathura org.pwmt.zathura.GotoPage uint32:"
++ page
);
// cmd.postln;
pipe = Pipe.new(cmd, “w”);
pipe.close;
});

You should be able to do this with the WebView, but I’ve never been able to get it to work…

you say… I’ll look into it right away.

Maybe you could convert the pdf to a pure text file using some non-sc related software and then import to SC trough the File or Document class?


Put that in text :slight_smile:

Ah I see:) thought we were talking about text

I went with the // A simple web browser example of the WebView class help file. I could navigate in my own local computer using file:///home/user/etc. But opening a PDF causes (for now) an error that I cannot see.

I did read :

Alternatively you could just do the whole thing as a series of images…
Or, if the scores is made with lilypond and can embedded http links on each note, and you could use an external reader to jump to that point - doesn’t solve the external problem, but does make jumping around easier.

I very naively tried :

webview.setContent(
File(“file:///home/some.pdf”, “rb”),
“application/pdf”,
“file:///home/some.pdf” )

To no avail.

I believe this response has the answer:

Sclang’s WebView:setAttribute should connect to the same QT setAttribute API - hopefully PDFs should work if you enable plugins as this post suggests?

It seems like this might be related to PDF viewers you have installed as well, so there may be more tweaking required - but it seems like at least in theory this works…