Giter Club home page Giter Club logo

pdfiumandroid's Issues

Update of support library

Hi, did you consider to update support library dependency in your project? I get that due to this action this library will have support only for apps with min sdk 14, but nowadays this is enough.

Also on this years Google IO, Google announced that apps has to target at least sdk 26, and it is good practice to keep support libraries at the same version as compileSdk.

Now i have to keep support library version in my app on version 25.3.1 the same as yours, because all support libraries has to have exact same version.

Random Crash on parser

Hello,

I have a frequent crash but hard to reproduce on a specific pdf.
It is reported on Android 5, 6 and 7. Fortunaly I have a device with debug symbole.
This is the stack trace on my device:

04-29 20:09:59.832 7639-7918/? A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x10 in tid 7918 (pool-3-thread-2)
04-29 20:09:59.920 8325-8325/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    LineageOS Version: '14.1-20180324-NIGHTLY-oneplus2'
    Build fingerprint: 'OnePlus/OnePlus2/OnePlus2:6.0.1/MMB29M/1447858500:user/release-keys'
04-29 20:09:59.921 8325-8325/? A/DEBUG: Revision: '0'
    ABI: 'arm64'
    pid: 7639, tid: 7918, name: pool-3-thread-2 
    signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x10
        x0   0000000000000000  x1   0000000000000004  x2   0000000000000200  x3   0000000000000000
        x4   0000000000000000  x5   0000000000000004  x6   0000000000000000  x7   0000007fa8663420
        x8   0000007faabad000  x9   0000000000000004  x10  0000000000000006  x11  0000000000000006
        x12  0000007fa5f84c10  x13  000000000000000c  x14  000000007179fe70  x15  0000000000000000
        x16  0000007faaba1da0  x17  0000007faa7d1a8c  x18  00000000000001f8  x19  0000007f83dd81e0
        x20  0000007f83dd81f8  x21  0000007f83dd8230  x22  0000007f83dd8250  x23  0000000000000000
        x24  d2f04564234501ea  x25  0000000046445025  x26  0000000000000000  x27  d2f04564234501ea
        x28  000000000000000a  x29  0000007f882f8b80  x30  0000007faa80caf8
        sp   0000007f882f8b50  pc   0000007faa80caf8  pstate 0000000080000000
04-29 20:09:59.940 8325-8325/? A/DEBUG: backtrace:
        #00 pc 0000000000152af8  /system/lib64/libpdfium.so (_ZN13CPDF_DocumentC2EP11CPDF_Parser+96)
        #01 pc 000000000015eb1c  /system/lib64/libpdfium.so (_ZN11CPDF_Parser10StartParseEP12IFX_FileReadii+512)
        #02 pc 00000000000cd978  /system/lib64/libpdfium.so (FPDF_LoadCustomDocument+112)
        #03 pc 000000000011e4f8  /system/lib64/libandroid_runtime.so
        #04 pc 0000000075388c7c  /data/dalvik-cache/arm64/system@[email protected] (offset 0x29b1000)

Load pdf from byte array

Is it possible to add this option? (i think it can be done with "FPDF_LoadMemDocument" function instead of "FPDF_LoadMemDocument").
It will be nice option in secure cases.

Logs in release

Hi,

I've noticed that even in release mode, the logs of PdfiumAndroid are displayed (in your other library AndroidPdfViewer). For example:

D/jniPdfium(18482): Canvas Ver: 256
D/jniPdfium(18482): Draw Hor: 1536
D/jniPdfium(18482): Draw Ver: 2048
D/jniPdfium(18482): Start X: -1024
D/jniPdfium(18482): Start Y: -1792
D/jniPdfium(18482): Canvas Hor: 256
D/jniPdfium(18482): Canvas Ver: 256
D/jniPdfium(18482): Draw Hor: 1536
D/jniPdfium(18482): Draw Ver: 2048
D/jniPdfium(18482): Start X: -1280
D/jniPdfium(18482): Start Y: -1792

Could it be possible to remove the logs (at least for the release)?

Thank you (and thank you for the great work!)

Getting A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0

Hi,

Unfortunately, I am facing below issue while opening the first page of the pdf file which is 3.7MB :

D/CacheImageTasks: File is Readable:file:/storage/sdcard0/Download/Books/wrox-professional-java-development-with-the-spring-framework.pdf
01-26 23:20:30.124 16333-16439/com.sagarrathod.bibliophile D/jniPdfium: Init FPDF library
01-26 23:20:30.158 16333-16439/com.sagarrathod.bibliophile A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 16439 (AsyncTask #3)

java.io.IOException: File is empty

I'm writing a print service to convert a pdf document page into image (bitmap). latter its bitmap will be print using esc pos command.
Here is method that I use in my print service, most code from your sample. DedetLogger just Android android.util.Log to simplify printing output.

    @Override
    protected void onPrintJobQueued(PrintJob printJob) {
        DedetLogger.Info(LOG_TAG, "onPrintJobQueued");
        printJob.start(); // to tell system printing is starting


        // https://github.com/barteksc/PdfiumAndroid
        ParcelFileDescriptor fd = printJob.getDocument().getData();
        fd.parseMode("r");

        //PdfiumCore pdfiumCore = new PdfiumCore(this);
        PdfiumCore pdfiumCore = new PdfiumCore(getApplicationContext());


        try {
            DedetLogger.Info(LOG_TAG, "Input Stream");
            InputStream fileStream = new FileInputStream(fd.getFileDescriptor());
            byte[] tmp = new byte[4];
            fileStream.read(tmp,0,4);
            //byte[] b = s.getBytes("UTF-8"); // string to byte
            String s = new String(tmp); // byte to strint
            DedetLogger.Info(LOG_TAG, "4bytes: "+s); // output: /com.dedetok.mypdf I/PS: 4bytes: %PDF i.e. file exist

            DedetLogger.Info(LOG_TAG, "#create PDFDocument object");
            com.shockwave.pdfium.PdfDocument pdfDocument = pdfiumCore.newDocument(fd); 
            // Error: /com.dedetok.mypdf W/System.err: java.io.IOException: File is empty

            int pageNum=1;
            DedetLogger.Info(LOG_TAG, "#open page 1");
            pdfiumCore.openPage(pdfDocument, pageNum);
            int width = pdfiumCore.getPageWidthPoint(pdfDocument, pageNum);
            int targetW = 57;
            int height = pdfiumCore.getPageHeightPoint(pdfDocument, pageNum);
            int targetH = height*width/57;

            DedetLogger.Info(LOG_TAG, "#render page 1 into bitmap");
            Bitmap bitmap = Bitmap.createBitmap(targetW, targetH, Bitmap.Config.ARGB_8888);
            pdfiumCore.renderPageBitmap(pdfDocument, bitmap, pageNum, 0, 0, targetW, targetH);
            DedetLogger.Info(LOG_TAG, "Render pdf to image done no error.");

            com.shockwave.pdfium.PdfDocument.Meta meta = pdfiumCore.getDocumentMeta(pdfDocument);
            DedetLogger.Info(LOG_TAG, "title = " + meta.getTitle());
            DedetLogger.Info(LOG_TAG, "author = " + meta.getAuthor());
            DedetLogger.Info(LOG_TAG, "subject = " + meta.getSubject());
            DedetLogger.Info(LOG_TAG, "keywords = " + meta.getKeywords());
            DedetLogger.Info(LOG_TAG, "creator = " + meta.getCreator());
            DedetLogger.Info(LOG_TAG, "producer = " + meta.getProducer());
            DedetLogger.Info(LOG_TAG, "creationDate = " + meta.getCreationDate());
            DedetLogger.Info(LOG_TAG, "modDate = " + meta.getModDate());

            printBookmarksTree(pdfiumCore.getTableOfContents(pdfDocument), "-");


            pdfiumCore.closeDocument(pdfDocument); // important!
            fd.close();

        } catch (IOException e) {
            e.printStackTrace();
        }

        printJob.complete(); // to tell system printing is starting
        DedetLogger.Info(LOG_TAG, "Print Job Completed");


    }
    void printBookmarksTree(List<PdfDocument.Bookmark> tree, String sep) {
        for (com.shockwave.pdfium.PdfDocument.Bookmark b : tree) {

            DedetLogger.Info(LOG_TAG, String.format("%s %s, p %d", sep, b.getTitle(), b.getPageIdx()));

            if (b.hasChildren()) {
                printBookmarksTree(b.getChildren(), sep + "-");
            }
        }
    }

This is the error:
com.shockwave.pdfium.PdfDocument pdfDocument = pdfiumCore.newDocument(fd);
// Error: /com.dedetok.mypdf W/System.err: java.io.IOException: File is empty

59:13.714 4298-4298/com.dedetok.mypdf I/PS: #create PDFDocument object
08-29 21:59:13.778 4298-4298/com.dedetok.mypdf W/System.err: java.io.IOException: File is empty
08-29 21:59:13.782 4298-4298/com.dedetok.mypdf W/System.err: at com.shockwave.pdfium.PdfiumCore.nativeOpenDocument(Native Method)
08-29 21:59:13.782 4298-4298/com.dedetok.mypdf W/System.err: at com.shockwave.pdfium.PdfiumCore.newDocument(PdfiumCore.java:105)
08-29 21:59:13.782 4298-4298/com.dedetok.mypdf W/System.err: at com.shockwave.pdfium.PdfiumCore.newDocument(PdfiumCore.java:98)
08-29 21:59:13.782 4298-4298/com.dedetok.mypdf W/System.err: at com.dedetok.mypdf.DedetPrintService.onPrintJobQueued(DedetPrintService.java:86)
08-29 21:59:13.782 4298-4298/com.dedetok.mypdf W/System.err: at android.printservice.PrintService$ServiceHandler.handleMessage(PrintService.java:516)
08-29 21:59:13.782 4298-4298/com.dedetok.mypdf W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
08-29 21:59:13.782 4298-4298/com.dedetok.mypdf W/System.err: at android.os.Looper.loop(Looper.java:136)
08-29 21:59:13.782 4298-4298/com.dedetok.mypdf W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5001)
08-29 21:59:13.782 4298-4298/com.dedetok.mypdf W/System.err: at java.lang.reflect.Method.invokeNative(Native Method)
08-29 21:59:13.782 4298-4298/com.dedetok.mypdf W/System.err: at java.lang.reflect.Method.invoke(Method.java:515)
08-29 21:59:13.782 4298-4298/com.dedetok.mypdf W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
08-29 21:59:13.782 4298-4298/com.dedetok.mypdf W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
08-29 21:59:13.782 4298-4298/com.dedetok.mypdf W/System.err: at dalvik.system.NativeStart.main(Native Method)

Can you help me to solve it, please.

Why output Bitmap is smaller and scaled in 2,78 times?

PdfiumCore pdfiumCore = new PdfiumCore(context);
   try {
       PdfDocument pdfDocument = pdfiumCore.newDocument(fd);

       pdfiumCore.openPage(pdfDocument, pageNum);

       int width = pdfiumCore.getPageWidthPoint(pdfDocument, pageNum);
       int height = pdfiumCore.getPageHeightPoint(pdfDocument, pageNum);

       // ARGB_8888 - best quality, high memory usage, higher possibility of OutOfMemoryError
       // RGB_565 - little worse quality, twice less memory usage
       Bitmap bitmap = Bitmap.createBitmap(width, height,
               Bitmap.Config.RGB_565);
       pdfiumCore.renderPageBitmap(pdfDocument, bitmap, pageNum, 0, 0,
               width, height);
       //if you need to render annotations and form fields, you can use
       //the same method above adding 'true' as last param

       pdfiumCore.closeDocument(pdfDocument); // important!

bitmap is smaller in 2,78 times then source image in pdf , why?

Support Android Gradle plugin 3.+

With the release of the Android Gradle 3 plugin and Android Studio 3 we can leverage the new build tools as well as built in C/C++ support in the editor. I did the leg work on this in a branch so I could test my own custom built versions of the libpdfium.so

Pros

  • With the NDK and Cmake installed from the Sdk Manager, the JNI and thus the AAR can be built without needing the extra manual ndk-build step.
  • Switching to Cmake allows the build tools to build the JNI multiple times for multiple platform levels automagically (or that's how I understand it)
  • All the free IDE features work properly now

Cons

  • Requires switching to API 14 minimum, however, API 9 is basically dead anyways

Would you be interested in merging this? If so I can open a PR for it.

Ref: https://github.com/ToxicBakery/PdfiumAndroid/tree/feature/test-custom-pdfium

Fatal signal 11

Good day!

Getting Fatal signal 11 at opening 70 mb size pdf.

Error - A/libc: Fatal signal 11 (SIGSEGV), code 128, fault addr 0x0 in tid 7413 (AsyncTask #4)



Stacktrace:

pid: 32022, tid: 32308, name: AsyncTask #4 >>> package.name <<< <br />signal 11 (SIGSEGV), code 128 (SI_KERNEL), fault addr 0x0 <br /> eax 00000000 ebx d4e9c20c ecx 00000000 edx cde485b8 <br /> esi 00000000 edi 00000001 <br /> xcs 00000023 xds 0000002b xes 0000002b xfs 000000ff xss 0000002b <br /> eip d4c125a0 ebp d44f8df8 esp d44f8dbc flags 00210246 <br /> <br />backtrace: <br /> #00 pc 002af5a0 /data/app/package.name-1/lib/x86/libmodpdfium.so <br /> #01 pc 002b2990 /data/app/package.name-1/lib/x86/libmodpdfium.so (opj_dwt_decode_real+1456) <br /> #02 pc 002029ee /data/app/package.name-1/lib/x86/libmodpdfium.so (opj_tcd_decode_tile+414) <br /> #03 pc 001f161b /data/app/package.name-1/lib/x86/libmodpdfium.so (opj_j2k_decode_tile+123) <br /> #04 pc 001f1b67 /data/app/package.name-1/lib/x86/libmodpdfium.so <br /> #05 pc 001e56b4 /data/app/package.name-1/lib/x86/libmodpdfium.so (opj_j2k_decode+180) <br /> #06 pc 001f8360 /data/app/package.name-1/lib/x86/libmodpdfium.so (opj_jp2_decode+80) <br /> #07 pc 001f529f /data/app/package.name-1/lib/x86/libmodpdfium.so (opj_decode+63) <br /> #08 pc 00149a74 /data/app/package.name-1/lib/x86/libmodpdfium.so (CJPX_Decoder::Init(unsigned char const*, int)+532) <br /> #09 pc 00149bf9 /data/app/package.name-1/lib/x86/libmodpdfium.so (CCodec_JpxModule::CreateDecoder(unsigned char const*, unsigned int, int)+73) <br /> #10 pc 0011dd61 /data/app/package.name-1/lib/x86/libmodpdfium.so (CPDF_DIBSource::LoadJpxBitmap()+129) <br /> #11 pc 0011e9f3 /data/app/package.name-1/lib/x86/libmodpdfium.so (CPDF_DIBSource::CreateDecoder()+579) <br /> #12 pc 00120c87 /data/app/package.name-1/lib/x86/libmodpdfium.so (CPDF_DIBSource::StartLoadDIBSource(CPDF_Document*, CPDF_Stream const*, int, CPDF_Dictionary*, CPDF_Dictionary*, int, unsigned int, int)+487) <br /> #13 pc 001172c9 /data/app/package.name-1/lib/x86/libmodpdfium.so (CPDF_ImageCache::StartGetCachedBitmap(CPDF_Dictionary*, CPDF_Dictionary*, int, unsigned int, int, CPDF_RenderStatus*, int, int)+169) <br /> #14 pc 001173b2 /data/app/package.name-1/lib/x86/libmodpdfium.so (CPDF_PageRenderCache::StartGetCachedBitmap(CPDF_Stream*, int, unsigned int, int, CPDF_RenderStatus*, int, int)+130) <br /> #15 pc 00120ec9 /data/app/package.name-1/lib/x86/libmodpdfium.so (CPDF_ProgressiveImageLoaderHandle::Start(CPDF_ImageLoader*, CPDF_ImageObject const*, CPDF_PageRenderCache*, int, unsigned int, int, CPDF_RenderStatus*, int, int)+121) <br /> #16 pc 00121032 /data/app/package.name-1/lib/x86/libmodpdfium.so (CPDF_ImageLoader::StartLoadImage(CPDF_ImageObject const*, CPDF_PageRenderCache*, void*&, int, unsigned int, int, CPDF_RenderStatus*, int, int)+130) <br /> #17 pc 001184f3 /data/app/package.name-1/lib/x86/libmodpdfium.so (CPDF_ImageRenderer::StartLoadDIBSource()+179) <br /> #18 pc 0011a3cd /data/app/package.name-1/lib/x86/libmodpdfium.so (CPDF_ImageRenderer::Start(CPDF_RenderStatus*, CPDF_PageObject const*, CFX_Matrix const*, int, int)+173) <br /> #19 pc 00115a10 /data/app/package.name-1/lib/x86/libmodpdfium.so (CPDF_RenderStatus::ContinueSingleObject(CPDF_PageObject const*, CFX_Matrix const*, IFX_Pause*)+400) <br /> #20 pc 00115bee /data/app/package.name-1/lib/x86/libmodpdfium.so (CPDF_ProgressiveRenderer::Continue(IFX_Pause*)+414) <br /> #21 pc 00115f51 /data/app/package.name-1/lib/x86/libmodpdfium.so (CPDF_ProgressiveRenderer::Start(CPDF_RenderContext*, CFX_RenderDevice*, CPDF_RenderOptions const*, IFX_Pause*, int)+129) <br /> #22 pc 00082352 /data/app/package.name-1/lib/x86/libmodpdfium.so (FPDF_RenderPage_Retail(CRenderContext*, void*, int, int, int, int, int, int, int, IFSDK_PAUSE_Adapter*)+626) <br /> #23 pc 00082d99 /data/app/package.name-1/lib/x86/libmodpdfium.so (FPDF_RenderPageBitmap+345) <br /> #24 pc 0000654b /data/app/package.name-1/lib/x86/libjniPdfium.so (Java_com_shockwave_pdfium_PdfiumCore_nativeRenderPageBitmap+779) <br /> #25 pc 002c9ded /data/dalvik-cache/x86/data@[email protected]@[email protected]



Thanks for your help.

Best, Nick.

How to put a marker on a PDF

Hello
I'm currenty developping an application on Android with AndroidPDFViewer : https://github.com/barteksc/AndroidPdfViewer

I want to create a fonctionnality, when the user touch the screen, it put a point on the PDF at this location. After I want to mesure the distance between 2 points but it's an other problem.
I don't understand how to do this funtionnality, put a point on PDF. I found this : DImuthuUpe/AndroidPdfViewer#554
So it's possible but how ? I don't get it.
I suppose I need to create a bitmap.

Thanks for your time.

Syncronize with upstream?

The library seems to have problems rendering certain pdf while the normal android viewer does not show the problem.

Shutting down after loading about 80 pages without Exception

Activity which use this library finishing without Exceptions after paging heavy pdf-document (magazine) for many times (about 80 pages).

Here is Log:

11-03 13:15:09.302 909-1240/system_process E/InputDispatcher﹕ channel '2c1798f6 com.shockwave.pdfiumtest/com.shockwave.pdfiumtest.PdfActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
11-03 13:15:10.094 15037-15154/com.google.android.gms.persistent E/MDM﹕ [336905] b.run: Couldn't connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null, message=null}
11-03 13:15:10.097 15037-15037/com.google.android.gms.persistent E/GmsWearableLS﹕ GoogleApiClient connection failed: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null, message=null}
11-03 13:15:10.421 15037-15037/com.google.android.gms.persistent E/ctxmgr﹕ [PowerConnectionState]Could not write powerInfo=Plug state: 2 BatteryLevel: 0.88, status=Status{statusCode=unknown status code: 7503, resolution=null}
11-03 13:15:10.489 15037-15397/com.google.android.gms.persistent E/MDM﹕ [336937] b.run: Couldn't connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null, message=null}
11-03 13:15:10.563 15037-15403/com.google.android.gms.persistent E/MDM﹕ [336938] b.run: Couldn't connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null, message=null}
11-03 13:15:10.647 909-1250/system_process E/WifiStateMachine﹕ WifiStateMachine CMD_START_SCAN source -2 txSuccessRate=6,93 rxSuccessRate=28,47 targetRoamBSSID=00:00:00:00:00:00 RSSI=-62
11-03 13:15:10.650 909-1250/system_process E/WifiStateMachine﹕ WifiStateMachine starting scan for "airport 5GHz"WPA_PSK with 5240,2412
11-03 13:15:11.013 15037-15459/com.google.android.gms.persistent E/MDM﹕ [336939] b.run: Couldn't connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null, message=null}
11-03 13:15:11.114 15071-15083/com.google.process.gapps E/DataBuffer﹕ Internal data leak within a DataBuffer object detected! Be sure to explicitly call release() on all DataBuffer extending objects when you are done with them. (internal object: com.google.android.gms.common.data.DataHolder@15ab4d6)
11-03 13:15:11.116 15071-15083/com.google.process.gapps E/DataBuffer﹕ Internal data leak within a DataBuffer object detected! Be sure to explicitly call release() on all DataBuffer extending objects when you are done with them. (internal object: com.google.android.gms.common.data.DataHolder@3ad55da)
11-03 13:15:11.117 15071-15083/com.google.process.gapps E/DataBuffer﹕ Internal data leak within a DataBuffer object detected! Be sure to explicitly call release() on all DataBuffer extending objects when you are done with them. (internal object: com.google.android.gms.common.data.DataHolder@1cac6a3)
11-03 13:15:11.118 15071-15083/com.google.process.gapps E/DataBuffer﹕ Internal data leak within a DataBuffer object detected! Be sure to explicitly call release() on all DataBuffer extending objects when you are done with them. (internal object: com.google.android.gms.common.data.DataHolder@1436f1f)
11-03 13:15:11.119 15071-15083/com.google.process.gapps E/DataBuffer﹕ Internal data leak within a DataBuffer object detected! Be sure to explicitly call release() on all DataBuffer extending objects when you are done with them. (internal object: com.google.android.gms.common.data.DataHolder@28bc536)
11-03 13:15:11.120 15071-15083/com.google.process.gapps E/DataBuffer﹕ Internal data leak within a DataBuffer object detected! Be sure to explicitly call release() on all DataBuffer extending objects when you are done with them. (internal object: com.google.android.gms.common.data.DataHolder@25cfb1e)

how stop

how to stop pdfiumCore.renderPageBitmap.

Can not release the memory of loaded bitmap

Hi, thanks in advance for the great effort on this project. I have a question about how to release the bitmap object cause I couldn't find any relative method in code. I wanna switch page in the ImageView, so I use PdfiumCore.openPage(pdfDocument, pageNum) with specify page number and release the old bitmap of the previous page. But I found that even I call bitmap.recycle(), the memory usage in Android Profiler keep going up. Most importantly, it's useless to force run gc().

I just want to know how to release the previous page to prevent OOM. Thanks again, hope to hear good news ASAP.

    ParcelFileDescriptor fd = open(SAMPLE_FILE);
    if (fd == null) {
        return;
    }
    pageNum = 0;
    pdfiumCore = new PdfiumCore(this);
    try {
        pdfDocument = pdfiumCore.newDocument(fd);

        pdfiumCore.openPage(pdfDocument, pageNum);

        width = pdfiumCore.getPageWidthPoint(pdfDocument, pageNum);
        height = pdfiumCore.getPageHeightPoint(pdfDocument, pageNum);
        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
        mBitmap = bitmap;
        bitmap = null;
        pdfiumCore.renderPageBitmap(pdfDocument, mBitmap, pageNum, 0, 0, width, height);

        mBigImage.setImageBitmap(mBitmap);
        //pdfiumCore.closeDocument(pdfDocument); // important!
    } catch (IOException ex) {
        ex.printStackTrace();
    }

Signature not rendered on pdf

I am currently using this library in order to render the pages of my pdf documents - it's very fast and efficient.
However, visible signatures are not rendered and therefore they are not visible on the bitmap that shows the content of a pdf page.
This is the code I use to render the pdf pages into bitmaps:

     File pdfFile = new File(pdfPath);
     ParcelFileDescriptor fileDescriptor = ParcelFileDescriptor.open(pdfFile, ParcelFileDescriptor.MODE_READ_ONLY);
      PdfiumCore pdfiumCore = new PdfiumCore(this);
      PdfDocument pdfDocument = pdfiumCore.newDocument(fileDescriptor); 
      List<Bitmap> previewList = = new ArrayList<Bitmap>();
      for(int pageNum=0; pageNum < pdfiumCore.getPageCount(pdfDocument); pageNum++){
      pdfiumCore.openPage(pdfDocument, pageNum);
      int width = pdfiumCore.getPageWidthPoint(pdfDocument, pageNum);
      int height = pdfiumCore.getPageHeightPoint(pdfDocument, pageNum);

      Bitmap bitmap = Bitmap.createBitmap(width*2, height*2, Bitmap.Config.ARGB_8888);
      pdfiumCore.renderPageBitmap(pdfDocument, bitmap, pageNum, 0, 0, width*2, height*2);

      previewList.add(bitmap);
    }

(then i set the first bitmap as the background image of a custom ImageView)

This is an example of pdf document whose signature is not correctly rendered:
pdf-test[1].pdf

Is there a way to overcome this issue?
Thanks for your time and patience,
Alberto

First cell on page rendering takes too much time

First cell on page rendering takes much more time than other. Is it an issue? Can it be fixed?

long startTime = System.nanoTime();
final Bitmap = proceed(task);
Log.d("RENDER", task.thumbnail + " time:" + ((System.nanoTime() - startTime) / 1000000) + "ms");

screenshot from 2018-10-24 19-15-46

How to merge the library with other native libraries

Hello,

I am working on a project where PDF library is needed as well as offline maps feature is neede. For offline maps we are using Maps.me which is based on a native library written on C++. Initially I added PdfiumAndroid through gradle and it working pretty smooth. Now, when I added maps code into this, it started crashing for armeabi-v8a, x86_64 devices as maps is only supported for armeabi-v7a and x86 devices. Then I narrowed down Pdfium support for only those two architectures and tried to build with two native libraries at the same place. But it is not able to find the actual methods in native from java. Can you please help me out that how can I build both the libraries with the support for all the devices.

Thanks in advance.

Heavy library

The library add ~18Mo to apk, it's a lot.
Can we reduce the size ?

support armeabi

Hi,
Some other native libraries(not open source) only support armeabi.
When use PdfiumAndroid together,there are merge problem.
Can PdfiumAndroid support aremabi ?

transparent background

Hello again!

Original PdfRendered produce transparent Bitmaps, it is easy to change paper for reader applications. But your version of the library, produce solid while as background, no matter if I change Bitmap config to RGB_8888.

Can original PdfRenderer functionaly be restored to produce transparent background for output Bitmap's?

C++ Library Support

Have you had a chance to look into this?

You're using gnustl_static as your STL. According to this, that means users of PdfiumAndroid (including AndroidPdfViewer) can't use C++ anywhere else in their projects. I have to do just that.

If I were to build a version around c++_shared (which seems the preferred version these days), would this be something you'd merge?

RICHMEDIA support?

How to support for richmedia content embedded inside the PDF? Any suggestion will be appreciated.

Whether link support can be extended to this richmedia functionality?

original cpp source code

Hello!

Where can I found source code for the binary files you attached in the repo? I want to recompile it and see source (commit revs) for for three libraries: libmodpdfium.so, libmodft2.so, libmodpng.so

Or you do not have source, except link you provided?

mips64 support

Can the next version include mips64 support, or is this an intentional decision to reduce APK size (since mips64 is still uncommon)?

mips64

maven uploades does not contain mips64 libraries. Not like we need it, or here is a mips devices at all :)

But since you have mips32 builded, and google recently announed all apps should have 64 bit support added to all arch's, why not to add one more mips64 to to build config?

Signature field flattening is not working

I'm using this code in my app to flatten a PDF with signatures added.

PdfiumCore pdfiumCore = new PdfiumCore(context);
ParcelFileDescriptor pfd = ParcelFileDescriptor.open(myFile, ParcelFileDescriptor.MODE_READ_ONLY);
PdfDocument pdfDocument = pdfiumCore.newDocument(pfd);

pdfiumCore.openPage(pdfDocument, page);

int width = pdfiumCore.getPageWidthPoint(pdfDocument, page);
int height = pdfiumCore.getPageHeightPoint(pdfDocument, page);

Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
pdfiumCore.renderPageBitmap(pdfDocument, bitmap, page, 0, 0, width, height);

But the resulting image created from the bitmap object won't have the signature fields drawn. Can i do something to add those signature fields to the flattening process?

Thanks
Mat

dlopen failed in Android 5.1

art dlopen("/data/data/xxx/app_libs/arm64-v8a/libmodft2.so", RTLD_LAZY) failed: dlopen failed: library "libmodpng.so" not found
java.lang.UnsatisfiedLinkError: dlopen failed: library "libmodpng.so" not found
at java.lang.Runtime.load(Runtime.java:332)
at java.lang.System.load(System.java:981)
at com.shockwave.pdfium.PdfiumCore.loadLibrary(PdfiumCore.java:45)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:133)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Error 20:51:46.017 828 10302 GED Failed to get GED Log Buf, err(0)

Core initialization

Core initialisation can be simplified to:

public PdfiumCore() {
     mCurrentDpi = Resources.getSystem().getDisplayMetrics().densityDpi
}

load pdf error

E/dalvikvm: Could not find class 'android.util.ArrayMap', referenced from method com.shockwave.pdfium.PdfDocument.
08-28 21:21:43.369 3565-4232/com.router.report W/dalvikvm: VFY: unable to resolve new-instance 2372 (Landroid/util/ArrayMap;) in Lcom/shockwave/pdfium/PdfDocument;
08-28 21:21:43.369 3565-4232/com.router.report D/dalvikvm: VFY: replacing opcode 0x22 at 0x0003
08-28 21:21:43.369 3565-4232/com.router.report D/dalvikvm: DexOpt: unable to opt direct call 0x4da1 at 0x05 in Lcom/shockwave/pdfium/PdfDocument;.
08-28 21:21:43.409 3565-3565/com.router.report E/PdfDetailActivity: android.util.ArrayMap

a visit

i used android-pdf-view and build my apk,then size +16MB,then i traced to this project,
too big! i can't refactor this project.
give me a way, please.please!please;

While the so file exist in the libs folder, couldn't find it when running the application

09-13 16:46:12.154 27548-27548/? E/com.shockwave.pdfium.PdfiumCore: Native libraries failed to load - java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.shockwave.pdfiumtest-2/base.apk"],nativeLibraryDirectories=[/data/app/com.shockwave.pdfiumtest-2/lib/arm64, /system/lib64, /vendor/lib64]]] couldn't find "libc++_shared.so"
09-13 16:46:12.160 27548-27548/? E/art: No implementation found for long com.shockwave.pdfium.PdfiumCore.nativeOpenDocument(int, java.lang.String) (tried Java_com_shockwave_pdfium_PdfiumCore_nativeOpenDocument and Java_com_shockwave_pdfium_PdfiumCore_nativeOpenDocument__ILjava_lang_String_2)
09-13 16:46:12.161 27548-27548/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.shockwave.pdfiumtest, PID: 27548
java.lang.UnsatisfiedLinkError: No implementation found for long com.shockwave.pdfium.PdfiumCore.nativeOpenDocument(int, java.lang.String) (tried Java_com_shockwave_pdfium_PdfiumCore_nativeOpenDocument and Java_com_shockwave_pdfium_PdfiumCore_nativeOpenDocument__ILjava_lang_String_2)
at com.shockwave.pdfium.PdfiumCore.nativeOpenDocument(Native Method)
at com.shockwave.pdfium.PdfiumCore.newDocument(PdfiumCore.java:135)
at com.shockwave.pdfium.PdfiumCore.newDocument(PdfiumCore.java:127)
at com.shockwave.pdfiumtest.PdfActivity.onCreate(PdfActivity.java:128)
at android.app.Activity.performCreate(Activity.java:6875)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2711)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2819)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1558)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6396)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
09-13 16:46:12.595 476-2506/? E/ANDR-PERF-MPCTL: Invalid profile no. 0, total profiles 0 only

renderPageBitmap - transparency

Is it possible to create a bitmap with transparency, using renderPageBitmap?
At this moment a white background is added to the bitmap. But I want the bitmap without a background.

Apk size increased upto 15 MB

Including the dependency

compile 'com.github.barteksc:pdfium-android:1.4.0'

increasing the apk size upto 15.4 MB,


I just want to use this library for creating thumb from a pdf page.

Q. Is there any way to just include a specific module from this library that is used to perform only Pdf page rendering?

like google library, you just need to add specific modules, not whole library
for example, for map

compile 'com.google.android.gms:play-services-maps:8.4.0'

Save loaded Pdf to another location (Isuue due to Google Drive Files)

I am using

ParcelFileDescriptor fd = App.applicationContext.getContentResolver().openFileDescriptor(pdfUri, "r");
PdfDocument pdfDocument = pdfiumCore.newDocument(fd);

to load Pdf document.

Is there any way to save this document to any other location using Pdfium Android?

Basically I am getting uri from Google drive file, I want to save that file in my local storage.

Method for reproducibly rebuilding the bundled pdfium shared objects?

I filed this upstream, figuring that only the original author knew how he built the shared objects checked into git, but I see that @barteksc rebuilt them after all according to git history. Sorry for the issue duplication, but it appears that upstream has gone silent anyhow.

Repost:

It would be awesome if the project had documentation for building the shared objects again from source, and where the source code that produced them lives, and also what specific version built them in order to reproduce them deterministically. Right now all we have is ELF blobs checked into git.

Was it the upstream android pdfium tree (https://android.googlesource.com/platform/external/pdfium/) that built them? If so, is it possible to document how it was done (scripting it would be even better) so it can be readily reproduced for new versions of pdfium?

Thank you!

mshockwave#12

ndkbuild error: ISO C++ forbids initialization of member 'pdfDocument'

when cd to .../src/main/jni and run ndkbuild, got error:

/src/main/jni/src/mainJNILib.cpp:48:33: error: ISO C++ forbids initialization of member 'pdfDocument' [-fpermissive]
/src/main/jni/src/mainJNILib.cpp:48:33: error: making 'pdfDocument' static [-fpermissive]
/src/main/jni/src/mainJNILib.cpp:48:33: error: invalid in-class initialization of static data member of non-integral type 'FPDF_DOCUMENT {aka void*}'

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.