GithubHelp home page GithubHelp logo

vikassandhu999 / flutter_pdf_compressor Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 3.0 75 KB

A flutter plugin to compress pdf files offline. (Android only)

Home Page: https://pub.dev/packages/pdf_compressor

License: BSD 3-Clause "New" or "Revised" License

Java 71.85% Swift 3.73% Objective-C 2.92% Dart 18.00% Ruby 3.51%
java dart flutter itext5

flutter_pdf_compressor's Introduction

pdf_compressor

A plugin to compress pdf files locally works for android only.

Getting Started

import

import 'package:pdf_compressor/pdf_compressor.dart';

usage

await PdfCompressor.compressPdfFile(inputFilePath, outputFilePath, CompressQuality.MEDIUM);

flutter_pdf_compressor's People

Contributors

bluntmess avatar vikassandhu999 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flutter_pdf_compressor's Issues

Memory Error- SIGBUS Signal

i am encountering the following error:

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'POCO/munch_in/munch:12/SKQ1.211006.001/V13.0.4.0.SLMINXM:user/release-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2023-09-11 13:59:43.555066995+0530
Process uptime: 0s
Cmdline: com.spirikle.scanclan
pid: 22197, tid: 22197, name: irikle.scanclan  >>> com.spirikle.scanclan <<<
uid: 10643
signal 7 (SIGBUS), code 2 (BUS_ADRERR), fault addr 0x6fe9b3f3d0
    x0  0000000012d980c4  x1  0000006fe9b3f3d0  x2  000000000000003e  x3  00000072218ad5c8
    x4  0000006fe9b3f40e  x5  0000000012d98102  x6  0000006fe9b3f3d0  x7  00000000000003d0
    x8  0000000012d980b8  x9  000000000000003d  x10 0000000000000000  x11 0000000000000000
    x12 000000000000be98  x13 0000007222216000  x14 000000000000776e  x15 b4000072d98a2a00
    x16 00000072220105f8  x17 00000072d6120810  x18 0000000000000001  x19 000000000000003e
    x20 0000006fe9b3f3d0  x21 0000000000000000  x22 b4000072d9915280  x23 0000007fd694ca30
    x24 b4000072d9920800  x25 0000007fd694cae8  x26 00000072d9b55000  x27 0000007fd694cc80
    x28 00000072d9b55000  x29 0000007fd694ca60
    lr  0000007221cff7f4  sp  0000007fd694ca20  pc  00000072d61206c4  pst 0000000080001000
backtrace:
      #00 pc 00000000000876c4  /apex/com.android.runtime/lib64/bionic/libc.so (__memcpy+36) (BuildId: d15a6afaad4d7e44de8683bcf906a6bd)
      #01 pc 00000000004ff7f0  /apex/com.android.art/lib64/libart.so (void art::JNI<true>::SetPrimitiveArrayRegion<_jbyteArray*, signed char, art::mirror::PrimitiveArray<signed char> >(_JNIEnv*, _jbyteArray*, int, int, signed char const*)+196) (BuildId: 6fc1c03912861b04885c9f2953121b6b)
      #02 pc 00000000004953a8  /apex/com.android.art/lib64/libart.so (art::(anonymous namespace)::CheckJNI::SetPrimitiveArrayRegion(char const*, art::Primitive::Type, _JNIEnv*, _jarray*, int, int, void const*) (.__uniq.99033978352804627313491551960229047428)+288) (BuildId: 6fc1c03912861b04885c9f2953121b6b)
      #03 pc 0000000000325e34  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (art_jni_trampoline+116)
Lost connection to device.

Flutter Doctor Output:

flutter doctor -v
[√] Flutter (Channel stable, 3.3.9, on Microsoft Windows [Version 10.0.22621.2134], locale en-CA)
    • Flutter version 3.3.9 on channel stable at C:\src\flutter\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b8f7f1f986 (10 months ago), 2022-11-23 06:43:51 +0900
    • Engine revision 8f2221fbef
    • Dart version 2.18.5
    • DevTools version 2.15.0

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\Admin\AppData\Local\Android\sdk
    • Platform android-33, build-tools 30.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.5)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.2.32616.157
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)

[√] VS Code (version 1.82.0)
    • VS Code at C:\Users\Admin\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (4 available)
    • 22021211RI (mobile) • 15693259 • android-arm64  • Android 12 (API 31)
    • Windows (desktop)   • windows  • windows-x64    • Microsoft Windows [Version 10.0.22621.2134]
    • Chrome (web)        • chrome   • web-javascript • Google Chrome 116.0.5845.180
    • Edge (web)          • edge     • web-javascript • Microsoft Edge 116.0.1938.76

[√] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

I encounter this error when the following code is run:

await PdfCompressor.compressPdfFile(
        file.path, file.path, CompressQuality.MEDIUM);

[Feature Request] Don't use main thread for compressing pdf

UI is freezing and receiving these logs:

I/aster_null_saf(18939): Background concurrent copying GC freed 1613063(49MB) AllocSpace objects, 87(3948KB) LOS objects, 46% free, 27MB/51MB, paused 387us total 196.274ms
I/aster_null_saf(18939): Background young concurrent copying GC freed 1114436(26MB) AllocSpace objects, 91(1620KB) LOS objects, 46% free, 27MB/51MB, paused 456us total 120.659ms
I/aster_null_saf(18939): Background concurrent copying GC freed 210798(18MB) AllocSpace objects, 525(10MB) LOS objects, 48% free, 25MB/49MB, paused 284us total 110.682ms
I/aster_null_saf(18939): Background young concurrent copying GC freed 56200(13MB) AllocSpace objects, 524(10MB) LOS objects, 48% free, 25MB/49MB, paused 277us total 106.931ms
I/aster_null_saf(18939): Background concurrent copying GC freed 107515(15MB) AllocSpace objects, 546(11MB) LOS objects, 48% free, 25MB/49MB, paused 287us total 266.379ms
I/aster_null_saf(18939): Background concurrent copying GC freed 84190(14MB) AllocSpace objects, 534(11MB) LOS objects, 47% free, 26MB/50MB, paused 278us total 262.975ms
I/Choreographer(18939): Skipped 347 frames! The application may be doing too much work on its main thread.

Update

Please can you update your packages for near versions of flutter, and please make it for work also in WEB.

plugin is crashing and creating large files in some cases

Issue: Tried compressing the attached pdf file of size 20.7 MB (approx) but the resultant pdf size I got was 103MB (approx.). The pdf consists of 618 pages with images so I think the plugin is not working well with images.

Also, the plugin crashes sometimes when trying to process large pdf files like this.

Pdf file: A17_FlightPlan.pdf

Thanks.

[Issue] Cant compress specific pdf

This pdf can't be compressed through this plugin - c4611_sample_explain.pdf

Receiving following errors:

W/System.err(18939): com.itextpdf.text.exceptions.BadPasswordException: PdfReader not opened with owner password
W/System.err(18939): at com.itextpdf.text.pdf.PdfStamperImp.(PdfStamperImp.java:168)
W/System.err(18939): at com.itextpdf.text.pdf.PdfStamper.(PdfStamper.java:98)
W/System.err(18939): at com.kaizen404.pdf_compressor.PdfCompressorPlugin$CompressPdf.saveCompressedPdfFromReader(PdfCompressorPlugin.java:83)
W/System.err(18939): at com.kaizen404.pdf_compressor.PdfCompressorPlugin$CompressPdf.run(PdfCompressorPlugin.java:78)
W/System.err(18939): at com.kaizen404.pdf_compressor.PdfCompressorPlugin.onMethodCall(PdfCompressorPlugin.java:43)
W/System.err(18939): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
W/System.err(18939): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
W/System.err(18939): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
W/System.err(18939): at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err(18939): at android.os.MessageQueue.next(MessageQueue.java:335)
W/System.err(18939): at android.os.Looper.loop(Looper.java:183)
W/System.err(18939): at android.app.ActivityThread.main(ActivityThread.java:7656)
W/System.err(18939): at java.lang.reflect.Method.invoke(Native Method)
W/System.err(18939): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
W/System.err(18939): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.