pdf doc

There is a doc page: How to include PDF of rulebook in VASSAL module help menu.

I cannot get this to work. If I follow the instructions exactly it gets an internal error. By exactly I mean not not putting anything in the “Menu Entry” field.

If I put, say , “Read Me!” in that field I get

https://drive.google.com/file/d/1aniD-EM6nx3nfP7cAaud4KAjwc3EPIHu/view?usp=sharing

If I follow those instructions on the dialog, that works. I really need something like this to work because this module needs decent instructions.

For the menu entry, type in “Rulebook” or “Readme” or something like that. (I’ve just posted an edit to the wiki entry to make that addition, but it will take a few days to clear moderation).

I just tried this myself, as I needed the rulebook put into a new module, and I had no problems – followed those directions precisely (except I typed “Rulebook” for the menu entry) and everything worked great.

One thing – I did this with a completely clean boot of the module, as the very first thing I did after loading the module into Vassal. And then I saved the module immediately. There are some intermittent bugs involving Help Menu HTML File edits, with the module not being able to be saved properly. You can avoid them by doing this edit at the very beginning of a clean edit session.

Hope this helps!

Brian

It urns out nothing is working for me.

I have tried a fresh clean module and it does not work. I have tried actual html rather than pdf does not work.

It occurs to me it may be relevant that I am using a Linux machine and this may be a bug in VASSAL on Linux.

As a test does anybody know of a module where this works?

I am also on Linux (Kubuntu 20.04), and I just tried this with a fresh module, and it worked just fine. Are you sure you’re following the steps on the doc page correctly?

Edit: Forgot to mention I’m using 3.3.0 beta 4 with Java 11, if that makes a difference, and I also added a blank map (as VASSAL complained about saving the module without any maps defined).

I have just reread them and I cannot see any divergence from them,

I am not sure if this is an issue with:

  1. VASSAL 3,2,17 (unlikely I’d guess)
  2. my machine and how it edits VASSAL modules
  3. my machine and how it launches pdf and html files into a browser.
  4. Something I am doing.

If someone could send me or direct me to a module that works for them, that would really help.

And for the record I can run this from the command line and it works:

sensible-browser 'file:///tmp/VASSAL/help/Westphalia_VASSAL.pdf/Westphalia_VASSAL.pdf'

There’s definitely something odd going on here. I added a random PDF from my computer (stored at “/home/[username]/Documents/Tunnels & Trolls/Adventure_in_Fellbarrow_(11744066).pdf”) to the module, typed “Test” for the Menu Entry, selected “/home/[username]/Documents/Tunnels & Trolls/” for the Contents, and “Adventure_in_Fellbarrow_(11744066).pdf” for the Starting Page.
This created the /tmp/VASSAL/help/Test directory, with “Adventure_in_Fellbarrow_(11744066).pdf” contained inside, and the .vmod file has a help directory, with a ZIP file called “Test”, containing “Adventure_in_Fellbarrow_(11744066).pdf”. Running the module, Selecting the “Help/Test” menu item opens the PDF.

Based on your PNG of the error you linked in your first post, VASSAL is looking for the PDF in /tmp/VASSAL/help/Read_Me!/Westphalia_VASSAL.pdf, but your last post says you can open /tmp/VASSAL/help/Westphalia_VASSAL.pdf/Westphalia_VASSAL.pdf…notice “Read_Me!” in the error has been replaced by “Westphalia_VASSAL.pdf” as the directory name in your latest post…

Edit: If that was just a typo on your part, I should also note that when I open the PDF from within VASSAL, it opens in the program associated with PDF files on my system (Okular, in my case), so perhaps there’s a problem with the file association for PDFs on your system?

I have tried with html also and that is not working.

Looking at previous modules:

I Tigris and Euphrates I used a plain text file.

In This Guilty Land I used a plain HTML file (no images). That worked. But then I added the html file rather than the containing directory.

My Paths of Glory 9.7 and For The People 3.2 modules both have working PDF files.

And jrwatts has a good point about it opening with your associated app. Try one of my modules and if it doesn’t open the rule book for you then it is likely a system configuration oddity on your system.

Thanks. I tried For the people and I get the same issue. IF someone could find the relevant piece of code that launches the browser or pdf viewer should be able to work it out from that.

It’s the openURL method in BrowserSupport.java (VASSAL.tools.BrowserSupport), called from BrowserHelpFile.java.

I’ve pasted the java code from the file below, in case that helps.

Brian

[code]package VASSAL.tools;

import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;

import edu.stanford.ejalbert.BrowserLauncher;
import edu.stanford.ejalbert.exception.BrowserLaunchingInitializingException;
import edu.stanford.ejalbert.exception.UnsupportedOperatingSystemException;

import org.apache.commons.lang.SystemUtils;

// FIXME: Remove BrowserLauncher when we move to Java 1.6+.

/**

  • Utility class for displaying an external browser window.
  • @author rkinney
    */
    public class BrowserSupport {

private static final BrowserLauncher browserLauncher;

static {
BrowserLauncher bl = null;

if (SystemUtils.IS_JAVA_1_5) {
  try {
    bl = new BrowserLauncher();
  }
  catch (BrowserLaunchingInitializingException e) {
    ErrorDialog.bug(e);
  }
  catch (UnsupportedOperatingSystemException e) {
    ErrorDialog.bug(e);
  }
}

browserLauncher = bl;

}

public static void openURL(String url) {
//
// This method is irritatingly complex, because:
// * There is no java.awt.Desktop in Java 1.5.
// * java.awt.Desktop seems not to work sometimes on Windows.
// * BrowserLauncher failes sometimes on Linux, and isn’t supported
// anymore.
//
if (!SystemUtils.IS_JAVA_1_5) {
if (Desktop.isDesktopSupported()) {
final Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(new URI(url));
return;
}
catch (IOException e) {
// We ignore this on Windows, because Desktop seems flaky
if (!SystemUtils.IS_OS_WINDOWS) {
ReadErrorDialog.error(e, url);
return;
}
}
catch (IllegalArgumentException e) {
ErrorDialog.bug(e);
return;
}
catch (URISyntaxException e) {
ErrorDialog.bug(e);
return;
}
}
}
}

if (browserLauncher != null) {
  browserLauncher.openURLinBrowser(url);
}
else {
  ErrorDialog.show("BrowserSupport.unable_to_launch", url);
}

}

private static final HyperlinkListener listener = new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
openURL(e.getURL().toString());
}
}
};

public static HyperlinkListener getListener() {
return listener;
}
}[/code]

Okay I found a file: src/VASSAL/tools/BrowserSupport.java. It makes very interesting and relevant reading but it does not quite tell me what VASSAL is doing. It suggests may be VASSAL is just giving without trying but I am not sure. I am using an XFCE desktop which might be relevant given what I saw in the code.

I just tried For The People under 3.3.0-beta4. Nothing happened. No error message but no rule boom either.

3.3.0-beta4 would be using this:

OpenJDK Runtime Environment (build 11.0.7+10-post-Debian-3deb10u1)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Debian-3deb10u1, mixed mode, sharing)

whereas 3.2.17 would be using

JAVA_VERSION="1.8.0_252"

Well it’s ultimately just calling onto the java.awt library, so you’d have to start researching java.awt.desktop which is the relevant Class.

Where you get pretty quickly to sentences like “Launches the associated application to open the file”

What application opens when you double-click a PDF file from your desktop?

Evince 3.0.2

For an html file it’s firefox-esr.

You could experiment with putting Adobe Acrobat or something like that in as the default application and see if that has any effect.

In the end the “good” news is that if you put your PDF in there it will work for everybody else :stuck_out_tongue:

I don’t believe that will help. As I have been repeatedly pointing out this also effects some use of HTML.

I have done a bit of googling. Looking at links like https://docs.oracle.com/javase/tutorial/uiswing/misc/desktop.html and https://stackoverflow.com/questions/8258153/how-to-get-desktop-class-supported-under-linux, I just need to have the gnome libraries. But actually it turns out I do, so I am not clear precisely what is happening.

I should probably remind myself how to program in java and I could try some of this code outside of VASSAL.

Or even better, get your dev environment set up for Vassal, and you can write your own custom class to experiment IN Vassal!

Thus spake slimy:

I should probably remind myself how to program in java and I could try
some of this code outside of VASSAL.

If you’re going to troubleshoot this, do it against 3.3.0-beta4, or 3.3.0
when it’s released this week. The code for 3.3.0 is both simpler and
current. Once 3.3.0 is out, my response to any question about 3.2 will be
“Upgrade to 3.3, then ask again if you still have a problem”.

There’s not much code in BrowserSupport now—really there are only three
bits which do anything:

Desktop.isDesktopSupported()

desktop.isSupported(Desktop.Action.BROWSE)

desktop.browse(new URI(url));

And Desktop isn’t our class, it’s part of the JDK. If we’re doing
something wrong in our code, I’d like to know, but my suspicion is that
we’re suffering from something else being wrong.


J.

Thanks. I sort of figured this out.

In fact I think I am just trying to see is I can get a webpage from inside a Java 11 program. If I can and 3,3.0 is not working I might have something to contribute.

It;s not going well: I can compile the following, though it seems to do nothing (which is what I would expect after trying For The PEople under 3.3.0-beta4.

import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class Main {
    public static void main(String[] args) {
        if (Desktop.isDesktopSupported()) {
                Desktop desktop = Desktop.getDesktop();
                if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
                        try {
                                URI uri = new URI("http://www.vassalengine.org/");
                                desktop.browse(uri);
                        }
                        catch (URISyntaxException ex) {
                                System.out.println(ex);
                        }
                        catch (IOException ex) {
                                System.out.println(ex);
                        }
                }
        }
    }
}

Thus spake slimy:

Code:

import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class Main {
public static void main(String[] args) {
if (Desktop.isDesktopSupported()) {

Print the value of this conditional.

            Desktop desktop = Desktop.getDesktop();
            if (desktop.isSupported(java.awt.Desktop.Action.BROWSE))

{

Print the value of this conditional.

It would be useful to verify that they’re both true for you. If one of
them is false, you’re never getting to the point of trying to open the
URL.


J.

Yeah I figured that out. I modified my code:

[code]import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class Main {
public static void main(String[] args) {
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
try {
URI uri = new URI(“http://www.vassalengine.org/”);
desktop.browse(uri);
}
catch (URISyntaxException ex) {
System.out.println(ex);
}
catch (IOException ex) {
System.out.println(ex);
}
}
else {
System.out.println(“Cannot start browser”);
}
}
else {
System.out.println(“Desktop is not supported”);
}
}
}
[/code]

and I got:

nicholas@leonhartsberger:~/VASSAL/test$ java Main 
Cannot start browser

So it looks like the Desktop is supported but browsing on it is not.