Qoppa PDF Android NullPointer

时间:2015-06-01 15:36:23

标签: android pdf nullpointerexception pdf-viewer

我在我的应用程序中尝试使用qoppapdf,它在以下代码中遇到了NullPointer:

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

错误如下:

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)

用作输入的网址有效,可与其他PDF-Viewer一起使用。 有没有人遇到过这种或类似的问题?我做错了吗?

我很高兴收到你的来信:-)

1 个答案:

答案 0 :(得分:1)

请在加载文档前添加以下代码:

//这个静态允许sdk访问字体资产,
//必须在利用图书馆之前设置 StandardFontTF.mAssetMgr = getAssets();