NSDEJAVU(1)

πŸ“¦
version 4.12.3 Β· 2 versions
, in fedora 43, fedora 44

✨ NSDEJAVU(1) ✨

okay bestie, sit down, we're talking about nsdejavu from the DjView-4 era πŸ’… this one's the DjVu browser plugin, and honestly? it's giving vintage. it's giving before your time. but it ate, and we're gonna learn it 🫢


🌸 SYNOPSIS 🌸

/usr/lib64/mozilla/plugins/nsdejavu.so

like, that's it. that's the whole synopsis. she's just a shared library sitting in the plugins folder, living her truth ✨


πŸ’€ WARNING πŸ’€

ngl, using nsdejavu as a plugin in 2020 is very difficult, and I need you to hear me on this. popular browsers either straight-up don't support netscape plugins anymore (looking at you, chrome πŸ‘€), or they removed support for every netscape plugin except flash (yep, firefox, I said what I said).

and like… the maintainers regret this. genuinely. because djview/nsdejavu is a perfect example of a very well behaved plugin that would have been easy to support 😭 not me getting emotional over a deprecated plugin architecture fr fr.

so bestie, if you're on a modern browser and this doesn't work: that's not you, that's the ecosystem. πŸ’€

πŸ¦‹ DESCRIPTION πŸ¦‹

The shared library nsdejavu.so uses the Netscape browser plugin API to display DjVu images in a number of popular web browsers. (yes, in a number of popular web browsers, that part is real, we're not rewriting history here πŸ’…)

how does it do it? iconic behavior actually: it works by invoking a standalone viewer out-of-process with the special command line option -netscape. main character energy, no cap.

and then there's a whole little search quest for which viewer to use, and it goes like this:

  1. it first searches a program named djview
  2. if that program cannot be found, it searches for djview4
  3. and finally djview3

✨ but ✨ it is always possible to override this search strategy by setting the environment variable NPX_DJVIEW to the full path of the desired executable. so if you wanna be the one in charge, you can be. periodt.


🌈 MIME TYPES AND EXTENSIONS 🌈

Typing the URL of a recognized DjVu document in your web browser should automatically invoke the DjVu browser plugin. that's the dream, that's the vibe.

but here's the thing: each browser uses different methods to determine that a particular URL is in fact a DjVu document. messy, but we deal πŸŽ€

Web server normally provide a MIME type to web browsers. The official MIME type for DjVu documents is image/vnd.djvu. πŸ†

For compatibility with ancient versions of the DjVu viewer, it is common to use instead the experimental MIME type image/x-djvu or image/x.djvu. (experimental!! how very avant-garde of them ✨)

Web servers should be configured to send the proper MIME type for DjVu documents. and also, most web browsers recognize files ending with .djvu or .djv as DjVu files, so that's your little safety net 🫢


πŸ” how to vibe check your server πŸ”

An easy way to check if an http server is giving an appropriate content-type is to invoke the following command with a URL corresponding to an actual DjVu file on the server:

curl -u URL | grep Content-Type

The result should be one of the following, preferably the first:

Content-Type: image/vnd.djvu
Content-Type: image/x.djvu
Content-Type: image/x-djvu

Any other MIME type indicates a server misconfiguration. πŸ’€ like, red flag, bestie. red flag.


πŸŽ€ CGI-STYLE FLAGS πŸŽ€

okay so this is the fun part. The behavior of the DjVu browser plugin can be specified by augmenting the URL using a syntax similar to that used by the CGI programs. and the template goes a lil something like this:

http://.../file.djvu?djvuopts&keyword=value&keyword=value&...

🚨 important 🚨 The DjVu browser plugin only recognizes keywords that appear after the word djvuopts. if you forget djvuopts, she's not listening. she's not even looking at you.

The keywords recognized by each viewer are listed in the corresponding man page. Unrecognized keywords are ignored β€” no error, no drama, just silence πŸ™ˆ

The most common keywords are:

  • page=pagename β€” Specify which page is displayed by name or by ordinal number.
  • zoom=zoomfactor β€” Set the zoom factor. Legal values for zoomfactor are:
    • number β€” Magnification factor in range 10% to 999%.
    • one2one β€” Select the "one-to-one" mode.
    • width β€” Select the "fit width" mode.
    • page β€” Select the "fit page" mode.
    • stretch β€” Stretch the image to the plugin window size.

πŸ‘‘ BROWSER COMPATIBILITY πŸ‘‘

The DjVu browser plugin has been tested with several popular web browsers, and the roster is lowkey a time capsule πŸ•°οΈ

  • Netscape 4 and 6
  • Gecko based browsers such as Mozilla, Galeon and Firefox
  • KHTML based browsers such as Konqueror
  • Opera

Please read the browser documentation to find out where the plugin library should be installed. (yes really, go read the docs, I'm not gonna guess for you 🫢)


πŸ’œ EMBEDDING DJVU IMAGES IN HTML PAGES πŸ’œ

You can integrate DjVu content on an HTML web page with either the <embed> or the <object> tag. and here's the slay part: this method will work even if your web server does not support the DjVu MIME type πŸ”₯

The CGI style flags can be directly used as attributes of the embedding tag. chef's kiss.

The following example shows the W3C standard syntax with the OBJECT tag:

<object data="myfile.djvu" type="image/vnd.djvu"
          width="100%" height="100%" >
    <param name="page" value="iii">
    <param name="zoom" value="stretch">
    This browser cannot render djvu data.
</object>

And this is the customary syntax with the EMBED tag:

<embed src="myfile.djvu" type="image/vnd.djvu"
          width="100%" height="100%"
          page="iii" zoom="stretch"></embed>

pick your fighter, both are valid πŸ’…


🧚 INTERFACING THE DJVIEW PLUGIN WITH JAVASCRIPT 🧚

okay now we're getting scriptable. Recent versions of the djview4 plugin can be controlled from the JavaScript interpreter of browsers implementing the Mozilla NPRuntime API. (iykyk)

To access the plugin object, include the attribute id="pluginname" into the <object> or <embed> tag and use the JavaScript function getElementById("pluginname").

The plugin object implements two methods to retrieve and set the value of the options usually recognized as CGI-style flags. It also can evaluate a specified JavaScript expression whenever something changes in the status of the djview interface. multitasking icon πŸ’…

  • pluginobject.setdjvuopt("key",value) β€” Set the value of the djvu option key to the character string value. This achieves the same effect as specifying option key=value among the CGI-style flags. For instance, values of the key page can be page IDs, page titles, page numbers, or page names.
  • pluginobject.getdjvuopt("key") β€” Return the value of the djvu option key as a string. The returned value is always a character string, even when the return is logically a number. Boolean values are returned as strings yes or no. Besides the usual CGI-style flags, this function recognizes the additional key pages and returns the total number of pages in the DjVu document. An empty string is returned when the key is not recognized. πŸ™ˆ
  • pluginobject.onchange="code"; β€” Ensure that string code is evaluated in the context of the plugin object whenever something changes in the djview graphical user interface. For instance, this evaluation happens when progressive refinements are painted, and when the user manipulates the image interactively.
  • pluginobject.version β€” Return a string describing the plugin version. This property can be used to test whether the djview plugin is scriptable in this browser.
⚠️ heads up bestie: Note that the scriptability feature may not be accessible until the djview plugin is fully loaded. Therefore it is advisable to check pluginobject.version from the JavaScript onload before calling any other method. do not skip this step, I'm begging 😭

🌟 CREDITS 🌟

This program was written by Andrei Erofeev <andrew_erofeev@yahoo.com> and was then improved by Bill Riemers <docbill@sourceforge.net> and LΓ©on Bottou <leonb@users.sourceforge.net>. absolute legends, all three πŸ‘‘


🫢 SEE ALSO 🫢


and that's the whole page, bestie!! πŸŽ‰ this little love letter to a netscape plugin era came to you from DjView-4, dated 1/4/2007 β€” yes, 2007, she's vintage vintage, and we respect her for it πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from