Flutter for web编写新标签页

4

我有一个以base64编码的html字节文件。

我想要执行类似于以下操作:

let pdfWindow = window.open("")
pdfWindow.document.write("<iframe width='100%' height='100%' src='data:application/pdf;base64, " + encodeURI(base64EncodedPDF) + "'></iframe>")

在Flutter Web中,但是当我运行时

var openWindow = html.window.open("", "Form");

我没有能力编写pdf的HTML代码。

我的目标是能够从浏览器中打印pdf文件,

有人知道接下来该去哪里吗?

1个回答

0

使用 url_launch 包 url_launch

void main() {
runApp(Scaffold(
body: Center(
  child: RaisedButton(
    onPressed: _launchURL,
    child: Text('Show Flutter homepage'),
     ),
   ),
  ));
}

 _launchURL() async {
 const url = 'https://flutter.dev';
  if (await canLaunch(url)) {
 await launch(url);
 } else {
throw 'Could not launch $url';
 }
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接