Integrated Sumatra PDF based Lister plug-in (wlx)

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

Post Reply
j
Member
Member
Posts: 124
Joined: 2009-04-13, 19:49 UTC

Integrated Sumatra PDF based Lister plug-in (wlx)

Post by *j »

I had this project in my personal queue for quite some time. Fortunately, I finally found some time to start coding.

So here it is:

A fully integrated Sumatra PDF based Lister plug-in.

This is the initial release so there are probably some rough edges, though I tested it quite extensively.

Now to what is more important - the features:
- View PDFs with Lister (or any other tool supporting wlx plug-ins)
- Fully independent of any external tools or additional libraries
- Very simple non-obtrusive interface, stripped down to the bare minimum
- Tightly integrated into Total Commander, thus offering support for search (your favorite F3->F3 combo works!) and position
- Fast, because it uses the Sumatra PDF code-base (that in turn uses MuPDF to render)
- Small, only 1.7 MB (compressed with UPX) for a full fledged PDF viewer
- Free Software (GPLv3 as required by Sumatra PDF)

Known issues (will be fixed when I find some more time):
- Original toolbar implementation of Sumatra PDF is a hack, thus there are some minor render glitches (in the toolbar you'll see an extra separator) when using the "Classic Theme"
- Slow rendering tasks may need to be completed before window will be closed

TODO/Wishlist (will be added when I find some more time):
- Add advanced (XMP based) properties dialog for the shown PDF
- Implement printing support
- Find a nice way to show/hide TOC box (ini setting?) and make it search-able

Screenshot:
Image: http://helicoid.de/tc/wlx_sumatrapdf.png

Changelog
Version 0.8.1:
- [face=courier]sendcommand=0[/face] did not save zoom level when "Fit to window" was active

Version 0.8:
- Updated to SumatraPDF r2072 (fixes Issue 1013)
- Added the ini-Setting [face=courier]sendcommand[/face] to disable sending and receiving the "Fit to Page"-commands from Lister. Default is 1.

Version 0.7.5:
- Store display mode (facing, continuous) in ini
- Do not write sumatrapdfprefs.dat file
- Updated detection string to match ext="pdf" or the pdf signature without forcing

Version 0.7.3:
- Some fixes for the TOC box ('t' always toggles the box, do not zoom when toggle)

Version 0.7.2:
- Added option to toggle TOC (press 't' and 't' again when the box is not focused or click the little arrow) - this is not persistent (yet).

Version 0.7.1:
- Added a toolbar button to show the SumatraPDF based properties window of a PDF

Version 0.7:
- Added support for ListGetPreviewBitmap(W) (which means thumbnails will be generated even on systems without any external PDF reader installed)

Version 0.6:
- Zoom level is now stored in lsplugin.ini
- Buttons for "fit page" and "fit to width" added to toolbar

Version 0.5:
- Initial release

Download:
Sumatra PDF WLX - Version 0.8.1 (1.7 MB)

For now, I did not put the sources into a proper repository, but you can get them here.
The changes were made against r2072 so just check out this version (or try it with HEAD) and extract the archive to the source tree.


Credits:
Krzysztof Kowalczyk and some other contributors wrote the Sumatra PDF core. Check the official Sumatra PDF page for more information. The wlx part is my work.

Feel free to report bugs you find (also check if they exist in the original Sumatra PDF and then and only then report them there). Patches are also very welcome.
Last edited by j on 2010-08-22, 22:51 UTC, edited 18 times in total.
User avatar
dott
Senior Member
Senior Member
Posts: 285
Joined: 2007-03-04, 00:58 UTC
Location: La Plata, Argentina

Post by *dott »

Testing...
kjk
New Member
New Member
Posts: 1
Joined: 2010-08-16, 04:20 UTC
Contact:

Post by *kjk »

Hi J, I'm the author of Sumatra. If there are improvements that you're making as part of your plugin work that would also benefit Sumatra, I encourage you to send them to me, as described at Sumatra website (section develop)

I believe it would be good for both of us: Sumatra would get the benefit of additional improvements and you would have a smaller diff to maintain for your project. In general I'm happy to give svn commit privileges after a few patches, to make it easy for people to contribute.

Maybe it would even be possible to build your plugin directly from Sumatra's sources (with a few #ifdefs).

Either way, I'm happy that Sumatra was of use for you.
Krzysztof Kowalczyk
http://blog.kowalczyk.info
j
Member
Member
Posts: 124
Joined: 2009-04-13, 19:49 UTC

Post by *j »

kjk wrote:I believe it would be good for both of us: Sumatra would get the benefit of additional improvements and you would have a smaller diff to maintain for your project. In general I'm happy to give svn commit privileges after a few patches, to make it easy for people to contribute.
Sure thing. For now the changes mainly regard the integration part. But when it comes to the toolbar I will definitely prepare patches for the main source tree when I make improvements.
kjk wrote:Maybe it would even be possible to build your plugin directly from Sumatra's sources (with a few #ifdefs).
I first went this way but the source became a bit too convoluted. I suppose in the long term it might be better to basically have a main.cpp and a listplug.cpp and put the specialized parts in either and the common parts in the SumatraPDF.cpp (those where little to none #ifdefs are needed). Anyway, if the plug-in would be a welcome addition to the main project I suppose that I will try to find some time to do a bit of integration work so the changes do not diverge that much and the plug-in keeps an up-to-date code-basis.
kjk wrote:Either way, I'm happy that Sumatra was of use for you.

It sure was. Great work by the way ;-).
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

I also suggest to base on original source code. You will be able to do print, search etc, and no glitches when rendering.
Pls, Upx compr. - make an option(if I include it into UV package, non-compr. version will be better)
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

3, Will you put to totalcmd.net?
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6708
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Post by *Horst.Epp »

There should be at least an option to set the default Zoom factor.
Currently it comes up everytime with some unreadable small display and doesn't remenber the last used Zoom.
This way you can't read a lot of PDF files in a short time.
j
Member
Member
Posts: 124
Joined: 2009-04-13, 19:49 UTC

Post by *j »

Alextp wrote:I also suggest to base on original source code. You will be able to do print, search etc, and no glitches when rendering.
Pls, Upx compr. - make an option(if I include it into UV package, non-compr. version will be better)
It is based on the original source code, hence the Sumatra PDF origin and not MuPDF (or so). But to implement an integration, printing and search needs to be delegated and the Sumatra PDF based search was not portable in that sense.
Also printing needs to be redirected as Total Commander tells the method what printer to use etc. (basically not that hard to do).

The glitch is inherent in the Sumatra PDF toolbar as it uses a separator as a spacer and thus it will produce some glitches. When I will find some time I will implement a proper toolbar that can be used in Sumatra PDF and my derived WLX.

Finally, I tested various compression variants and UPX produces the smallest overall archive. On important point is, that I want to use a standard format such as RAR or ZIP, any other would mean that the user needs an extra packer (plug-in) installed. Feel free to use UPX to decompress the DLL if you have a problem with it or compile the source code to get a real vanilla file.
Alextp wrote:3, Will you put to totalcmd.net?
I don't have an account there yet. But when I'll get one, I will.
j
Member
Member
Posts: 124
Joined: 2009-04-13, 19:49 UTC

Post by *j »

Horst.Epp wrote:There should be at least an option to set the default Zoom factor.
Currently it comes up everytime with some unreadable small display and doesn't remenber the last used Zoom.
This way you can't read a lot of PDF files in a short time.
You are right. I forgot to mention that in my "Known Issues" list. There is no proper configuration yet. When it will be used, the zoom will definitely be saved.
User avatar
fenix_productions
Power Member
Power Member
Posts: 1979
Joined: 2005-08-07, 13:23 UTC
Location: Poland
Contact:

Post by *fenix_productions »

2j
I must say you fulfilled my dream (shared with Ultima Prime long ago). Thank you.

So... next dreams are:
- some comic viewer as WLX,
- ToDoList by AbstractSpoon as WFX ;)
"When we created the poke, we thought it would be cool to have a feature without any specific purpose." Facebook...

#128099
User avatar
Xnor
Junior Member
Junior Member
Posts: 80
Joined: 2009-04-17, 10:55 UTC

Post by *Xnor »

good job, thanks a lot :!: :!:
#201591 Single user licence
User avatar
dott
Senior Member
Senior Member
Posts: 285
Joined: 2007-03-04, 00:58 UTC
Location: La Plata, Argentina

Post by *dott »

On the zoom regard, Z shortcut help me on this, it's not ideal but...
j
Member
Member
Posts: 124
Joined: 2009-04-13, 19:49 UTC

Post by *j »

I released an update. The new version will store the last set zoom level.
You can disable writing of a new zoom level by setting [face=courier]savezoom=0[/face] in the [face=courier]lsplugin.ini[/face] under the [face=courier][SumatraPDF][/face] key. Then the value stored as [face=courier]zoom[/face] will be used when opening a PDF (where -1 is fit page and -2 fit to width).

There is some heuristic going on when "fit image to window" is active:
When a previous session (like Imagine or what ever) sets the "Fit image to window" it will overrule the previous zoom level but will not overwrite the setting in the INI. Thus when pressing "f" you will return to the previous zoom-level. I think this way the behavior is quite consistent.

Any other suggestions are welcome.
User avatar
Xnor
Junior Member
Junior Member
Posts: 80
Joined: 2009-04-17, 10:55 UTC

Post by *Xnor »

nice progress.
I wanted to ask if it could be possible to select text in a pdf and be able to copy it to the clipboard. It would be just great.
#201591 Single user licence
j
Member
Member
Posts: 124
Joined: 2009-04-13, 19:49 UTC

Post by *j »

Xnor wrote:nice progress.
I wanted to ask if it could be possible to select text in a pdf and be able to copy it to the clipboard. It would be just great.
Yes, hold Ctrl while dragging with your mouse to select a text area. Then you can either Ctrl+C or do Edit->"Copy as text" from the menu.
Post Reply