Mupdf compile with only pdf support - android

I was working on a lightweight pdf viewer, and I wanted the size to be of the range of 5 MBs,
I am using mupdf , but the compiled .so file itself is around 16.6 MBs,
Is there a way to compile mupdf with only pdf support and not the others like xps, images, etc.
Like this app on google play, the file of .so file is just 3 MBs
https://play.google.com/store/apps/details?id=de.geraldthaler.octopuspdf,
Any help will be greatly appreciated.

I figured, It was because of the font packs,
compiling without extra font packs generates very small .so's

If this is still relevant:
There is a configuration file In MuPDF source that lets you throw out features before you generate the library, called config.h located in directory mupdf/include/fitz.
By setting the appropriate #define statements, XPS, EPUB, etc. can be opted out. The biggest space saver is however opting out certain fonts. In essence you can restrict your library to PDF's Base-14 (Helvetica, Times-Roman, Courier, Symbol and ZapfDingbats) fonts. You also can opt out support for various image format support.
Taking all that together should bring you down well below 5 MB.

Related

Qt Android: Put videos inside app directory files

I have around 10 video files in the sizes of 10 MB each. I want to have them inside the /data/user/0/org.my.app/files. Somehow they need to be included in the .apk and installed here.
Right now they are living in this structure in Qt project:
DISTFILES += \
assets/video/video1.mp4
The goal is to be able to play the videos using
Video {
source: appPath + "/assets/video/video1.mp4"
}
The ideal way is just using .qrc but it has been problems before when putting videos there.
With video, it's usually impractical to try to make it a resource since the size of the QRC will explode and result in long compile times and a large executable.
I've had luck delivering videos with a Qt Android app by using the native Java AssetManager: https://developer.android.com/reference/android/content/res/AssetManager
You'll need to use a CustomActivity in Java-land and integrate with it using JNI as demonstrated here: https://doc.qt.io/qt-5/qtandroidextras-customactivity-example.html
Or as #splaytreez points out you can use Qt's builtin support for Android Assets as documented here: https://doc.qt.io/qt-5/porting-to-android.html
Also, depending on the size of your video and what it does to your APK size, you may want to use the AAB bundle as discussed here: https://developer.android.com/guide/app-bundle/

Android apk file too big when using FFMPeg encoder library

I'm developing an app which creates x264 videos with the following library:
com.arthenica:mobile-ffmpeg-full:4.2.2.LTS
but the result apk file is too big (~71mb), so I tried:
com.arthenica:mobile-ffmpeg-min-gpl:4.2.2.LTS
and this way, as the library downloads only a few codecs -included the ones I need- apk size was reduced to ~49mb, what is much better, but still looks too big to me, so I'd need to know if any of you know a better way to reduce apk size, because people generally refuse to download such big apps
Regarding the rest of the app (drawables, resources and so) they're well optimized, because if I remove this library and rebuild, the size of the app drops to 10mb
I was reading this question:
FFMPEG Android Library Increase Size
and user S.R suggests to compress all cpu architecture models in one archive file and extract target cpu lib based on cpu model on app's directory and load ffmpeg from there, but I really don't know how to do that.
I'm checking my app's folder structure and noticed there are this next folders regarding ffmpeg lib:
arm64-v8a => ~16mb
armeabi-v7a => ~29mb
x86 => ~17mb
x86_64 => ~21mb
But not sure if I could remove any of them, and as you can see armeabi-v7a is the largest.
As per your requirement, FFmpeg is the best option to so much of video processing task but the problem with FFmpeg is it will increase the size of the app. So I will suggest you to compile this FFMPEG library in your project, it also has many inbuilt functions like add music, add image on Video etc. It will definitely help you with your work as well as size is also very small ~11mb.
You can use Android App Bundle (aab) to reduce app size
further.
use
implementation "com.arthenica:mobile-ffmpeg-min:4.4.LTS"
according to documentation

Android Expansion File. How can I put library in expansion file

I am working on an app where we are using lots of libraries to provide funtionalities like reading PDF,docx,ppt etc also we have a youtube player and many more other libraries.
Due to the design of our app, we are using lots of resources to design UI(resources is about 22 mb). We are using these images in layouts (which are lot if you ask).
I checked to see whether we can go down on using Background images, but more we strip them, our client asks for more features to integrate in the app which again increases the size to more then 50 MB (Google play limitation as mentioned here Google play expansion file setup link) .
I am looking for a solution where I can somehow remove the libraries while compiling the app to keep size under limit of 50 MB and put it in expansion file (I know this seems to be a problem, cuz I don't know how I will compile the app without those libraries) and load it on run time .
I am very confused here, Can some one help me here ??

How to reduce size of the APK file generated by Apportable?

I'm using Apportable to port my game and it works fairly well. But there's a problem here now. Apportable seems to link some library when generating the apk package and that makes the .apk file larger. The simplest Spin example's generated .apk file will be nearly 10Mb for this reason. However my game's .apk file has to be smaller than a size given by the publisher, and Apportable makes this size unable to achieve due to the extra 8Mb it added. Is there any way to reduce size of the generated .apk file? Maybe I can unlink some unused libraries but I don't know how to do that. Please help me or I will have to fallback to cocos2d-x and it will be much more troublesome to port the game :(
An Apportable apk file will always be bigger than the corresponding iOS ipa file because unlike on iOS, the apk file needs to include libraries for functionality built into the iOS platform like Foundation, objc, and UIKIt.
Also, because of dynamic nature of Objective C, it is not possible to determine at build time what parts of the libraries could be excluded. In theory, it would be possible to do some library compression on an app specific basis, but it would be time-consuming and error prone and a 10M reduction would likely still be too much to reduce.
More discussion on the Apportable forum.

Processing PDFs to reduce file size / and or complexity

I have PDF files I need to prepare for viewing on mobile devices. The worse case would be ~50 pages, with lots full color images and vector art, file size approx. 40MB. This is acceptable for PC viewing on broadband, but not great for mobile viewing due to long download times and very laggy scrolling on mobile (At least on my overclocked Droid). Are there any tools or libraries for processing the files to simply the vector stuff, downsample/recompress the images, that sort of thing?
Output in pdf format is not absolutely essential, but it needs to be something readable on android and iOS devices without software downloads.
There are a few main things that can blow up the size of a PDF on mobile devices:
hi-resolution pictures (where lo-res would suffice)
embedded fonts (where content would still be readable "good enough" without them)
PDF content not required any more for the current version/view (older version of certain objects)
embedded ICC profiles
embedded third-party files (using the PDF as a container)
embedded job tickets (for printing)
embedded Javascript
and a few more
FOSS software: Ghostscript can try to size down your PDFs, mainy be re-sampling the pictures used and by removing older versions ("generations") of PDF objects which were replaced by newer ones:
gswin32c.exe ^
-o sized-down.pdf ^
-sDEVICE=pdfwrite ^
-dPDFSETTINGS=/ebook ^
-dEmbedAllFonts=false ^
-c ".setpdfwrite <</AlwaysEmbed [ ]>>" ^
-f blown-up.pdf
You can add more parameters to above commandline to size down certain PDFs even more (f.e. by setting a lower max resolution, etc.) Here is an example to enforce a downsampling for color and grayscale images to 72dpi:
gswin32c.exe ^
-o sized-down.pdf ^
-sDEVICE=pdfwrite ^
-dPDFSETTINGS=/ebook ^
-dEmbedAllFonts=false ^
-dColorImageDownsampleThreshold=1.0 ^
-dColorImageDownsampleType=/Average ^
-dColorImageResolution=72 ^
-dGrayImageDownsampleThreshold=1.0 ^
-dGrayImageDownsampleType=/Average ^
-dGrayImageResolution=72 ^
-c ".setpdfwrite <</AlwaysEmbed [ ]>>" ^
-f blown-up.pdf
Commercial+closed source software: callas pdfToolbox4 is able to reduce file sizes even more by applying a custom profile to the PDF downsizing process (it can even un-embed fonts and ICC profiles).
Update 2: See also the following (new) question with the answer:
How can I remove all images from a PDF?
It provides some sample PostScript code which completely removes all (raster) images from the PDF, leaving the rest of the page layout unchanged. This is useful in cases where you do not want the (raster) images, but only the text parts in order to reduce file size.
Adobe Acrobat Professional has two built-in tools for optimizing PDF files:
"PDF Optimizer" - http://www.adobe.com/designcenter/acrobat/articles/acr7optimize.html, which will simplify vectors and removed unneeded content (among other things)
and
"Optimize Scanned PDF" -http://help.adobe.com/en_US/Acrobat/9.0/Standard/WS58a04a822e3e50102bd615109794195ff-7f71.w.html#WS0BEFAC0B-47D9-47b8-9AF8-4DE2FE9C9736.w, which will downsample and compress embedded raster images.
Both are the best tools for what they do that I have used. However, the focus of most PDF optimization tools is to reduce file size not improve rendering speed.
If you want to drastically improve rendering performance on your device you should consider pre-rendering the PDFs to bitmap images. If you scale them up a bit before rasterizing (to allow for on-device zooming) and stick to an indexed color scheme you should be able to produce rasters for each page that are an acceptable file size and resolution. They will draw much more quickly on the device than vector content would.
There are options in Acrobat to reduce image size and improve PDF filesize/speed. Have you looked this option?
Are you planning on the user having the PDF files stored on their phone for viewing offline? If not, could you batch convert the PDF files into HTML? You could also post-process any images to lower the quality/filesize.
Some options for converters include:
Email either a link to the PDF, or the actual PDF to pdf2html#adobe.com. You will receive back an HTML version of the PDF. More info on the Adobe site
Use standalone software such as pdf995 or pdf2html
Use a commercial Adobe Acrobat plugin, such as LD-Converter
I'm sure there are even more options for performing the conversion.
As an outside bet, have you tried viewing your PDF's from your phone using the google online reader?
Some time ago (a few years) I used to reduce the size of PDFs by converting them to djvu (say, through http://any2djvu.djvuzone.org/ or the locally-installed free command-line tools). The results were very nice (small).
At that time, AFAIK, PDF didn't include the support for encodings of the same efficiency in size as djvu, but now I have been told that the PDF format has included the encodings that are as good as djvu. So, there must be tools that do a similarly good optimization for PDF. Look for them.
Or you could distribute djvus, but I'm not sure djvu-reading software is pre-installed in your OSes.
it needs to be something readable on android and iOS devices without software downloads.
You can pre-process your PDF with a tool like k2pdfopt.
It changes this ===================> to this:
______
From its sources, the project started in 2012.

Categories

Resources