Develop an ebook reader on iPhone/iPad using MuPDF library
Asked Answered
M

2

4

Can I develop an ebook reader on iphone/ipad using MuPDF library?

Do you have any good idea? Please help me with some good tutorials.

Multiphase answered 6/9, 2011 at 17:49 Comment(6)
Does Apple allow you to recreate the functionality of their own software and sell it? I haven't done iOS for a while, but that's what I remember you weren't allowed to do...Moldavia
really? i didn't think about that problems. Any idea?Multiphase
You can't get around the restrictions.Moldavia
Would you suggest me a good framework for pdf?Multiphase
Note that MuPDF is GPL, which would require you to also release your application source code, and may make it incompatible with the App Store.Lantz
MuPDF is dual-licensed. If you want to use it for free, it's available under the GNU AGPL license. That will indeed require you to release your application source code (but it's still perfectly compatible with the Android App Store at least). If you can't abide by the terms of the GNU AGPL, it's also available with a commercial license that frees you from all those complex requirements.Acclamation
P
5

Sorry for the late answer but it could help people a day or another. As I had to integrate the MuPDF library into one of my (Swift) project, I generated the static fat libraries and integrate them into Xcode.

Here you go with a step-by-step quick tutorial:

How to build the static fat library:

  1. git clone --recursive git://git.ghostscript.com/mupdf.git
  2. Go to mupdf/platform/ios
  3. Open MuPDF.xcodeproj with Xcode.
  4. Configure the scheme of the MuPDF target to Release.
  5. Build and run the app on an iPhone simulator.
    • This will generate the library for platforms i386 and x86_64
  6. Build and Run the app on a real iPhone device - use your own bundle id, certificate and provisioning profile.
    • This will generate the library for platforms armv7 and arm64
  7. Go to mupdf/build/
    • You will find two folders that contains all built librairies: release-ios-i386-x86_64 and release-ios-armv7-arm64
  8. Now you need to create fat libraries with all 4 architectures for the mupdf one and all its dependencies.

lipo -create ./*/libcurl.a -output 'libcurl.a' ; lipo -create ./*/libfreetype.a -output 'libfreetype.a' ; lipo -create ./*/libjbig2dec.a -output 'libjbig2dec.a' ; lipo -create ./*/libjpeg.a -output 'libjpeg.a' ; lipo -create ./*/libmujs.a -output 'libmujs.a' ; lipo -create ./*/libmupdf.a -output 'libmupdf.a' ; lipo -create ./*/libopenjpeg.a -output 'libopenjpeg.a' ; lipo -create ./*/libz.a -output 'libz.a'

How to integrate MuPDF into your project:

  1. Add/import into your project:
    • All header files from mupdf/include/mupdf
    • All obj-c classes from mupdf/platform/ios/classes
    • The common.[h,m] files from mupdf/platform/ios
  2. Add/import the previously generated fat libraries (8 files)
  3. Configure the Library Search Path by adding the path to your library files.
    • For example $(inherited) $(PROJECT_DIR)/External/MuPDF/lib/

You should now be able to build and run your app with the library included. Use the sample project to understand how the library works or any online tutorial.

Pro Tip:

The final fat libraries are pretty big all together (~ 46mb). You could easily reduce the final size of your app by importing:

  1. Under a release folder just the lib.a from mupdf/build/release-ios-armv7-arm64
  2. Under a debug folder the big generated fat librairies from mupdf/build/
  3. Set different Library Search Path for Debug and Release config.

Once done, you will be able to build and run on Debug on every simulator and devices. But only on devices for Release. Which in the end you need as your app, through, the AppStore should only run on real devices. There is no need to include debug-simulator architecture static librairies.

Here is a screenshot of all imported files into my Xcode project:

enter image description here

Plus answered 29/6, 2015 at 9:15 Comment(4)
Thank you so much for saving me a bunch of time with this guide. And I also have to configure User Header Search Paths manually in "How to integrate MuPDF into your project" step 3, for example, $(PROJECT_DIR)/MuPDFSample/Bundles/mupdf/include. Just record it here, in case anyone use it someday.Poleax
BTW, for the newest version(1.10a), the static fat library I created is "fat" to 170M+ for libmupdf.a alone... 😂 Is it really large like this?Poleax
I can't create fat libraries from my machine. Please refer the screenshot. Can't open infut file issue found. How can I overcome this? Please clarify, I was struck at the 8th step that you listed.Microfilm
Where is mupdf/platform/ios? Can't find it.Vesical
A
1

It is certainly possible to develop an ebook reader on iphone/ipad using MuPDF.

MuPDF is licensed both under the GNU GPL and under the Artifex commercial license. We have commercial licensees who do use MuPDF to implement ebook readers on ipad.

We also release a version of MuPDF for iOS via the iTunes app store (search for MuPDF) - so despite their sometimes unclear and arbitrary rules about what they will and won't allow, Apple clearly have no problem with "duplicating functionality" as a previous respondent suggested.

As to help with tutorials etc:

  • in the MuPDF source we have a doc directory that contains example source showing how to open/render/close a PDF file. We also have examples there that show how to work in multi-threaded worlds.
  • we have example android/iOS/windows/linux viewers in the source too.
  • we have simple command line tools (again with full source) that show how to render PDFs etc.

I would hope that this is enough to get a competent programmer moving.

While the GNU GPL version is released unsupported, we do offer support contracts to those who want them. Alternatively, pop along to the #ghostscript irc channel and we may be able to help with simple queries (though there is a limit to how much time we can invest in helping any single free user). Or, ask specific questions on here.

Acclamation answered 9/5, 2013 at 11:59 Comment(2)
What is roughly the cost for a developer to use the mupdf library in their closed source, commercial pdf viewer?Sniffle
Every license is different, because every use case is different. Contact [email protected], describe your desired use (the more details the better) and the friendly people there will get back to you with a quote.Acclamation

© 2022 - 2024 — McMap. All rights reserved.