Qoppa PDF Android NullPointer

六眼飞鱼酱① 提交于 2019-12-11 09:21:44

问题


I`m trying qoppapdf in my App and it runs into an NullPointer in the following code:

 PDFDocument pdf = null;
    try {
        pdf = new PDFDocument(url, null);
    } catch (PDFException e) {
        e.printStackTrace();
    }
    PDFPage page = pdf.getPage(0);

The error reads:

06-01 17:29:59.687  24761-24761/app W/dalvikvm﹕ Exception Ljava/lang/NullPointerException; thrown while initializing Lcom/qoppa/android/pdfProcess/PDFPage;
06-01 17:29:59.687  24761-24761/app D/AndroidRuntime﹕ Shutting down VM
06-01 17:29:59.687  24761-24761/app W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x413d22a0)
06-01 17:29:59.757  24761-24763/app D/dalvikvm﹕ GC_CONCURRENT freed 2569K, 26% free 10659K/14343K, paused 4ms+13ms, total 68ms
06-01 17:29:59.757  24761-24761/app E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.ExceptionInInitializerError
            at com.qoppa.android.pdfProcess.PDFDocument$1.b(Unknown Source)
            at com.qoppa.android.pdfViewer.e.p.b(Unknown Source)
            at com.qoppa.android.pdfProcess.PDFDocument.b(Unknown Source)
            at com.qoppa.android.pdfProcess.PDFDocument.<init>(Unknown Source)
            at com.qoppa.android.pdfProcess.PDFDocument.<init>(Unknown Source)
            at com.qoppa.android.pdfProcess.PDFDocument.<init>(Unknown Source)

The url which is used as input is valid and works fine with other PDF-Viewer. Does anyone experienced this or similar problems? Am I doing it wrong?

I would be pleased to hear from you :-)


回答1:


Please add the following code before loading the document:

//this static allows the sdk to access font assets,
//it must be set prior to utilizing libraries
StandardFontTF.mAssetMgr = getAssets();



来源:https://stackoverflow.com/questions/30577560/qoppa-pdf-android-nullpointer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!