相关文章推荐
不要命的汉堡包  ·  WebView全面解析 ·  2 月前    · 
拉风的勺子  ·  WebView - .NET MAUI | ...·  2 周前    · 
淡定的小摩托  ·  谷歌翻译API ...·  8 月前    · 
仗义的柠檬  ·  android - Proguard ...·  1 年前    · 

使用jspdf在android webview中下载pdf

0 人关注

我正在尝试在android webview中使用jspdf和jspdf-autotable。

///My print pdf code

const doc = new jsPDF();
autoTable(doc, { html: "#tb1", startY: 75, styles:{font:'Arial',fontSize:9}  });
autoTable(doc, { html: "#tb2", startY: (doc as any).lastAutoTable.finalY +5, styles
               {overflow:'linebreak',font:'Arial',fontSize:9 },  });
doc.save("Invoice.pdf");

// 我的安卓webview代码

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    web = findViewById(R.id.webView);
    WebSettings webSettings = web.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setAllowFileAccess(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    web.setWebViewClient(new Callback());