I am having iOS application in which I want to view data from .djvu file. Is there any way to read .djvu file in Swift or inside UIWebview.
I have also tried following solutions to view djvu file in uiwebview but that doesn't help.
1. Directly open djvu file in uiwebview
let urlPage : URL! = URL(string: "http://192.168.13.5:13/myData/5451890-OP.djvu")
webView.loadRequest(URLRequest(url: urlPage))
2. Secondly i have tried to convert djvu file to pdf and the showing that converted pdf file into view. Reference link: https://github.com/MadhuriMane/ios-djvu-reader But that gives mirror image with low quality.
3. I have tried to preview file with the help of UIDocumentInteractionController() and it's delegate method but didn't work.
Please suggest any possible ways to do so.
Keeping in mind that .djvu files are less popular then similar formats like EPUB, MOBI, PDF and other eBook file formats, I would have following approach to workaround the problem.
1) Create a Web Service to convert djvu files to pdf ex.:
http://example.com/djvuToPdf/djvuFile/outputFile2) Read the PDF file in
UIWebViewTo create a Web Service I would assume that you have access to any Linux distributed Server, in my case Ubuntu 16.04.
Step one: Install djvulibre
sudo apt-get install djvulibre-bin ghostscriptStep two: test run
$ djvups inputFile.djvu | ps2pdf - outputFile.pdf. You may also use theddjvucommand. However, files converted withddjvucommand are 10x larger thandjvupscommand. You would want to consider to use--helpthe explore the settings likemode,qualityand so on.Step three: Creating a Web Service (to keep things simple, I use PHP, use anything at your convenience [Python golang])
Final Step: load PDF in App
As Apple advise, consider using WKWebView in place of UIWebView.