openPdfInNewTab static method

void openPdfInNewTab(
  1. Uint8List? pdfBytes,
  2. String pdfName
)

Implementation

static void openPdfInNewTab(Uint8List? pdfBytes, String pdfName) {
  if (pdfBytes == null) return;

  final blob = html.Blob([pdfBytes], 'application/pdf');


  final url = html.Url.createObjectUrl(blob);


  final anchor = html.AnchorElement(href: url)
    ..target = '_blank'
    ..download = '$pdfName.pdf';
  anchor.click();
  html.Url.revokeObjectUrl(url);
}