espresso3389 / flutter_pdf_render

A Flutter package, which renders PDF pages.
https://pub.dev/packages/pdf_render
MIT License
108 stars 71 forks source link

Help, Get worker.min.js leak when resize flutter web #135

Open anggaaryas opened 1 year ago

anggaaryas commented 1 year ago

Screenshot 2023-11-27 120827

Dont know whats wrong with my code

 Expanded(
            child: openedFile != null
                ? PdfViewer.openData(openedFile!,
                    viewerController: controller,)
                : Container())

index.html script. i have qrcode scanner, and google maps api too but it is normal. I suspect that the bug is from worker

pdfjsLib.GlobalWorkerOptions.workerSrc =
    "https://cdn.jsdelivr.net/npm/pdfjs-dist@3.4.120/build/pdf.worker.min.js";
  <script src="https://unpkg.com/@zxing/library@0.19.1" type="application/javascript"></script>

  <!-- This script adds the flutter initialization JS code -->
  <script src="flutter.js" defer></script>

  <script src="https://maps.googleapis.com/maps/api/js?key=API-KEY"></script>

  <!-- IMPORTANT: load pdfjs files -->
  <script
          src="https://cdn.jsdelivr.net/npm/pdfjs-dist@3.4.120/build/pdf.min.js"
          type="text/javascript"
  ></script>
  <script type="text/javascript">
  pdfjsLib.GlobalWorkerOptions.workerSrc =
    "https://cdn.jsdelivr.net/npm/pdfjs-dist@3.4.120/build/pdf.worker.min.js";
  pdfRenderOptions = {
    // where cmaps are downloaded from
    cMapUrl: "https://cdn.jsdelivr.net/npm/pdfjs-dist@3.4.120/cmaps/",
    // The cmaps are compressed in the case
    cMapPacked: true,
    // any other options for pdfjsLib.getDocument.
    // params: {}
  };
</script>

Flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.13.9, on Microsoft Windows [Version 10.0.22631.2715], locale id-ID)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2022 17.4.4)
[√] Android Studio (version 2023.1)
[√] VS Code (version 1.85.0-insider)
[√] Connected device (3 available)
[√] Network resources

• No issues found!
anggaaryas commented 1 year ago

I thinks it is related to #126 too because its flash and re download the pdf.js . Maybe bug when rebuilding viewer 🤔