使用MuPDF库在iPhone / iPad上开发电子书阅读器 [英] Develop an ebook reader on iPhone/iPad using MuPDF library

查看:166
本文介绍了使用MuPDF库在iPhone / iPad上开发电子书阅读器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用MuPDF库在iphone / ipad上开发电子书阅读器吗?



你有什么好主意吗?请帮我一些好的教程。

解决方案

对于迟到的答案感到抱歉,但它可以帮助人们一天或另一天。
由于我必须将MuPDF库集成到我的一个(Swift)项目中,我生成
静态胖库并将它们集成到Xcode中。



<你带着一步一步的快速教程:



如何构建静态胖库:




  1. git clone --recursive git://git.ghostscript.com/mupdf.git

  2. 转到 mupdf / platform / ios

  3. 使用Xcode打开 MuPDF.xcodeproj

  4. 配置方案MuPDF定位到发布

  5. 在iPhone模拟器上构建并运行应用程序。


    • 这将生成平台的库 i386 x86_64


  6. 在真实的iPhone设备上构建并运行应用程序 - 使用您自己的软件包ID,证书和配置文件。


    • 这将为平台生成库 armv7 arm64


  7. 转到 mupdf / build /


    • 您将找到两个包含所有内置库的文件夹: release-ios-i386-x86_64 release-ios-armv7-arm64


  8. 现在需要创建包含所有4种体系结构的胖库对于mupdf及其所有依赖项。

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'



如何将MuPDF集成到您的项目中:




  1. 添加/导入项目:


    • 来自<$的所有头文件c $ c> mupdf / include / mupdf

    • 来自 mupdf / platform / ios / classes

    • 来自的常见。[h,m]文件mupdf / platform / ios


  2. 添加/导入先前生成的胖库(8个文件)

  3. 配置库搜索路径通过添加库文件的路径。


    • 例如 $(继承)$(PROJECT_DIR)/外部/ MuPDF / lib /


您现在应该可以使用包含的库来构建和运行您的应用程序。
使用示例项目来了解库的工作原理或任何在线教程。



专业提示:



最终的胖库一共都很大(约46mb)。
你可以通过导入轻松减少应用程序的最终大小:


  1. 在一个发布文件夹下只有lib.a来自 mupdf / build / release-ios-armv7-arm64

  2. 在调试文件夹下,来自的大量生成的胖库mupdf / build /

  3. Debug设置不同的库搜索路径 发布 config。

完成后,你将会能够在每个模拟器和设备上构建并运行 Debug 。但仅适用于发布 的设备。最后,您需要作为您的应用,AppStore
应该只在真实设备上运行。没有必要包含调试模拟器架构静态库。



以下是我的Xcode项目中所有导入文件的屏幕截图:




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.

解决方案

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:

这篇关于使用MuPDF库在iPhone / iPad上开发电子书阅读器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆