我在原生android中创建了pdf WebView库。在静态方法中,必须传递Webiew对象和String。让我知道如何在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();
}
}`