TXT and PDF viewer and Documents library
#1
Summary
 
  • I propose to add to Kodi core the ability to read and display TXT and PDF files using the Poppler library.
  • Additionally, a Documents library may be added in a similar fashion to the Pictures library.

Motivations

The integration of Retroplayer into Kodi Leia will introduce the ability to play retro/old games natively into Kodi. This feature has long been awaited and will clearly differentiate Kodi from other media center apps. Although Leia will be able to play games (or ROMs), a Games database eventually will be added into Kodi so users can browse their games the same way as Movies, TV Series or Music. Games require new types of artwork, including Boxfronts, Boxbacks, Title screenshot, In-game screenshot, etc. Notably, an important asset for Games is the Game Manual. Currently, Game manuals cannot be easily displayed in Kodi.

In addition, many Music album releases, particularly classical music releases, come with booklets that can be backed up in PDF files after scanning them. Having the ability to display these PDF booklets will be an invaluable feature for many music lovers.

Many users in the past have expressed their wish to use Kodi to keep their comic collection organized within Kodi. Previously, launcher plugins like Advanced Launcher were used to call external programs like PDF/CBR viewers in order to display comic collections.

Also many users have expressed their wish to use Kodi to browse and manage their collection of ebooks.

Last but not least, it will be a very interesting feature if TXT files can be displayed from the Kodi File Manager. The ability to see the content of TXT files (in particular XML files) would be extremely useful when setting up Kodi.

Previous work

There has been a number of Kodi addons that enable user to visualize PDF files. PDF Reader is nice but only supports PDF made entirely of images. HyperLauncher uses the auxiliary addon plugin.image.pdfreader which calls GhostScrip to convert each page of the PDF file into a JPG/PNG file, and then display those images. Advanced Emulator Launcher has support in its internal database for Game/ROM manuals but currently is not able to display PDF files.

The idea of Kodi being able to render PDF/TXT and other formats is not new. Here is a long thread started in 2004 to discuss this matter.

Proposal of feature request

I propose to include the Poppler library into Kodi with the purpose of rendering PDF files. Poppler is written in C++, is portable, has a very simple API and it is currently used in many document viewer applications. PDF/TXT files may be display with a code like this

xbmc.executebuiltin('ShowDocument("{0}")'.format('my_file.pdf'))

I propose to create a new window similar to DialogTextViewer.xml. DialogTextViewer.xml uses a proportional font and is convenient to display Movie plots, for example. The new window will use a monospaced type font and will be used to render TXT file contents.

I optionally proposed a Documents library database. Users may use this to add media sources containing ebooks in PDF (or other formats), comics, etc.
Reply
#2
This sounds awesome Big Grin

A documents library would be a great addition.

Thanks for looking into this
Reply
#3
I have been doing some more research.

1) Poppler PDF rendering library needs Cairo library as a rendering backend. Cairo supports rendering to memory surfaces or PNG images. I'm not sure if it's feasible to include both Cairo and Poppler into Kodi as embedded libraries but it may be worth investigation (maybe as a GSoC project?).

2) Even if the PDF render is not implemented, the TXT visualiser is an important feature in my opinion. Can you please consider adding a monospaced text rendering window into Kodi? Also, TXT/XML/DAT files can be recognised as text files and rendered in the File Manager?

The current DialogTextViewer.xml window can be kept as it is, with a proportional font. A new window, for example, DialogTextViewerMono.xml will use a monospaced font and will be ideal to render TXT and XML files.

Any dev can please comment something?
Reply
#4
including those in the main build is not an option. you could probably pull this off using a combined vfs / image decoder add-on.
Reply
#5
(2017-11-23, 15:03)spiff Wrote: including those in the main build is not an option. you could probably pull this off using a combined vfs / image decoder add-on.

OK, I understand Poppler and Cairo are a lot of fat to include in the core. Anyway, the proposal is there and your idea about a binary addon may work OK.

What about the TXT/XML/DAT file viewer and the monospaced text display dialog? That should be relatively easy to do and will be a really nice feature for many addons.
Reply
#6
i thought it should already be there, i wrote such a thing 8 years ago or something. might need some glue to be usable from add-ons, will check.
yep, it's there;

Code:
import xbmcgui
xbmcgui.Dialog().textviewer('heading', 'contents')
Reply
#7
(2017-11-23, 15:13)spiff Wrote: i thought it should already be there, i wrote such a thing 8 years ago or something. might need some glue to be usable from add-ons, will check.
yep, it's there;
Code:
import xbmcgui
xbmcgui.Dialog().textviewer('heading', 'contents')

Yeah, my plugins like Advanced Emulator Launcher already use that function to display text which opens a window skinned in DialogTextViewer.xml. However, skinners tend to use DialogTextViewer.xml to display things like Movie plots and use a small window and most importantly, a proportional font. For example, this is AEL displaying launcher statistics in Estuary

Image

And this is same window in Mimic.

Image

This is how the same window with same content looks into my mod Estuary AEL, using a monospaced font.

Image

The thing is, maybe the original idea was to use DialogTextViewer.xml window to display TXT/XML files, but over time people have used it for other purposes. By creating a new Kodi window then it will be clear the distinction: one window for Movie plots, general long info, etc. and one window for displaying TXT files.

Also, can you please adjust the File Manager so when the user clicks on a TXT/XML/DAT file the textviewer windows shows the contents? This is similar to clicking on a PNG/JPG file and you can see the picture. That should be easy to do, right?
Reply
#8
if you are going to tell me that things are easy to do, my answer is simple: yes, it's so easy you can do it yourself.

duplicated dialogs is not something we want for sure. there should instead be an option to request mono-spaced font.
Reply
#9
(2017-11-23, 18:08)spiff Wrote: if you are going to tell me that things are easy to do, my answer is simple: yes, it's so easy you can do it yourself.

Please relax. My comment was educated so I think I don't deserve such an answer. I know that just setting a developing environment for a big application like Kodi may take several hours. Plus more hours to get familiarized with the build system and the C++ code (which I'm not, I'm just a Python developer) in order to make the proposed change.
(2017-11-23, 18:08)spiff Wrote: duplicated dialogs is not something we want for sure. there should instead be an option to request mono-spaced font.

That should do the job, yes. "Officialize" in some way that and addon may request the text viewer dialog to be big and to use a monospaced font. Advanced Emulator Launcher already requests a monospaced font when opening a text viewer dialog by setting a property (please refer to the link in the previous post) but unfortunately most skins just ignore it because is a non-standard thing.
Reply
#10
I am very relaxed but never ever ask for something and then immediately demean the task. You wouldn't do that to anyone in their face and you should not do it on the internet. It is simply impolite, adds nothing of value and certainly does not help your cause in any way. Just dont.
Reply
#11
(2017-11-23, 18:38)spiff Wrote: I am very relaxed but never ever ask for something and then immediately demean the task. You wouldn't do that to anyone in their face and you should not do it on the internet. It is simply impolite, adds nothing of value and certainly does not help your cause in any way. Just dont.

I'm glad you are relaxed. Contrary to what some people do, I always use words like "please" and use use verbs like "may" in my posts, so I believe I understand about what is impolite and what is not and won't take any lessons from you. I'm not sure about what you mean by "ask for something and then immediately demean the task" but I think you have totally misunderstood my attitude and/or meaning. My comment about something being easy or not to implement in no way and by no means undermines the work itself, the person doing it or is ordering someone to do something just because it is easy whatsoever.
Reply
#12
then what is the point of claiming things you admit you are incapable of doing are simple? you are in no position to make the claim. i won't go near this thing out of principle and it's all because of that. i never tried to lecture you, i only tried to tell you how such statements are received. i never called you impolite so you do not have to defend your ego like that.
Reply
#13
To be best of my knowledge I had never made such claim. First I did make a suggestion ("should be relatively easy ...") and then I just asked a question ("That should be easy to do, right?"), in both cases using polite language that included the word please and soft verbs like "may" or "should", which by the way you don't generally use. Obviously, that was misinterpreted and I got a blunt answer in response. Then, I tried to play it down to return things to normal an carry on with the feature discussion, trying to empathize and recognizing the effort that requires just compiling Kodi. I got a blunter response. This is not about defending my ego but rather that I won't accept that you put words or attitudes in my mouth I never said or implied and the text is there for anyone to read and draw his conclusions.

Finally, if you are not "going near this thing out of principle and it's all because of that", who's trying to defend their ego here? If the features I propose are useful please think about implementing them and I will appreciate that. If not, please provide some useful feedback from the core developer point of view and then I may think about other ways of improving things.
Reply
#14
you won't get my point and that's fine. let's move on. i have implemented the mono space toggle.
Reply
#15
(2017-11-24, 11:51)spiff Wrote: you won't get my point and that's fine. let's move on. i have implemented the mono space toggle.

Thanks a lot, I saw the PR. I will make changes in AEL and test it ASAP.

Edit: also saw the PR about the TXT/XML files in the File Manager. That's great and thanks a lot!
Reply



Logout Mark Read Team Forum Stats Members Help
TXT and PDF viewer and Documents library0
This forum uses Lukasz Tkacz MyBB addons.