Bearing in mind that .djvu files are less popular than similar formats such as EPUB, MOBI, PDF and other e-book formats, I would have the following approach to solving the problem.
1) Create a web service to convert djvu files to pdf for example: http://example.com/djvuToPdf/djvuFile/outputFile
2) Read the PDF file in UIWebView
To create a web service, I would assume that you have access to any distributed Linux server, in my case Ubuntu 16.04.
Step one: install djvulibre sudo apt-get install djvulibre-bin ghostscript
Step Two: Test Run $ djvups inputFile.djvu | ps2pdf - outputFile.pdf $ djvups inputFile.djvu | ps2pdf - outputFile.pdf . You can also use the ddjvu command. However, files converted using the ddjvu command ddjvu 10 times larger than the djvups command. You would like to consider using --help to study settings like mode , quality , etc.
Step three: creating a web service (to keep things simple, I use PHP, use something at your convenience [Python golang])
<?php $inputFile = $_GET['input_file']; $outputFile = $_GET['output_file']; // use shell exec to execute the command // keep in mind that the conversion takes quite a long time shell_exec(sprintf("djvups %s | ps2pdf - %s", $inputFile, $outputFile)); $name = $outputFile; //file_get_contents is standard function $content = file_get_contents($name); header('Content-Type: application/pdf'); header('Content-Length: '.strlen( $content )); header('Content-disposition: inline; filename="' . $name . '"'); header('Cache-Control: public, must-revalidate, max-age=0'); header('Pragma: public'); header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); header('Last-Modified: '.gmdate('D, d MYH:i:s').' GMT'); echo $content; ?>
Final step: Download the PDF in the application
As Apple advises, consider using WKWebView instead of UIWebView.
if let pdfURL = Bundle.main.url(forResource: "pdfFile", withExtension: "pdf", subdirectory: nil, localization: nil) { do { let data = try Data(contentsOf: pdfURL) let webView = WKWebView(frame: CGRect(x:20,y:20,width:view.frame.size.width-40, height:view.frame.size.height-40)) webView.load(data, mimeType: "application/pdf", characterEncodingName:"", baseURL: pdfURL.deletingLastPathComponent()) view.addSubview(webView) } catch {