0

I used the pdf package in my Flutter web project. It is completely working while I run it in debug or release mode, but when the web is deployed, it is not working. We can see it is clickable, but nothing happens after clicking.

Currently, when I click on the button, I can see it is clicked, but nothing happens. I want to generate a pdf while clicking, and this problem only arises when the web is deployed.

I tried to put this code in the index.html file, but nothing happened.

<script type="text/javascript">
 pdfjsLib.GlobalWorkerOptions.workerSrc =
 "https://cdn.jsdelivr.net/npm/[email protected]/build/pdf.worker.min.js";
 pdfRenderOptions = {
 // where cmaps are downloaded from
 cMapUrl: "https://cdn.jsdelivr.net/npm/[email protected]/cmaps/",
 // The cmaps are compressed in the case
 cMapPacked: true,
 // any other options for pdfjsLib.getDocument.
 // params: {}
 };
</script>
VLAZ
29.6k9 gold badges65 silver badges88 bronze badges
asked May 2, 2024 at 9:20
1
  • Please also share the current behaviour and expected behaviour so that ppl can help. Commented May 2, 2024 at 9:27

1 Answer 1

0

I had used a font in my code as

 static getGujaratiFont() async {
 final font = await rootBundle.load("fonts/NotoSansGujarati.ttf");
 gujaratiFont = pw.Font.ttf(font);

}

and my path in pubspec.yaml file is

 assets:
 - assets/fonts/NotoSansGujarati.ttf

so, there is 'rootBundle' is take automatic assets while debugging web but when web is deployed i have to set path in my font as rootBundle.load("assets/fonts/NotoSansGujarati.ttf"); then it is working

answered May 15, 2024 at 10:10
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.