在kony FFI中传递本机android Webview对象

时间:2016-03-16 06:09:40

标签: ffi kony

我在原生android.In中创建了pdf WebView库。必须传递Webiew对象和String.let我知道如何在kony FFI中传递webview对象。

下面是添加静态方法库代码:

public static void pdfGeneration(WebView webView,String name){

    webView.measure(View.MeasureSpec.makeMeasureSpec(
                    View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED),
            View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
    webView.layout(0, 0, webView.getMeasuredWidth(),
            webView.getMeasuredHeight());
    webView.setDrawingCacheEnabled(true);
    webView.buildDrawingCache();

    // create a new document
    PdfDocument document = new PdfDocument();

    // crate a page description
    PageInfo pageInfo = new PageInfo.Builder(webView.getMeasuredWidth(), webView.getMeasuredHeight(), 1).create();

    // start a page
    Page page = document.startPage(pageInfo);

    // draw something on the page
    webView.draw(page.getCanvas());

    // finish the page
    document.finishPage(page);


    try {
        String path = Environment.getExternalStorageDirectory().toString();
        OutputStream fOut = null;
        File file = new File(path, "/"+name+".pdf");
        fOut = new FileOutputStream(file);
        document.writeTo(fOut);
        // close the document
        document.close();
        fOut.flush();
        fOut.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}`

0 个答案:

没有答案